Component Interface
Every Component Interface will have 4 attributes
Name of the component: Each Component Interface will have a unique name . It will be given at the time of the creation of the component interface
Keys : Keys will be created basing on the search record definition of the component
Properties: Properties gives access to component data and settings . There are 2 types properties
Methods: A method is like a function that can perform a specific task according to requirement .There are 2 types of methods
5. Use Save() method , So the instance of the data will be saved to database
In order to Get a new set of data the code can be modified in the following way
3) Set the GET Keys
5) Set the values for the rest
of the fields and execute Save() Method to successfully get the new instance of
the data from DB
- Component Interface is an Integration Tool ,
- Its like a wrapper around the component .
- It exposes PeopleSoft component (Combination of pages) for the synchronous access from other applications
- One component can have multiple interfaces , But one CI maps to only one component
Every Component Interface will have 4 attributes
- Name of the component
- Keys
- Properties
- Methods
Name of the component: Each Component Interface will have a unique name . It will be given at the time of the creation of the component interface
Keys : Keys will be created basing on the search record definition of the component
Create Keys
|
These keys will be formed based on the ADD mode of the component . Search key in the search record will come under this
|
Get Keys
|
Search key for the search record will form this keys
|
Find Keys
|
Both the search key & alternate search keys will form this
|
Standard Properties
|
These properties can be set to true or false .These cannot be displayed in Application Designer they are
Interactive Mode
Get History Items
Edit History Items
|
User-defined Properties
|
User -defined properties will relates to record fields of the underlying component
Fields - Properties
Scroll data - Collections
|
Behavior of the CI by the property setting
EditHistoryItems=False
GetHistoryItems=True
|
It is same as the accessing
the component in the Update/Display Allwhere we can see the past
information but cannot edit the data
|
EditHistoryItems=True
GetHistoryItems=True
|
It is same as the accessing
the component in the Correction Mode
|
GetHistoryItems=False
|
It equivalents with Update Modehere
there is no value to EditHistoryItems
when GetHistoryItems is false
|
Interactive Mode
|
False makes to skip firing
of the individual properties (fields) code .
True means Code will get
fire for the FieldChange event of the properties.
|
Standard Methods
|
These are common for all the Interfaces
Find
Get
Create
Cancel
Save
|
User defined Methods
|
These are further created by user on his requirement
|
Implementing a Component Interface
In general we use
Component Interfaces to perform the following actions
> Create a new Instance
of data
> Get existing Instance of
data
> Retrieve a list of
instances of data
Creating new instance of data:
1. Get a session object
2. Get a Component Interface
3. Set the Create keys
4. Use the Create() method to
create an instance of the data2. Get a Component Interface
3. Set the Create keys
5. Use Save() method , So the instance of the data will be saved to database
Consider
the example where CI looks like in the following way
When you place it in the PeopleCode action in the AE, Pseudo will be generated automatically. It looks like in the following way |
/*
===>
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, &oSampleCi;
Local
ApiObject&oSampleci1Collection, &oSampleci1;
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.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 *****;
&oSampleCi = &oSession.GetCompIntfc(CompIntfc.SAMPLE_CI);
If &oSampleCi = Null Then
errorHandler();
throw CreateException(0, 0, "GetCompIntfc
failed");
End-If;
rem ***** Set the Component
Interface Mode *****;
&oSampleCi.InteractiveMode =
False;
&oSampleCi.GetHistoryItems =
True;
&oSampleCi.EditHistoryItems =
False;
rem ***** Set Component Interface
Get/Create Keys *****;
&oSampleCi.EMPLID = [*];
rem ***** Execute Get *****;
If Not &oSampleCi.Get() Then
rem ***** No rows exist
for the specified keys.*****;
errorHandler();
throw CreateException(0,
0, "Get failed");
End-If;
rem ***** Execute Create ******;
rem If Not &oSampleCi.Create()
Then;
rem ***** Unable to Create Component
Interface for the Add keys provided. *****;
rem errorHandler();
rem throw
CreateException(0, 0, "Create failed");
rem End-If;
rem ***** Begin: Get/Set Component
Interface Properties *****;
rem ***** Get/Set Level 0 Field
Properties *****;
&fileLog.WriteLine("&oSampleCi.EMPLID
= " | &oSampleCi.EMPLID);
rem
&oSampleCi.EMPLID = [*];
&fileLog.WriteLine("&oSampleCi.MOBILE_PHONE=
" | &oSampleCi.MOBILE_PHONE);
rem&oSampleCi.MOBILE_PHONE =
[*];
&fileLog.WriteLine("&oSampleCi.NAME
= " | &oSampleCi.NAME);
rem &oSampleCi.NAME = [*];
&fileLog.WriteLine("&oSampleCi.SEX
= " | &oSampleCi.SEX);
rem &oSampleCi.SEX = [*];
rem
***** Set/Get SAMPLECI_1 Collection Field Properties -- Parent: PS_ROOT
Collection *****;
&oSampleci1Collection =
&oSampleCi.SAMPLECI_1;
Local integer &i17;
For &i17 = 1 To
&oSampleci1Collection.Count;
&oSampleci1 = &oSampleci1Collection.Item(&i17);
&fileLog.WriteLine("&oSampleci1.DEPTID
= " | &oSampleci1.DEPTID);
rem &oSampleci1.DEPTID = [*];
&fileLog.WriteLine("&oSampleci1.DEPTNAME
= " | &oSampleci1.DEPTNAME);
rem &oSampleci1.DEPTNAME = [*];
End-For;
rem ***** End: Get/Set Component
Interface Properties *****;
rem ***** Execute Save *****;
rem If Not &oSampleCi.Save()
Then;
rem errorHandler();
rem throw
CreateException(0, 0, "Save failed");
rem End-If;
rem ***** Execute Cancel *****;
rem If Not &oSampleCi.Cancel()
Then;
rem 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");
|
In
order to create new set of data the code can be
modified in the following way
1) Get a session object
Session has to declared with a data type (i.e. API Type)
& Need to get current PeopleSoft Session .From the above coding it is
Local ApiObject&oSession,
&oSampleCi;
rem ***** Get current
PeopleSoft Session *****;
&oSession = %Session;
|
2) Get a Component Interface
Use the GetCompIntfc method with a session object to get the
Component Interface.
Make sure that you are inputting valid CI name or else you
will receive an error
rem ***** Get the Component Interface *****;
&oSampleCi
= &oSession.GetCompIntfc(CompIntfc.SAMPLE_CI);
If
&oSampleCi = Null Then
errorHandler();
throw
CreateException(0, 0, "GetCompIntfc failed");
End-If;
|
At this point you have the
structure of the Component Interface it is not yet populated with any data
3) Set the Create Keys
These values will make a new instance of data that has to be
populated into db
Make sure you are inputting unique key values
rem ***** Set Component Interface
Get/Create Keys *****;
&oSampleCi.EMPLID = “2344”;
|
4) Use the Create() method to
instantiate the data
Need to remove [rem] to the Create method
Add [rem] to Get () method as we are not getting any
instances of the data from db
I.e. it looks like
rem ***** Execute Get
*****;
rem If Not &oSampleCi.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
&oSampleCi.Create() Then;
rem ***** Unable to Create
Component Interface for the Add keys provided. *****;
errorHandler();
throw
CreateException(0, 0, "Create failed");
End-If;
|
This successfully creates the new instance of the data , It’s
not yet saved into DB
5) Set the values for the
rest of the fields and execute Save() Method to successfully save the new
instance of the data into DB
Remove [rem] from all the individual fields and assign the
value
Remove [rem] for the Save () method
rem ***** Begin: Get/Set Component Interface
Properties *****;
rem *****
Get/Set Level 0 Field Properties *****;
&fileLog.WriteLine("&oSampleCi.EMPLID =
" | "2234");
&oSampleCi.EMPLID = "2234";
&fileLog.WriteLine("&oSampleCi.MOBILE_PHONE
= " | "9985");
&oSampleCi.MOBILE_PHONE = "9985";
&fileLog.WriteLine("&oSampleCi.NAME =
" | "Varma,penumatsa");
&oSampleCi.NAME = "Varma,penumatsa";
&fileLog.WriteLine("&oSampleCi.SEX =
" | "M");
&oSampleCi.SEX = "M";
rem ***** Set/Get SAMPLECI_1
Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oSampleci1Collection = &oSampleCi.SAMPLECI_1;
Local
integer &i17;
For
&i17 = 1 To &oSampleci1Collection.Count;
&oSampleci1 =
&oSampleci1Collection.Item(&i17);
&fileLog.WriteLine("&oSampleci1.DEPTID
= " | "110");
&oSampleci1.DEPTID = "110";
&fileLog.WriteLine("&oSampleci1.DEPTNAME
= " | "Finance");
&oSampleci1.DEPTNAME = "Finance";
End-For;
rem *****
End: Get/Set Component Interface Properties *****;
rem *****
Execute Save *****;
If Not
&oSampleCi.Save() Then;
errorHandler();
throw
CreateException(0, 0, "Save failed");
End-If;
|
After running this, automatically new set of data will be
uploaded into db.
Get an existing Instance of
data
In order to Get a new set of data the code can be modified in the following way
1) Get a session object
Session has to declared with a data type (i.e. API Type)
& Need to get current PeopleSoft Session .From the above coding it is
Local
ApiObject&oSession, &oSampleCi;
rem
***** Get current PeopleSoft Session *****;
&oSession = %Session; |
2) Get a Component Interface
Use the GetCompIntfc method with a session object to get the
Component Interface.
Make sure that you are inputting valid CI name or else you
will receive an error
rem ***** Get the Component Interface *****;
&oSampleCi
= &oSession.GetCompIntfc(CompIntfc.SAMPLE_CI);
If
&oSampleCi = Null Then
errorHandler();
throw
CreateException(0, 0, "GetCompIntfc failed");
End-If;
|
At this point you have the
structure of the Component Interface it is not yet populated with any data
3) Set the GET Keys
These values will make a new instance of data that has to be
populated into db
Make sure you are inputting unique key values
rem ***** Set Component
Interface Get/Create Keys *****;
&oSampleCi.EMPLID =
"2234";
|
4) Use the GET() method to
instantiate the data
I.e. it looks like
rem ***** Execute Get *****;
If Not
&oSampleCi.Get() Then
rem ***** No rows exist for the specified keys.*****;
errorHandler();
throw
CreateException(0, 0, "Get failed");
End-If;
rem ***** Execute
Create ******;
rem If Not &oSampleCi.Create() Then;
rem
***** Unable to Create Component Interface for the Add keys provided. *****;
rem errorHandler();
rem throw CreateException(0, 0, "Create
failed");
rem End-If; |
Remove [rem] from all the individual fields and assign the
value
Remove [rem] for the Save () method
rem ***** Begin: Get/Set Component Interface Properties
*****;
rem ***** Get/Set
Level 0 Field Properties *****;
&fileLog.WriteLine("&oSampleCi.EMPLID
= " | &oSampleCi.EMPLID);
&oSampleCi.EMPLID = &oSampleCi.EMPLID;
&fileLog.WriteLine("&oSampleCi.MOBILE_PHONE
= "&oSampleCi.MOBILE_PHONE);
&oSampleCi.MOBILE_PHONE = &oSampleCi.MOBILE_PHONE;
&fileLog.WriteLine("&oSampleCi.NAME
= " | &oSampleCi.NAME);
&oSampleCi.NAME = &oSampleCi.NAME;
&fileLog.WriteLine("&oSampleCi.SEX
= " | &oSampleCi.SEX);
&oSampleCi.SEX = &oSampleCi.SEX;
rem ***** Set/Get
SAMPLECI_1 Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oSampleci1Collection = &oSampleCi.SAMPLECI_1;
Local integer
&i17;
For &i17 = 1 To
&oSampleci1Collection.Count;
&oSampleci1 = &oSampleci1Collection.Item(&i17);
&fileLog.WriteLine("&oSampleci1.DEPTID
= " | &oSampleci1.DEPTID);
&oSampleci1.DEPTID = &oSampleci1.DEPTID;
&oSampleci1.DEPTNAME = &oSampleci1.DEPTNAME;
End-For;
rem ***** End:
Get/Set Component Interface Properties *****;
rem ***** Execute
Save *****;
If Not
&oSampleCi.Save() Then;
errorHandler();
throw
CreateException(0, 0, "Save failed");
End-If; |
which method is used if keys are partially known?keys are completely known?
ReplyDeleteCan you elaborate your question ..? When you drag and drop CI automatically you will get exposure to the keys ..! Isn't it ?
ReplyDeleteThanks for sharing your knowledge. It helped me understand some concepts which I didn't know before.
ReplyDeleteHow to generate the pseudo code in AE.
ReplyDelete