You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

Instance already exists for a CI

2 replies [Last post]
RPL's picture
RPL
User offline. Last seen 11 years 17 weeks ago. Offline
Joined: 11/25/2008
Posts: 2

I am loading data from a CSV file into PS database using App engine and CI.Only the first row of data gets loaded ,while loading the 2nd row it gives an error saying Instance already exists for a CI.
So create failed.Can some one please help?
Following is my code:

/* ===>
This is a dynamically generated PeopleCode template to be used only as a helper
to the application developer.
You need to replace all references to '[*]' OR default values with  references to
PeopleCode variables and/or a Rec.Fields. */


Local File &fileLog;
Local ApiObject &oSession, &oAfAcctTransCi;
Local ApiObject &oAfAccountCrfCollection, &oAfAccountCrf;


Local File &INPUTFILE;
Local string &Filepath;
Local number &line_num;

Local Rowset &rsInput;
Local Record &rOutput;
Local SQL &SQL1;



Function errorHandler()
   Local ApiObject &oPSMessageCollection, &oPSMessage;
   Local number &i;
   Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;
   
   &oPSMessageCollection = &oSession.PSMessages;
   For &i = 1 To &oPSMessageCollection.Count
      &oPSMessage = &oPSMessageCollection.Item(&i);
      &sErrMsgSetNum = &oPSMessage.MessageSetNumber;
      &sErrMsgNum = &oPSMessage.MessageNumber;
      &sErrMsgText = &oPSMessage.Text;
      &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
   End-For;
   rem ***** Delete the Messages from the collection *****;
   &oPSMessageCollection.DeleteAll();
End-Function;

