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.

CI IN ADD AND UPDATE MODE-->mess

4 replies [Last post]
PARITOSH's picture
User offline. Last seen 9 years 31 weeks ago. Offline
Joined: 06/16/2010
Posts: 19

Help me out....
I am able to insert new rows....
But unable to update the existing ones......
-----------------------------------------
CODE
---------------------------------------
Local File &fileLog;
Local ApiObject &oSession, &oCiPb2;

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\CI_PB2.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 = 2;

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

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

rem ***** Set Component Interface Get/Create Keys *****;
&oCiPb2.FIRSTNAME_PB3 = STATE_PB_AET.NAME_PB_STG;

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

rem ***** Execute Create ******;
If Not &oCiPb2.Get() Then
If Not &oCiPb2.Create() Then;
rem ***** Unable to Create Component Interface for the Add keys provided. *****;
errorHandler();
throw CreateException(0, 0, "Create failed");
End-If;
End-If;

rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;
&fileLog.WriteLine("&oCiPb2.FIRSTNAME_PB3 = " | &oCiPb2.FIRSTNAME_PB3);
rem &oCiPb2.FIRSTNAME_PB3 = STATE_PB_AET.NAME_PB_STG;
&fileLog.WriteLine("&oCiPb2.SALARY_PB3 = " | &oCiPb2.SALARY_PB3);
rem &oCiPb2.SALARY_PB3 = STATE_PB_AET.SAL_PB_STATE;
rem ***** End: Get/Set Component Interface Properties *****;

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

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

catch Exception &ex
rem Handle the exception;
&fileLog.WriteLine(&ex.ToString());
end-try;
&fileLog.WriteLine("End");
&fileLog.Close();
------------------------------------------------
STAGING RECORD-->STATE RECORD
STATE RECORD-->MAIN RECORD
USING FILE LAOUT ,DO SELECT AND CI
----------------------------------------------

pavan sri harsha's picture
pavan sri harsha (not verified)
Re: CI IN ADD AND UPDATE MODE-->mess

HI,

I need details about your requirement and what you are trying to do.
Then i can help you on this.

PARITOSH's picture
User offline. Last seen 9 years 31 weeks ago. Offline
Joined: 06/16/2010
Posts: 19
Re: CI IN ADD AND UPDATE MODE-->mess

(1) first i had inserted data in staging record through file laout code(draggeded filelaout in app eng step 1) wich contain csv file.
(2) I had put staging data in state record through do select app eng prog(step 2--action1)
(3)through deliverd ci code i had put data in main record from state record...
Now the issue is that though New data get inserted properly with all validations,but if i am traying to update data fro existing row its nt working...
:( help me out...

pavan sri harsha's picture
pavan sri harsha (not verified)
Re: CI IN ADD AND UPDATE MODE-->mess

Hi,

What error you are getting.

please provide me the error.

Regards,
Pavan sri harsha

pavan sri harsha's picture
pavan sri harsha (not verified)
Re: CI IN ADD AND UPDATE MODE-->mess

Hi,

Try to use below logic it will work...

Function function name (&Att, &Desc, &fileLog_att) Returns boolean
-------------------------------------------------------
rem ***** Execute Get *****;
If Not &oCfAttributesCi.Get() Then
rem ***** No rows exist for the specified keys.*****;
errorHandler();
throw CreateException(0, 0, "Get failed");

rem ***** Execute Create ******;
If Not &oCfAttributesCi.Create() Then;
rem ***** Unable to Create Component Interface for the Add keys provided. *****;
errorHandler();
throw CreateException(0, 0, "Create failed");

Else
&fileLog.WriteLine(" Value not found, Creating the New value " | &Att);

rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;
&oAttributesCi.MULTIPLE_FLG = "N";

rem ***** Set/Get CF_ATTRIB_VALUE Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oCfAttribValueCollection = &CfAttributesCi.CF_ATTRIB_VALUE;
Local integer &i114;
&oCfAttribValue = &oCfAttribValueCollection.INSERTItem(1);
&Desc1 = String(&Desc);
&oCfAttribValue.CF_ATTRIB_VALUE_1 = &Desc1;

&oCfAttribValue.DESCR60 = &Desc;

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

rem ***** Execute Save *****;
If Not &oCfAttributesCi.Save() Then;
errorHandler();
throw CreateException(0, 0, "Save failed");
Else
&ret = True;
SQLExec("commit");
&fileLog.WriteLine("Status : Save Success");
End-If;

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

Else
&fileLog_att.WriteLine("Attribute Value found, Updating the value " | &Att);
rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;
&oCfAttributesCi.MULTIPLE_FLG = "Y";

rem ***** Set/Get CF_ATTRIB_VALUE Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oCfAttribValueCollection = &oCfAttributesCi.CF_ATTRIB_VALUE;
Local integer &i113;
rem For &i113 = 1 To &oCfAttribValueCollection.Count;
&oCfAttribValue = &oCfAttribValueCollection.INSERTItem(1);
&oCfAttribValue.CF_ATTRIB_VALUE_1 = &Desc;

&oCfAttribValue.DESCR60 = &Desc;

rem End-For;

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

rem ***** Execute Save *****;
If Not &oCfAttributesCi.Save() Then;
errorHandler();
throw CreateException(0, 0, "Save failed");
Else
&ret = True;
SQLExec("commit");
&fileLog_att.WriteLine("Status : Save Success");
End-If;

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

catch Exception &ex
rem Handle the exception;
&fileLog_att.WriteLine(&ex.ToString());
&ret = False;
end-try;