Wednesday, 23 December 2020

Generate BI Report from a page using People code

 import PSXP_RPTDEFNMANAGER:*;


&LanguageCd = "ENG";

&AsOfDate = %Date;

&OutFormat = "PDF";

&MyReportName = "ENRL_VERIFY";

&MyTemplate = "ENRL_VERIFY";


Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&MyReportName);


&oReportDefn.Get();

Local Record &rcdQryPrompts, &RC1;


&rcdQryPrompts = &oReportDefn.GetPSQueryPromptRecord();

If Not &rcdQryPrompts = Null Then

   

   &oReportDefn.SetPSQueryPromptRecord(&rcdQryPrompts);

   &rcdQryPrompts.EMPLID.Value = X_VERIFY_WRK.EMPLID.Value;

   &rcdQryPrompts.INSTITUTION.Value = X_VERIFY_WRK.INSTITUTION.Value;

   

   

   &rcdQryPrompts.ACAD_CAREER.Value = X_VERIFY_WRK.ACAD_CAREER.Value;

   

   &rcdQryPrompts.STRM.Value = X_VERIFY_WRK.STRM.Value;

   

   

   

   

End-If;



SQLExec("select TMPLDEFN_ID from PSXPRPTTMPL_VW where REPORT_DEFN_ID =:1 and LANGUAGE_CD =:2", &oReportDefn, &LanguageCd, &TemplateID);




&oReportDefn.ProcessReport(&TemplateID, &LanguageCd, &AsOfDate, &OutFormat);

CommitWork();

If All(X_VERIFY_WRK.STRM.Value) Then

   

   &oReportDefn.DisplayOutput();

Else

   Error MessageBox(0, "", 0, 0, "Please select a term from the list ");

End-If;


Sunday, 10 March 2019

Peoplecode to check if field contains spaces or punctuation


If All(PTSF_SRCH_ENGN.PTSF_SRCH_ENG_INS.Value) Then
   &Name = PTSF_SRCH_ENGN.PTSF_SRCH_ENG_INS.Value;
   &I = 1;
   If IsAlphaNumeric(&Name) = False Then
      While &I <= Len(&Name)
         /* Test to see if failure is because of _ or - or not*/
         &testchar = Substring(&Name, &I, 1);
         If (IsAlphaNumeric(&testchar) = True) Or
               (&testchar = "_") Or
               (&testchar = "-") Then;
            &I = &I + 1;
         Else
            Error (MsgGetText(78, 33, "no spaces or punctuation are allowed"));
            &I = Len(&Name);
            Break;
         End-If;
      End-While;
   Else
      /* test for number in first position*/
      &testnumberpos1 = Substring(&Name, 1, 1);
      If IsDigits(&testnumberpos1) = True Then
         Error (MsgGetText(78, 33, "no spaces or punctuation are allowed"));
         &I = Len(&Name);
      End-If;
   End-If;
End-If;

Tuesday, 12 February 2019

Flush data from Component Buffer in a Grid




In my case , I am flushing the grid data on field change of Qualification field

Local Rowset &Xlat;

/* --- Flush Elective Grid on Qualification Field Change --- */

&Xlat = GetRowset(Scroll.X_ELECTIVE_INFO);


&Xlat.Flush();



Monday, 13 March 2017

Read CSV file in Peoplecode

Local File &MYFILE;
Local Record &REC;
Local array of string &ARRAY;
Local string &FilePath, &FileName;

Local Rowset &GRD_RS;

&GRD_RS = GetLevel0()(1).GetRowset(Scroll.IOBM_PHN_NO_WRK);
&GRD_RS.Flush();
SQLExec("Delete  from PS_IOBM_PHN_NO_WRK ");
SQLExec("commit");

&FILE = IOBM_SMSATT_WRK.ATTACHUSERFILE.Value;

&URL = GetURL(URL.IOBM_FINANCE_UPLOAD);

&MYFILE = GetFile(&URL | &FILE, "r", "a", %FilePath_Absolute);


&REC = CreateRecord(Record.IOBM_PHN_NO_WRK);
&ARRAY = CreateArrayRept("", 0);


