How to Run PS Query Report in Application Engine PeopleCode

How to Run PS Query Report in Application Engine PeopleCode

Local ApiObject &aRunQry;

&PSQry = %Session.GetQuery();

&qryName = “PS Query Name”;

/* State Record is Prompt field in PS Query*/
&process_instance = PT_TEST_AET.PROCESS_INSTANCE;

If (&PSQry.Open(&qryName, True, True) <> 0) Then

     &fileLogLM.WriteLine(“Cannot Open the Query”);

Else
     &aQryPromptRec = &PSQry.PromptRecord;
     &aQryPromptRec.PROCESS_INSTANCE.Value = &process_instance;
     &Date_Format = DateTimeToLocalizedString(%Date, “dd-MMM-yyyy”);

     /* Output File */
    &strFile = “FILE_” | &process_instance;

     /* Use the RunToFile method to execute the Query and return the result to the file specified with Destination.*/
      &outStrFile = %FilePath | &strFile;
       MessageBox(0, “”, 0, 0, “Query Out File : ” | &outStrFile);

      If (&PSQry.RunToFile(&aQryPromptRec, &outStrFile, %Query_XLS, 0) = 0) Then

         MessageBox(0, “”, 0, 0, “ResultSet saved into file successfully.”);
     Else
          MessageBox(0, “”, 0, 0, “Failed to save Resultset into file.”);
      End-If;
End-If;

How to Hide/Unhide Scroll and Grid, Allrow in Peoplecode

How to Hide/Unhide Scroll, Allrow in Peoplecode

On Page Activity in Peoplecode

Example 1

Local Rowset &rs1, &rs2;

&rs1 = GetRowset();
&rs2 = GetRowset(SCROLL.TS_INFO_FILE);

For &I = 1 to &rs1.ActiveRowCount
     If ALL(&rs1.GetRow(&I).TS_INFO_FILE.FIELD1 ) Then
    &rs2.HideAllRows();
    End-If;
End-For;

Example 2

hideScroll(Scroll.TS_INFO_FILE); 

unhideScroll(Scroll.TS_INFO_FILE); 

         hideScroll(RECORD.TS_INFO_FILE); 

        unhideScroll(RECORD.TS_INFO_FILE); 

Example 3 Hide/ Unhide some field on grid/ scroll area 

Local Rowset &rs1, &rs2;

&rs1 = GetRowset(); 
&rs2 = GetRowset(SCROLL.TS_INFO_FILE);

For &I = 1 to &rs1.ActiveRowCount 
     If ALL(&rs1.GetRow(&I).TS_INFO_FILE.FIELD1 ) Then 

         &rs2 (&i).TS_INFO_FILE.FIELD1.Visible = False;

         &rs2 (&i).TS_INFO_FILE.FIELD2.Visible = False;
    End-If; 
End-For;

How to Sort Scroll Area / Grid Column by Peoplecode Of PeopleSoft

How to Sort Scroll Area / Grid Column Level 1by Peoplecode Of PeopleSoft

Example 1

ScrollFlush(Record.TS_INFO_FILE);
ScrollSelect(1, Record.TS_INFO_FILE, Record.TS_INFO_FILE, “Where emplid = :1 and YEAR = :2 ORDER BY decode(TS_FILE_TYPE, ‘NID’, 1, ‘ADD’, 2, ‘LIC’, 3 )”, %EmployeeId, &YEAR);

Example 2

&rs= GetLevel0()(1).GetRowset(Scroll.TS_INFO_FILE); 
&rs.Sort(TS_INFO_FILE.FIELD1, “A”, TS_INFO_FILE.FIELD2, “D”, TS_INFO_FILE.FIELD3, “A”);

Example 3

ScrollFlush(Record.TS_INFO_FILE);
ScrollSelect(1, Record.TS_INFO_FILE, Record.TS_INFO_FILE, “Where emplid = :1 and YEAR = :2 “, %EmployeeId, &YEAR);
sortscroll(1, Record.TS_INFO_FILE,TS_INFO_FILE.FIELD1, “A”, TS_INFO_FILE.FIELD2, “D”);

Example 4

ScrollFlush(Record.TS_INFO_FILE);
ScrollSelect(1, Record.TS_INFO_FILE, Record.TS_INFO_FILE, “Where emplid = :1 and TS_YEAR_MM = :2 ORDER BY decode(TS_FILE_TYPE, ‘NID’, 1, ‘ADD’, 2, ‘HOME’, 3 )”, %EmployeeId, &TS_YEAR_MM);

How to Use Current Rent Row Number of Field In PeopleCode Scroll Level1

How to Use Current Rent Row Number of Field In PeopleCode

Local Rowset &rs0, &rs1;

&index = CurrentRowNumber();
&rs0 = GetLevel0();
&rs1 = &rs0.GetRow(1).GetRowset(Scroll.COURSE);

/* Define Field Value of  CurrentRowNumber on Scroll Level 1*/

&rs1(&index).DERIVED_CRSE.SESSION.Value = &rs1(&idx).COURSE.SESSION.Value;

/* Loop For Define Filed Value on Scroll Level 1*/
For &i = 1 To &rs1.ActiveRowCount

   &rs1(&i).DERIVED_CRSE.SESSION.Value = &rs1(&idx).COURSE.SESSION.Value;

End-For;

How to Arrange/ Sort/ Filter/ Change Translate Value or Prompt Table

How to Arrange/ Sort/ Filter/ Change Translate Value or Prompt Table

Local Rowset &Xlat;
&Xlat = CreateRowset(Record.PSXLATITEMLANG);
&Xlat.Flush();

/*– Decode Value and Sort of Translate Value–*/
rem &Xlat.Fill(“Where fieldname = ‘Field Name’ order by decode(Fieldvalue,’Jan’,1,0),fieldvalue”);

/*– Filter Value and Change Long Name of Translate Value –*/

&Xlat.Fill(“Where fieldname = ‘WO_WO_TYPE’ AND FIELDVALUE NOT IN ( ‘0’,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’10’,’12’) ORDER BY decode(XLATLONGNAME,’Income’,0,’Value Creation’,’2′ ,’Benchmarking’,’3′ ,’Risk Management’,3 ,’KPI Main’,3,1)”);
WO_TBL.WO_WO_TYPE.ClearDropDownList();
&j = &Xlat.ActiveRowCount + 1;
For &i = 1 To &Xlat.ActiveRowCount
       &Value = &Xlat.GetRow(&i).PSXLATITEMLANG.FIELDVALUE.Value;
      &descr = &Xlat.GetRow(&i).PSXLATITEMLANG.XLATLONGNAME.Value;
      rem DERIVED_WO.WO_WO_TYPE.AddDropDownItem(&Value, &Descr);
     If &Value = “11” Then
           &descr = “Value Creation Special”;
     End-If;
       WO_TBL.WO_WO_TYPE.AddDropDownItem(&Value, Rept(Char(9), &j – &i) | &descr);
End-For;