try
   rem ***** Set the Log File *****;
   &fileLog = GetFile("C:\temp\AF_ACCT_TRANS_CI.log", "w", "a", %FilePath_Absolute);
   &fileLog.WriteLine("Begin");
   rem ***** Get current PeopleSoft Session *****;
   &oSession = %Session;
   
   rem ***** Set the PeopleSoft Session Error Message Mode *****;
   rem ***** 0 - None *****;
   rem ***** 1 - PSMessage Collection only (default) *****;
   rem ***** 2 - Message Box only *****;
   rem ***** 3 - Both collection and message box *****;
   &oSession.PSMessagesMode = 1;
   
   rem ***** Get the Component Interface *****;
   &oAfAcctTransCi = &oSession.GetCompIntfc(CompIntfc.AF_ACCT_TRANS_CI);
   If &oAfAcctTransCi = Null Then
      errorHandler();
      throw CreateException(0, 0, "GetCompIntfc failed");
   End-If;
   
   rem ***** Set the Component Interface Mode *****;
   &oAfAcctTransCi.InteractiveMode = True;
   &oAfAcctTransCi.GetHistoryItems = True;
   &oAfAcctTransCi.EditHistoryItems = True;
   
   /* Create an instance of the Records */
   &rOutput = CreateRecord(Record.AF_ACCT_TRANS);
   &rsInput = CreateRowset(Record.AF_ACCT_TRANS);
   &fileLog.WriteLine("before set keys");
   
   
   /* Create an instance of the SQL statement for insert */
   
   &SQL1 = CreateSQL("%Insert(:1)");
   
   &INPUTFILE = GetFile("c:\temp\testfile.csv", "R", "A", %FilePath_Absolute);
   &fileLog.WriteLine("try3");
   
   If &INPUTFILE.IsOpen Then
      If &INPUTFILE.SetFileLayout(FileLayout.AF_ACT_TRANS_FL) Then
         
         &line_num = 0;
         
         /* read in first line to the recordset */
         &rsInput = &INPUTFILE.ReadRowset();
         
         
         While &rsInput <> Null
           
            &line_num = &line_num + 1;
           
           
            &fileLog.WriteLine("&line_num" | &line_num);
           
            /* copy values from file to record */
            &rsInput(1).GetRecord(1).CopyFieldsTo(&rOutput);
           
           
            &fileLog.WriteLine("try1");
            rem ***** Set Component Interface Get/Create Keys *****;
            &oAfAcctTransCi.AF_ACCOUNT_OLD = &rOutput.AF_ACCOUNT_OLD.Value;
            rem   &fileLog.WriteLine("AF_ACCOUNT_OLD" | &rsInput.AF_ACCOUNT_OLD.Value);
            &oAfAcctTransCi.AF_TEMPLATE_CD = &rOutput.AF_TEMPLATE_CD.Value;
            rem   &fileLog.WriteLine("AF_TEMPLATE_CD" | &rsInput.AF_TEMPLATE_CD.Value);
            &oAfAcctTransCi.AF_BUSINESS_UNIT = &rOutput.AF_BUSINESS_UNIT.Value;
            rem   &fileLog.WriteLine("AF_BUSINESS_UNIT" | &rsInput.AF_BUSINESS_UNIT.Value);
           
            &fileLog.WriteLine("after set keys");
            rem ***** Execute Get *****;
            /*     If Not &oAfAcctTransCi.Get() Then
               rem ***** No rows exist for the specified keys.*****;
               errorHandler();
               throw CreateException(0, 0, "Get failed");
            End-If;
          */
            &fileLog.WriteLine("before create keys");
            rem ***** Execute Create ******;
            If Not &oAfAcctTransCi.Create() Then;
               
               rem ***** Unable to Create Component Interface for the Add keys provided. *****;
               errorHandler();
               throw CreateException(0, 0, "Create failed");
            End-If;
           
            &fileLog.WriteLine("after create keys");
           
            &fileLog.WriteLine("try2");
           
           
            rem ***** Begin: Get/Set Component Interface Properties *****;
            rem ***** Get/Set Level 0 Field Properties *****;
            &oAfAcctTransCi.AF_ACCOUNT_OLD = &rOutput.AF_ACCOUNT_OLD.Value;
            &fileLog.WriteLine(".AF_ACCOUNT_OLD" | &rOutput.AF_ACCOUNT_OLD.Value);
            &oAfAcctTransCi.AF_TEMPLATE_CD = &rOutput.AF_TEMPLATE_CD.Value;
            &fileLog.WriteLine("AF_TEMPLATE_CD" | &rOutput.AF_TEMPLATE_CD.Value);
            &oAfAcctTransCi.AF_BUSINESS_UNIT = &rOutput.AF_BUSINESS_UNIT.Value;
            &fileLog.WriteLine("AF_BUSINESS_UNIT" | &rOutput.AF_BUSINESS_UNIT.Value);
           
            rem ***** Set/Get AF_ACCOUNT_CRF Collection Field Properties -- Parent: PS_ROOT Collection *****;
            &oAfAccountCrfCollection = &oAfAcctTransCi.AF_ACCOUNT_CRF;
           
            Local integer &i113;
            For &i113 = 1 To &oAfAccountCrfCollection.Count;
               &oAfAccountCrf = &oAfAccountCrfCollection.Item(&i113);
               
               
               &fileLog.WriteLine("&oAfAccountCrf.EFFDT = " | &oAfAccountCrf.EFFDT);
               &oAfAccountCrf.EFFDT = &rOutput.EFFDT.Value;
               &fileLog.WriteLine("&rOutput.EFFDT.Value" | &rOutput.EFFDT.Value);
               
               
               
               &fileLog.WriteLine("&oAfAccountCrf.ACCOUNT = " | &oAfAccountCrf.ACCOUNT);
               &oAfAccountCrf.ACCOUNT = &rOutput.ACCOUNT.Value;
               &fileLog.WriteLine("&rOutput.ACCOUNT.Value" | &rOutput.ACCOUNT.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.EFF_STATUS = " | &oAfAccountCrf.EFF_STATUS);
               &oAfAccountCrf.EFF_STATUS = &rOutput.EFF_STATUS.Value;
               &fileLog.WriteLine("&rOutput.EFF_STATUS.Value" | &rOutput.EFF_STATUS.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.PRODUCT = " | &oAfAccountCrf.PRODUCT);
               &oAfAccountCrf.PRODUCT = &rOutput.PRODUCT.Value;
               &fileLog.WriteLine("&rOutput.PRODUCT.Value" | &rOutput.PRODUCT.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.CHARTFIELD2 = " | &oAfAccountCrf.CHARTFIELD2);
               &oAfAccountCrf.CHARTFIELD2 = &rOutput.CHARTFIELD2.Value;
               &fileLog.WriteLine("&rOutput.CHARTFIELD2.Value" | &rOutput.CHARTFIELD2.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.FUND_CODE = " | &oAfAccountCrf.FUND_CODE);
               &oAfAccountCrf.FUND_CODE = &rOutput.FUND_CODE.Value;
               &fileLog.WriteLine("&rOutput.FUND_CODE.Value" | &rOutput.FUND_CODE.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.CHARTFIELD1 = " | &oAfAccountCrf.CHARTFIELD1);
               &oAfAccountCrf.CHARTFIELD1 = &rOutput.CHARTFIELD1.Value;
               &fileLog.WriteLine("&rOutput.CHARTFIELD1.Value" | &rOutput.CHARTFIELD1.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.AFFILIATE = " | &oAfAccountCrf.AFFILIATE);
               &oAfAccountCrf.AFFILIATE = &rOutput.AFFILIATE.Value;
               &fileLog.WriteLine("&rOutput.AFFILIATE.Value" | &rOutput.AFFILIATE.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.LEDGER_GROUP = " | &oAfAccountCrf.LEDGER_GROUP);
               &oAfAccountCrf.LEDGER_GROUP = &rOutput.LEDGER_GROUP.Value;
               &fileLog.WriteLine("&rOutput.LEDGER_GROUP.Value" | &rOutput.LEDGER_GROUP.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.DEPTID = " | &oAfAccountCrf.DEPTID);
               &oAfAccountCrf.DEPTID = &rOutput.DEPTID.Value;
               &fileLog.WriteLine("&rOutput.DEPTID.Value" | &rOutput.DEPTID.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.PROGRAM_CODE = " | &oAfAccountCrf.PROGRAM_CODE);
               &oAfAccountCrf.PROGRAM_CODE = &rOutput.PROGRAM_CODE.Value;
               &fileLog.WriteLine("&rOutput.PROGRAM_CODE.Value" | &rOutput.PROGRAM_CODE.Value);
               
               &fileLog.WriteLine("&oAfAccountCrf.CLASS_FLD = " | &oAfAccountCrf.CLASS_FLD);
               &oAfAccountCrf.CLASS_FLD = &rOutput.CLASS_FLD.Value;
               &fileLog.WriteLine("&rOutput.CLASS_FLD.Value" | &rOutput.CLASS_FLD.Value);
            End-For;
           
            &SQL1.Execute(&rOutput);
           
            &rsInput = &INPUTFILE.ReadRowset();
           
           
            rem ***** Execute Save *****;
            If Not &oAfAcctTransCi.Save() Then;
               errorHandler();
               throw CreateException(0, 0, "Save failed");
            End-If;
           
           
            &fileLog.WriteLine("saved");
            /*
            rem ***** Execute Cancel *****;
            If Not &oAfAcctTransCi.Cancel() Then;
               errorHandler();
               throw CreateException(0, 0, "Cancel failed");
            End-If;
            */
           
         End-While;
         
         
      End-If;
   End-If;
   
   &INPUTFILE.Close();
   
catch Exception &ex
   rem Handle the exception;
   &fileLog.WriteLine(&ex.ToString());
end-try;

&fileLog.WriteLine("End");
&fileLog.Close();

simrose's picture
User offline. Last seen 5 years 36 weeks ago. Offline
Joined: 08/01/2008
Posts: 33
Re: Instance already exists for a CI

Hi
the problem is that you are trying to create new child(add action) but using ITEM function
use insertitem to create new keys.

Probelm statement :
oAfAccountCrf = &oAfAccountCrfCollection.Item(&i113);

USE :
INSERTITEM

your not geting error for first row because &oAfAccountCrfCollection.Count value is one when component is blank(opened first time).
For &i113 = 1 To &oAfAccountCrfCollection.Count;
= For &i113 = 1 To 1;

Solution :

Check for first row if keys are blank
user item(1) for first row.
for other row then first row user INSERTITEM(1)

pseudo code -->
IF childkey1 = ' ' and childkey2=' ' and childkey3=' ' so on
then
&oAfAccountCrf = &oAfAccountCrfCollection.Item(1);
else
&oAfAccountCrf = &oAfAccountCrfCollection.InsertItem(1);

Cheer
Sim

Guest's picture
Guest (not verified)
Re: Instance already exists for a CI

Data has parent row and multiple child rows Tried suggestion but still get error:

PeopleTools 8.49.18 - Application Engine
Copyright (c) 1988-2010 PeopleSoft, Inc.
All Rights Reserved

PeopleTools SQL Trace value: 3 (0x3): c:\temp\FNDEV1.trc

Updating for EMPLID: K0000027571 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: Updating for EMPLID: K0000027571 (0,0) (0,0)

before CcCardDataExCollection K0000027571 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: before CcCardDataExCollection K0000027571 (0,0) (0,0)

after CcCardDataExCollection K0000027571 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: after CcCardDataExCollection K0000027571 (0,0) (0,0)

Invalid value -- press the prompt button or hyperlink for a list of valid values (15,11)

Error changing value. {KS_CC_EE_PROFILE.CC_CARD_DATA_EX(1).KS_CNTRL_ACCT_NUM} (91,34)

&oCcCardDataCollection K0000027571 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: &oCcCardDataCollection K0000027571 (0,0) (0,0)

&REC.BUSINESS_UNIT.Value: 02800 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: &REC.BUSINESS_UNIT.Value: 02800 (0,0) (0,0)

&count: 1 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: &count: 1 (0,0) (0,0)

&RoleCounter: 1 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: &RoleCounter: 1 (0,0) (0,0)

&count: 1 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: &count: 1 (0,0) (0,0)

&RoleCounter: 2 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: &RoleCounter: 2 (0,0) (0,0)

Updating for EMPLID: K0000165461 (0,0)
Message Set Number: 0
Message Number: 0
Message Reason: Updating for EMPLID: K0000165461 (0,0) (0,0)

Instance already exists {KS_CC_EE_PROFILE} (91,3)
Application Engine program KS_CC_CARD ended normally

Code

Local File &fileLog;
Local ApiObject &oSession, &oKsCcEeProfile;
Local ApiObject &oCcRqsthistVwCollection, &oCcRqsthistVw;
Local ApiObject &oCcCardDataExCollection, &oCcCardDataEx;
Local ApiObject &oCcCardDataCollection, &oCcCardData;
Local ApiObject &oCcCardSpeedchCollection, &oCcCardSpeedch;
Local ApiObject &oCcCardAuthCollection, &oCcCardAuth;
Local ApiObject &oCcCardRoleCollection, &oCcCardRole;
Local ApiObject &oCcVndrCardVwCollection, &oCcVndrCardVw;

Function errorHandler()
Local ApiObject &oPSMessageCollection, &oPSMessage;
Local number &i;
Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;

&oPSMessageCollection = &oSession.PSMessages;
For &i = 1 To &oPSMessageCollection.Count
&oPSMessage = &oPSMessageCollection.Item(&i);
&sErrMsgSetNum = &oPSMessage.MessageSetNumber;
&sErrMsgNum = &oPSMessage.MessageNumber;
&sErrMsgText = &oPSMessage.Text;
rem &fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
End-For;
rem ***** Delete the Messages from the collection *****;
&oPSMessageCollection.DeleteAll();
End-Function;

try
rem ***** Set the Log File *****;
rem &fileLog = GetFile("C:\temp\KS_CC_EE_PROFILE.log", "w", "a", %FilePath_Absolute);
rem &fileLog.WriteLine("Begin");
rem ***** Get current PeopleSoft Session *****;
&oSession = %Session;

rem ***** Set the PeopleSoft Session Error Message Mode *****;
rem ***** 0 - None *****;
rem ***** 1 - PSMessage Collection only (default) *****;
rem ***** 2 - Message Box only *****;
rem ***** 3 - Both collection and message box *****;
&oSession.PSMessagesMode = 1;

rem ***** Get the Component Interface *****;
&oKsCcEeProfile = &oSession.GetCompIntfc(CompIntfc.KS_CC_EE_PROFILE);
If &oKsCcEeProfile = Null Then
errorHandler();
throw CreateException(0, 0, "GetCompIntfc failed");
End-If;

rem ***** Set the Component Interface Mode *****;
&oKsCcEeProfile.InteractiveMode = True;
&oKsCcEeProfile.GetHistoryItems = True;
&oKsCcEeProfile.EditHistoryItems = False;

&REC = CreateRecord(Record.KS_CC_CARD_LOAD);
&SQL = CreateSQL("%selectall(:1) ORDER BY EMPLID", Record.KS_CC_CARD_LOAD);
&SQL.Reusecursor = True;

While &SQL.Fetch(&REC)
&hdrcount = &hdrcount + 1;
rem ***** Set Component Interface Get/Create Keys *****;
&oKsCcEeProfile.EMPLID = &REC.EMPLID.Value;
MessageBox(0, "", 0, 0, "Updating for EMPLID: " | &REC.EMPLID.Value);
rem ***** Execute Get *****;
If Not &oKsCcEeProfile.Get() Then

rem ***** No rows exist for the specified keys.*****;
errorHandler();
throw CreateException(0, 0, "Get failed");
End-If;

rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;
rem &fileLog.WriteLine("&oKsCcEeProfile.SELECTED_ROW = " | &oKsCcEeProfile.SELECTED_ROW);
&oKsCcEeProfile.SELECTED_ROW = 0;
rem &fileLog.WriteLine("&oKsCcEeProfile.CC_MASK_OPT = " | &oKsCcEeProfile.CC_MASK_OPT);
&oKsCcEeProfile.CC_MASK_OPT = "N";
rem &fileLog.WriteLine("&oKsCcEeProfile.CC_RQSTHIST_PB = " | &oKsCcEeProfile.CC_RQSTHIST_PB);
rem &oKsCcEeProfile.CC_RQSTHIST_PB = [*];
<*
rem ***** Set/Get CC_RQSTHIST_VW Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oCcRqsthistVwCollection = &oKsCcEeProfile.CC_RQSTHIST_VW;
Local integer &i138;
For &i138 = 1 To &oCcRqsthistVwCollection.Count;
&oCcRqsthistVw = &oCcRqsthistVwCollection.Item(&i138);
&fileLog.WriteLine("&oCcRqsthistVw.PV_CC_REQUEST_NUM = " | &oCcRqsthistVw.PV_CC_REQUEST_NUM);
rem &oCcRqsthistVw.PV_CC_REQUEST_NUM = [*];
&fileLog.WriteLine("&oCcRqsthistVw.CREDIT_CARD_VENDOR = " | &oCcRqsthistVw.CREDIT_CARD_VENDOR);
rem &oCcRqsthistVw.CREDIT_CARD_VENDOR = [*];
&fileLog.WriteLine("&oCcRqsthistVw.ACCOUNT = " | &oCcRqsthistVw.ACCOUNT);
rem &oCcRqsthistVw.ACCOUNT = [*];
&fileLog.WriteLine("&oCcRqsthistVw.CURRENCY_CD = " | &oCcRqsthistVw.CURRENCY_CD);
rem &oCcRqsthistVw.CURRENCY_CD = [*];
&fileLog.WriteLine("&oCcRqsthistVw.LIMIT_PO_AMT = " | &oCcRqsthistVw.LIMIT_PO_AMT);
rem &oCcRqsthistVw.LIMIT_PO_AMT = [*];
&fileLog.WriteLine("&oCcRqsthistVw.LIMIT_CYCLE_AMT = " | &oCcRqsthistVw.LIMIT_CYCLE_AMT);
rem &oCcRqsthistVw.LIMIT_CYCLE_AMT = [*];
&fileLog.WriteLine("&oCcRqsthistVw.NBR_PO_PER_DAY = " | &oCcRqsthistVw.NBR_PO_PER_DAY);
rem &oCcRqsthistVw.NBR_PO_PER_DAY = [*];
&fileLog.WriteLine("&oCcRqsthistVw.NBR_PO_PER_CYCLE = " | &oCcRqsthistVw.NBR_PO_PER_CYCLE);
rem &oCcRqsthistVw.NBR_PO_PER_CYCLE = [*];
&fileLog.WriteLine("&oCcRqsthistVw.PROCESSED_FLG = " | &oCcRqsthistVw.PROCESSED_FLG);
rem &oCcRqsthistVw.PROCESSED_FLG = [*];
End-For;
*>
rem ***** Set/Get CC_CARD_DATA_EX Collection Field Properties -- Parent: PS_ROOT Collection *****;
MessageBox(0, "", 0, 0, "before CcCardDataExCollection " | &REC.EMPLID.Value);
&oCcCardDataExCollection = &oKsCcEeProfile.CC_CARD_DATA_EX;
rem Local integer &i148;
rem For &i148 = 1 To &oCcCardDataExCollection.Count;
/* Tom Hins changed next line from .item to .Insertitem changed back 5-4 added if statement */
If &hdrcount = 1 Then
&oCcCardDataEx = &oCcCardDataExCollection.Item(1);
MessageBox(0, "", 0, 0, "after CcCardDataExCollection " | &REC.EMPLID.Value);
Else
&oCcCardDataEx = &oCcCardDataExCollection.InsertItem(1);
End-If;
If All(&oCcCardDataEx.BUSINESS_UNIT) Then
&oCcCardDataEx = &oCcCardDataExCollection.InsertItem(1);
End-If;

rem &fileLog.WriteLine("&oCcCardDataEx.BUSINESS_UNIT = " | &oCcCardDataEx.BUSINESS_UNIT);
&oCcCardDataEx.BUSINESS_UNIT = &REC.BUSINESS_UNIT.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.CREDIT_CARD_VENDOR_1 = " | &oCcCardDataEx.CREDIT_CARD_VENDOR_1);
&oCcCardDataEx.CREDIT_CARD_VENDOR_1 = "UMB";
rem &fileLog.WriteLine("&oCcCardDataEx.CRDMEM_ACCT_NBR_0 = " | &oCcCardDataEx.CRDMEM_ACCT_NBR_0);
/* Tom hins unremmed next line and added value */
&oCcCardDataEx.CRDMEM_ACCT_NBR_0 = &REC.CRDMEM_ACCT_NBR.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.CURRENCY_CD_1 = " | &oCcCardDataEx.CURRENCY_CD_1);
rem &oCcCardDataEx.CURRENCY_CD_1 = "USD";
rem &fileLog.WriteLine("&oCcCardDataEx.EXPIRATION_DT = " | &oCcCardDataEx.EXPIRATION_DT);
&oCcCardDataEx.EXPIRATION_DT = &REC.EXPIRATION_DT.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.LIMIT_AMOUNT = " | &oCcCardDataEx.LIMIT_AMOUNT);
rem &oCcCardDataEx.LIMIT_AMOUNT = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.DT_ISSUED_TO_EMPL = " | &oCcCardDataEx.DT_ISSUED_TO_EMPL);
&oCcCardDataEx.DT_ISSUED_TO_EMPL = &REC.DT_ISSUED_TO_EMPL.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.CC_CARD_TYPE = " | &oCcCardDataEx.CC_CARD_TYPE);
&oCcCardDataEx.CC_CARD_TYPE = "VISA";
rem &fileLog.WriteLine("&oCcCardDataEx.CC_CARD_FUNCTION = " | &oCcCardDataEx.CC_CARD_FUNCTION);
rem &oCcCardDataEx.CC_CARD_FUNCTION = "PRCR";
rem &fileLog.WriteLine("&oCcCardDataEx.BUSINESS_UNIT = " | &oCcCardDataEx.BUSINESS_UNIT);
/* Tom hins unremmed next line and added value */
&oCcCardDataEx.BUSINESS_UNIT = &REC.BUSINESS_UNIT.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.CC_VENDOR_CARD = " | &oCcCardDataEx.CC_VENDOR_CARD);
rem &oCcCardDataEx.CC_VENDOR_CARD = "N";
rem &fileLog.WriteLine("&oCcCardDataEx.CRDMEM_ACCT_NBR = " | &oCcCardDataEx.CRDMEM_ACCT_NBR);
&oCcCardDataEx.CRDMEM_ACCT_NBR = &REC.CRDMEM_ACCT_NBR.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.CRDMEM_ACCT_MSK = " | &oCcCardDataEx.CRDMEM_ACCT_MSK);
&oCcCardDataEx.CRDMEM_ACCT_MSK = &REC.CRDMEM_ACCT_NBR.Value;
&oCcCardDataEx.KS_CNTRL_ACCT_NUM = &REC.KS_CNTRL_ACCT_NUM.Value;
rem &fileLog.WriteLine("&oCcCardDataEx.LIMIT_PO_AMT_1 = " | &oCcCardDataEx.LIMIT_PO_AMT_1);
rem &oCcCardDataEx.LIMIT_PO_AMT_1 = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.LIMIT_CYCLE_AMT_1 = " | &oCcCardDataEx.LIMIT_CYCLE_AMT_1);
rem &oCcCardDataEx.LIMIT_CYCLE_AMT_1 = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.NBR_PO_PER_DAY_1 = " | &oCcCardDataEx.NBR_PO_PER_DAY_1);
rem &oCcCardDataEx.NBR_PO_PER_DAY_1 = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.NBR_PO_PER_CYCLE_1 = " | &oCcCardDataEx.NBR_PO_PER_CYCLE_1);
rem &oCcCardDataEx.NBR_PO_PER_CYCLE_1 = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.SHIPTO_ID = " | &oCcCardDataEx.SHIPTO_ID);
rem &oCcCardDataEx.SHIPTO_ID = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.OPRCLASS = " | &oCcCardDataEx.OPRCLASS);
rem &oCcCardDataEx.OPRCLASS = [*];
rem &fileLog.WriteLine("&oCcCardDataEx.DISTRIB_CHOICE = " | &oCcCardDataEx.DISTRIB_CHOICE);
&oCcCardDataEx.DISTRIB_CHOICE = 1;

MessageBox(0, "", 0, 0, "&oCcCardDataCollection " | &REC.EMPLID.Value);

rem ***** Set CC_CARD_DATA Collection Field Properties -- Parent: CC_CARD_DATA_EX Collection *****;
&oCcCardDataCollection = &oCcCardDataEx.CC_CARD_DATA;
rem For &i268 = 1 To &oCcCardDataCollection.Count;
/* Tom Hins changed next line from .item to .Insertitem changed back */
&oCcCardData = &oCcCardDataCollection.Item(1);

<*
If All(&oCcCardData.BUSINESS_UNIT_GL) Then
&oCcCardData = &oCcCardDataCollection.insertItem(1);
End-If;
*>

rem &fileLog.WriteLine("&oCcCardData.BUSINESS_UNIT_GL = " | &oCcCardData.BUSINESS_UNIT_GL);
&oCcCardData.BUSINESS_UNIT_GL = &REC.BUSINESS_UNIT.Value;
MessageBox(0, "", 0, 0, "&REC.BUSINESS_UNIT.Value: " | &REC.BUSINESS_UNIT.Value);
rem &fileLog.WriteLine("&oCcCardData.ACCOUNT_1 = " | &oCcCardData.ACCOUNT_1);
&oCcCardData.ACCOUNT_1 = &REC.ACCOUNT.Value;
rem &fileLog.WriteLine("&oCcCardData.ALTACCT = " | &oCcCardData.ALTACCT);
rem &oCcCardData.ALTACCT = [*];
rem &fileLog.WriteLine("&oCcCardData.DEPTID = " | &oCcCardData.DEPTID);
&oCcCardData.DEPTID = "0280000000";
rem &fileLog.WriteLine("&oCcCardData.OPERATING_UNIT = " | &oCcCardData.OPERATING_UNIT);
rem &oCcCardData.OPERATING_UNIT = [*];
rem &fileLog.WriteLine("&oCcCardData.PRODUCT = " | &oCcCardData.PRODUCT);
rem &oCcCardData.PRODUCT = [*];
rem &fileLog.WriteLine("&oCcCardData.FUND_CODE = " | &oCcCardData.FUND_CODE);
rem &oCcCardData.FUND_CODE = [*];
rem &fileLog.WriteLine("&oCcCardData.CLASS_FLD = " | &oCcCardData.CLASS_FLD);
rem &oCcCardData.CLASS_FLD = [*];
rem &fileLog.WriteLine("&oCcCardData.PROGRAM_CODE = " | &oCcCardData.PROGRAM_CODE);
rem &oCcCardData.PROGRAM_CODE = [*];
rem &fileLog.WriteLine("&oCcCardData.BUDGET_REF = " | &oCcCardData.BUDGET_REF);
rem &oCcCardData.BUDGET_REF = [*];
rem &fileLog.WriteLine("&oCcCardData.AFFILIATE = " | &oCcCardData.AFFILIATE);
rem &oCcCardData.AFFILIATE = [*];
rem &fileLog.WriteLine("&oCcCardData.AFFILIATE_INTRA1 = " | &oCcCardData.AFFILIATE_INTRA1);
rem &oCcCardData.AFFILIATE_INTRA1 = [*];
rem &fileLog.WriteLine("&oCcCardData.AFFILIATE_INTRA2 = " | &oCcCardData.AFFILIATE_INTRA2);
rem &oCcCardData.AFFILIATE_INTRA2 = [*];
rem &fileLog.WriteLine("&oCcCardData.CHARTFIELD1 = " | &oCcCardData.CHARTFIELD1);
rem &oCcCardData.CHARTFIELD1 = [*];
rem &fileLog.WriteLine("&oCcCardData.CHARTFIELD2 = " | &oCcCardData.CHARTFIELD2);
rem &oCcCardData.CHARTFIELD2 = [*];
rem &fileLog.WriteLine("&oCcCardData.CHARTFIELD3 = " | &oCcCardData.CHARTFIELD3);
rem &oCcCardData.CHARTFIELD3 = [*];
rem &fileLog.WriteLine("&oCcCardData.BUSINESS_UNIT_PC = " | &oCcCardData.BUSINESS_UNIT_PC);
rem &oCcCardData.BUSINESS_UNIT_PC = [*];
rem &fileLog.WriteLine("&oCcCardData.PROJECT_ID = " | &oCcCardData.PROJECT_ID);
rem &oCcCardData.PROJECT_ID = [*];
rem &fileLog.WriteLine("&oCcCardData.ACTIVITY_ID = " | &oCcCardData.ACTIVITY_ID);
rem &oCcCardData.ACTIVITY_ID = [*];
rem &fileLog.WriteLine("&oCcCardData.RESOURCE_TYPE = " | &oCcCardData.RESOURCE_TYPE);
rem &oCcCardData.RESOURCE_TYPE = [*];
rem &fileLog.WriteLine("&oCcCardData.RESOURCE_CATEGORY = " | &oCcCardData.RESOURCE_CATEGORY);
rem &oCcCardData.RESOURCE_CATEGORY = [*];
rem &fileLog.WriteLine("&oCcCardData.RESOURCE_SUB_CAT = " | &oCcCardData.RESOURCE_SUB_CAT);
rem &oCcCardData.RESOURCE_SUB_CAT = [*];
rem &fileLog.WriteLine("&oCcCardData.LOCATION = " | &oCcCardData.LOCATION);
rem &oCcCardData.LOCATION = [*];
rem &fileLog.WriteLine("&oCcCardData.ENTRY_EVENT = " | &oCcCardData.ENTRY_EVENT);
rem &oCcCardData.ENTRY_EVENT = [*];
<* Tom Hins start
rem ***** Set CC_CARD_SPEEDCH Collection Field Properties -- Parent: CC_CARD_DATA_EX Collection *****;
rem &oCcCardSpeedchCollection = &oCcCardDataEx.CC_CARD_SPEEDCH;
Local integer &i293;
For &i293 = 1 To &oCcCardSpeedchCollection.Count;
&oCcCardSpeedch = &oCcCardSpeedchCollection.Item(&i293);
rem &fileLog.WriteLine("&oCcCardSpeedch.SETID = " | &oCcCardSpeedch.SETID);
rem &oCcCardSpeedch.SETID = [*];
rem &fileLog.WriteLine("&oCcCardSpeedch.SPEEDCHART_KEY = " | &oCcCardSpeedch.SPEEDCHART_KEY);
rem &oCcCardSpeedch.SPEEDCHART_KEY = [*];
rem &fileLog.WriteLine("&oCcCardSpeedch.DEFAULT_FLAG = " | &oCcCardSpeedch.DEFAULT_FLAG);
rem &oCcCardSpeedch.DEFAULT_FLAG = [*]; Tom Hins end *>

rem ***** Set CC_CARD_AUTH Collection Field Properties -- Parent: CC_CARD_DATA_EX Collection *****;
&oCcCardAuthCollection = &oCcCardDataEx.CC_CARD_AUTH;
Local integer &i297;
For &i297 = 1 To &oCcCardAuthCollection.Count;
/* Tom Hins changed next line from .item to .Insertitem changed back remmed out next line pm 5-4*/
rem &oCcCardAuth = &oCcCardAuthCollection.Item(&i297);
rem &fileLog.WriteLine("&oCcCardAuth.COMMODITY_CD = " | &oCcCardAuth.COMMODITY_CD);
rem &oCcCardAuth.COMMODITY_CD = [*];
rem &fileLog.WriteLine("&oCcCardAuth.LIMIT_AMOUNT_1 = " | &oCcCardAuth.LIMIT_AMOUNT_1);
rem &oCcCardAuth.LIMIT_AMOUNT_1 = [*];
rem &fileLog.WriteLine("&oCcCardAuth.ACCOUNT_3 = " | &oCcCardAuth.ACCOUNT_3);
rem &oCcCardAuth.ACCOUNT_3 = [*];
rem &fileLog.WriteLine("&oCcCardAuth.LIMIT_TRANS_AMT = " | &oCcCardAuth.LIMIT_TRANS_AMT);
rem &oCcCardAuth.LIMIT_TRANS_AMT = [*];

<* Tom Hins added following *>
&RoleCounter = 1;
&REC2 = CreateRecord(Record.KS_CC_ROLE_LD);
&SQL1 = CreateSQL("%selectall(:1) Where CRDMEM_ACCT_NBR = :2 AND EMPLID = :3", Record.KS_CC_ROLE_LD, &REC.CRDMEM_ACCT_NBR.Value, &REC.EMPLID.Value);
&SQL1.Reusecursor = True;

&oCcCardRoleCollection = &oCcCardDataEx.CC_CARD_ROLE;

While &SQL1.Fetch(&REC2)

rem ***** Set CC_CARD_ROLE Collection Field Properties -- Parent: CC_CARD_DATA_EX Collection *****;

rem Local integer &i2103;
rem For &i2103 = 1 To &oCcCardRoleCollection.Count;
&count = &oCcCardRoleCollection.Count;
MessageBox(0, "", 0, 0, "&count: " | &count);

MessageBox(0, "", 0, 0, "&RoleCounter: " | &RoleCounter);
If &RoleCounter = 1 Then
/* Tom Hins changed next lines from .item to .Insertitem left 2nd row no success */
&oCcCardRole = &oCcCardRoleCollection.Item(1);
Else
&oCcCardRole = &oCcCardRoleCollection.InsertItem(1);
End-If;
rem &oCcCardRole = &oCcCardRoleCollection.Item(&i2103);
rem &fileLog.WriteLine("&oCcCardRole.OPRID = " | &oCcCardRole.OPRID);
&oCcCardRole.OPRID = &REC2.OPRID.Value;
rem &fileLog.WriteLine("&oCcCardRole.CC_USE_ON_REQ = " | &oCcCardRole.CC_USE_ON_REQ);
rem &oCcCardRole.CC_USE_ON_REQ = [*];
rem &fileLog.WriteLine("&oCcCardRole.CC_USE_ON_PO = " | &oCcCardRole.CC_USE_ON_PO);
rem &oCcCardRole.CC_USE_ON_PO = [*];
rem &fileLog.WriteLine("&oCcCardRole.ROLENAME = " | &oCcCardRole.ROLENAME);
&oCcCardRole.ROLENAME = &REC2.ROLENAME.Value;

rem ***** Set CC_VNDR_CARD_VW Collection Field Properties -- Parent: CC_CARD_DATA_EX Collection *****;
REM &oCcVndrCardVwCollection = &oCcCardDataEx.CC_VNDR_CARD_VW;
REM Local integer &i2108;
REM For &i2108 = 1 To &oCcVndrCardVwCollection.Count;
REM &oCcVndrCardVw = &oCcVndrCardVwCollection.Item(&i2108);
rem &fileLog.WriteLine("&oCcVndrCardVw.VENDOR_SETID = " | &oCcVndrCardVw.VENDOR_SETID);
rem &oCcVndrCardVw.VENDOR_SETID = [*];
rem &fileLog.WriteLine("&oCcVndrCardVw.VENDOR_ID = " | &oCcVndrCardVw.VENDOR_ID);
rem &oCcVndrCardVw.VENDOR_ID = [*];
rem &fileLog.WriteLine("&oCcVndrCardVw.VNDR_LOC = " | &oCcVndrCardVw.VNDR_LOC);
rem &oCcVndrCardVw.VNDR_LOC = [*];
rem &fileLog.WriteLine("&oCcVndrCardVw.CC_DISP_OPTION = " | &oCcVndrCardVw.CC_DISP_OPTION);
rem &oCcVndrCardVw.CC_DISP_OPTION = [*];
rem &fileLog.WriteLine("&oCcVndrCardVw.CC_ALLOW_OVERRIDE = " | &oCcVndrCardVw.CC_ALLOW_OVERRIDE);
rem &oCcVndrCardVw.CC_ALLOW_OVERRIDE = [*];
rem &fileLog.WriteLine("&oCcVndrCardVw.CC_USE_FLAG = " | &oCcVndrCardVw.CC_USE_FLAG);
rem &oCcVndrCardVw.CC_USE_FLAG = [*];
&RoleCounter = &RoleCounter + 1;
rem End-For;
End-While;
End-For;

rem ***** End: Get/Set Component Interface Properties *****;

rem ***** Execute Save *****;
If Not &oKsCcEeProfile.Save() Then;
errorHandler();
throw CreateException(0, 0, "Save failed");
End-If;

rem ***** Execute Cancel *****;
rem If Not &oKsCcEeProfile.Cancel() Then;
rem errorHandler();
rem throw CreateException(0, 0, "Cancel failed");
rem End-If;

If Not &SQL.IsOpen Then
&SQL = CreateSQL("%selectall(:1) where EMPLID > :2 ORDER BY EMPLID", Record.KS_CC_CARD_LOAD, &REC.EMPLID.Value);
End-If;

End-While;

catch Exception &ex
rem Handle the exception;
rem &fileLog.WriteLine(&ex.ToString());
end-try;
rem &fileLog.WriteLine("End");
rem &fileLog.Close();