If &MYFILE.IsOpen Then
 
   While &MYFILE.ReadLine(&STRING);
     
      &ARRAY = Split(&STRING, ",");
      &REC.EMPLID.Value = &ARRAY [1];
      SQLExec("select Distinct phone  from PS_PERSON_PHONE where Emplid = :1 ", &ARRAY [1], &PHONE);
      &REC.PHONE.Value = &PHONE;
      &REC.Insert();
      rem  MessageBox(0, "", 0, 0, "" | &REC.EMPLID.Value | "" | &REC.PHONE.Value);
     
   End-While;
End-If;
GetLevel0().Refresh()

Tuesday, 3 January 2017

Get Day name in peoplesoft



Local string &Get_DT  =    (IOBM_ATTEND_WRK.DT_ARRIVE.Value);


rem &GRD_SQL2 = SQLExec("select to_char(sysdate, 'DY') FROM DUAL ", &getday);

&GRD_SQL2 = SQLExec("select to_char(to_date(:1,'yyyy/mm/dd'), 'DY') FROM DUAL ", &Get_DT, &getday);

Evaluate &getday

When "THU"
   IOBM_ATTEND_WRK.THURS.Value = "Y";

   When "FRI"
   IOBM_ATTEND_WRK.FRI.Value = "Y";
    
When "SAT"
   IOBM_ATTEND_WRK.SAT.Value = "Y";

  When "SUN"
   IOBM_ATTEND_WRK.SUN.Value = "Y";

  When "MON"
   IOBM_ATTEND_WRK.MON.Value = "Y";

  When "TUE"
   IOBM_ATTEND_WRK.TUES.Value = "Y";

  When "WED"
   IOBM_ATTEND_WRK.WED.Value = "Y";

End-Evaluate;

Friday, 9 December 2016

SQLExec

Sqlexec  Update

  SQLExec("Update PS_SF_ACCTG_LN set GL_DISTRIB_STATUS = 'Y', PROCESS_INSTANCE = :4 where RUN_DT = :1 and SEQNUM = :2 and SF_LINE_NBR = :3", &REC.RUN_DT.Value, &REC.SEQNUM.Value, &REC.SF_LINE_NBR.Value, &Process_instance);


----------------------------------------------------------------------------------------------------------

Comma Seprated String in Poeplecode

&UserRoles = CreateArray("");
Local array of string &roles = %Roles;
Local string &rolesStr = "";
If &roles.Len >= 1 Then
   &rolesStr = "'" | &UserRoles [1] | "'";
End-If;

For &i = 2 To &roles.Len
   &rolesStr = &rolesStr | ", ";
   &UserRoles [&i] = &roles [&i];
   &rolesStr = &rolesStr | "'" | &UserRoles [&i] | "'";
End-For;





If %Language = %Language_Base Then
  
  
   FORM_ADD_VW.FORM_TYPE.SqlText = "SELECT A.FORM_TYPE, A.PORTAL_LABEL FROM PS_KS_FORM_TYPE_VW A  WHERE A.ROLEUSER IN (" | &rolesStr | ") AND A.FORM_TYPE_STATUS ='A' AND A.PORTAL_NAME='" | %Portal | "' AND A.EFFDT_FROM <= %CurrentDateIn AND (A.EFFDT_TO is null or A.EFFDT_TO >= %CurrentDateIn)";
  
  
Else
  
   FORM_ADD_VW.FORM_TYPE.SqlText = "SELECT A.FORM_TYPE, B.PORTAL_LABEL FROM PS_KS_FORM_TYPE_VW A , PS_FORM_TYPE_LG B WHERE A.ROLEUSER IN (" | &rolesStr | ") AND  A.FORM_TYPE_STATUS ='A' AND A.PORTAL_NAME='" | %Portal | "' AND A.EFFDT_FROM <= %CurrentDateIn AND (A.EFFDT_TO is null or A.EFFDT_TO >= %CurrentDateIn) AND A.FORM_TYPE=B.FORM_TYPE AND B.LANGUAGE_CD='" | %Language | "'";
  
  
End-If;