This post is to explain the usage of multi-dimensional array in PeopleSoft.
To explain it, I’m taking an example to display the field label text for all the dropdown fields on a page.
Create a SQL object NS_DROPDOWN_FLD_LBL , with the following SQL statement:
Select FieldType, FieldName, LblText
From PSPNLFIELD
Where PNLNAME=:1 And RECNAME =:2 And LABEL_ID<>' '
Now write this PeopleCode at appropriate place:
Local number &n_FldType, &n_element;
Local string &s_FieldName, &s_FldLabel, &b_state;
/*Declare & initiate array*/
Local array of array of string &a_FieldList;
/*Array with 3 elements*/
&a_FieldList = CreateArrayRept(CreateArrayRept(" ", 0), 3);
/*Fetch fields for record JOB on JOB_DATA1 page*/
&sql = GetSQL(SQL.NS_DROPDOWN_FLD_LBL, “JOB_DATA1”, “JOB” );
&a_FieldList.Len = 0;
&n_element=1;
While &sql.Fetch(&n_FldType, &s_FieldName, &s_FldLabel)
If &n_FldType = 5 Then
&b_state = "Y";
Else
&b_state = "N";
End-If;
&a_FieldList.Push(&s_FieldName);
&a_FieldList [&n_element, 2] = &b_state;
&a_FieldList [&n_element, 3] = &s_FldLabel;
&n_element = &n_element + 1;
End-While;
/* Getting values out of the array */
/* This would display messagebox for all the fields which are dropdown. */
For &i = 1 To &a_FieldList.Len
If &a_FieldList [&i][2] = "Y" Then
MessageBox(0, "", 0, 0, " FieldName:- " | String(&a_FieldList [&i][1]) | " FieldLabel:- " | String(&a_FieldList [&i][3]));
End-If;
End-For;
|
super...........
ReplyDelete