Wednesday 23 December 2020

Populate Dynamic Drop down using peoplecode

 

&FLD = GetRecord(Record.X_VERIFY_WRK).GetField(Field.STRM);

&FLD.ClearDropDownList();



&SQL = CreateSQL("select distinct  a.strm , b.descr  from  PS_STDNT_enrl a, ps_term_tbl b where a.strm=b.strm  and a.emplid =:1", %EmployeeId);

While &SQL.Fetch(&strm, &descr)

   &FLD.AddDropDownItem(&strm, &descr);

   /* Adding each row from the SQL's output to the drop downĂ‚  */

End-While;

Build your where clause based on the Level 0 Work record fields

 &id = X_TSCRPT_WRK.EMPLID.Value;

&rqst_id = X_TSCRPT_WRK.REPORT_REQUEST_NBR.Value;

rem &sbdt = X_TSCRPT_WRK.SUBMITTED_DT.Value;

&nid = X_TSCRPT_WRK.NATIONAL_ID.Value;

&status = X_TSCRPT_WRK.X_DELIVERY_STATUS.Value;


&WHERE_CLAUSE = " ";

ScrollFlush(Record.X_TRANS_REQ_VW);

If All(&id) Then

   

   &WHERE_CLAUSE = &WHERE_CLAUSE | " EMPLID = '" | &id | "'";

End-If;

If All(&rqst_id) Then

   If All(&WHERE_CLAUSE) Then

      &WHERE_CLAUSE = &WHERE_CLAUSE | " AND " | "REPORT_REQUEST_NBR = '" | &rqst_id | "'";

   Else

      &WHERE_CLAUSE = &WHERE_CLAUSE | " REPORT_REQUEST_NBR = '" | &rqst_id | "'";

   End-If;

End-If;



If All(&nid) Then

   If All(&WHERE_CLAUSE) Then

      &WHERE_CLAUSE = &WHERE_CLAUSE | " AND " | "NATIONAL_ID = '" | &nid | "'";

   Else

      &WHERE_CLAUSE = &WHERE_CLAUSE | " NATIONAL_ID = '" | &nid | "'";

   End-If;

End-If;


If All(&status) Then

   If All(&WHERE_CLAUSE) Then

      &WHERE_CLAUSE = &WHERE_CLAUSE | " AND " | "X_DELIVERY_STATUS = '" | &status | "'";

   Else

      &WHERE_CLAUSE = &WHERE_CLAUSE | " X_DELIVERY_STATUS = '" | &status | "'";

   End-If;

End-If;




If All(X_TSCRPT_WRK.DATE_TO.Value, X_TSCRPT_WRK.DATE_FROM.Value) Then

   If All(&WHERE_CLAUSE) Then

      &WHERE_CLAUSE = &WHERE_CLAUSE | " AND " | "SUBMITTED_DT  between " | Quote(X_TSCRPT_WRK.DATE_FROM.Value) | " AND " | Quote(X_TSCRPT_WRK.DATE_TO.Value);

   Else

      &WHERE_CLAUSE = &WHERE_CLAUSE | "SUBMITTED_DT  between " | Quote(X_TSCRPT_WRK.DATE_FROM.Value) | " AND " | Quote(X_TSCRPT_WRK.DATE_TO.Value);

      

      

   End-If;

End-If;



If All(&WHERE_CLAUSE) Then

   &WHERE_CLAUSE = "WHERE " | &WHERE_CLAUSE;

End-If;

ScrollSelect(1, Record.X_TRANS_REQ_VW, Record.X_TRANS_REQ_VW, &WHERE_CLAUSE);


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;