Sunday, October 20, 2013

XML -

This will generate an XML error:
<message>if salary < 1000 then</message>
To avoid this error, replace the "<" character with an entity reference:
<message>if salary &lt; 1000 then</message>
There are 5 predefined entity references in XML:
&lt;<less than
&gt;>greater than
&amp;&ampersand 
&apos;'apostrophe
&quot;"quotation mark

Saturday, October 19, 2013

Dynamic Prompt - with Dynaic view

in every field change write criteria Function -

Declare Function Build_WhereClause PeopleCode MHN_PENDDOC_REC.EMPLID FieldFormula;

Build_WhereClause();

Where Clause Function : in EMPLID field formula

Function Build_WhereClause
   
   Local string &where_clause, &sql1;
   
   If All(MHN_PENDDOC_REC.INSTITUTION.Value) Then
      &where_clause = &where_clause | "INSTITUTION='" | MHN_PENDDOC_REC.INSTITUTION.Value | "' ";
   End-If;
   
   If All(MHN_PENDDOC_REC.ACAD_CAREER.Value) Then
      &where_clause = &where_clause | "AND ACAD_CAREER='" | MHN_PENDDOC_REC.ACAD_CAREER.Value | "' ";
   End-If;
   
   If All(MHN_PENDDOC_REC.STRM.Value) Then
      &where_clause = &where_clause | "AND STRM='" | MHN_PENDDOC_REC.STRM.Value | "' ";
   End-If;
   
   If All(MHN_PENDDOC_REC.CAMPUS.Value) Then
      &where_clause = &where_clause | "AND CAMPUS='" | MHN_PENDDOC_REC.CAMPUS.Value | "' ";
   End-If;
   
   If All(MHN_PENDDOC_REC.ACAD_PLAN.Value) Then
      &where_clause = &where_clause | "AND ACAD_PLAN='" | MHN_PENDDOC_REC.ACAD_PLAN.Value | "' ";
   End-If;
   
   If All(MHN_PENDDOC_REC.CLASS_SECTION.Value) Then
      &where_clause = &where_clause | "AND CLASS_SECTION='" | MHN_PENDDOC_REC.CLASS_SECTION.Value | "' ";
   End-If;
   
   If All(MHN_PENDDOC_REC.ADMIT_TYPE.Value) Then
      &where_clause = &where_clause | "AND ADMIT_TYPE='" | MHN_PENDDOC_REC.ADMIT_TYPE.Value | "' ";
   End-If;
   rem WinMessage(&where_clause);
   If Left(&where_clause, 3) = "AND" Then
      &where_clause = Replace(&where_clause, 1, 3, "");
   End-If;
   If All(&where_clause) Then
      &where_clause = "WHERE" | &where_clause;
   End-If;
   &sql1 = " SELECT DISTINCT EMPLID,NAME FROM PS_MHN_XML_EMP4_VW " | &where_clause;
   
   
   MHN_PENDDOC_REC.EMPLID.SqlText = &sql1;
End-Function;

in EMPLID Rowinit

MHN_PENDDOC_REC.EMPLID.SqlText = "SELECT DISTINCT EMPLID, NAME  FROM PS_MHN_XML_EMP4_VW";

Dynamic Grid -



 &SQLString = "SELECT A.COMMON_ID,  C.NAME,A.CHECKLIST_CD, D.XLATLONGNAME FROM PS_PERSON_CHECKLST A, PS_NAMES C, PSXLATITEM D WHERE A.CHECKLIST_STATUS = 'I'  AND C.EFFDT = (SELECT MAX(C_ED.EFFDT) FROM PS_NAMES C_ED WHERE C.EMPLID = C_ED.EMPLID AND C.NAME_TYPE = C_ED.NAME_TYPE AND NAME_TYPE='PRI' AND C_ED.EFFDT <= SYSDATE) AND A.COMMON_ID = C.EMPLID AND  D.fieldname = 'CHECKLIST_STATUS' AND D.FIELDVALUE = A.CHECKLIST_STATUS AND A.COMMON_ID IN (SELECT HM.EMPLID FROM PS_MHN_PENDDOC_VW HM) ";
       
&sql1 = CreateSQL(&SQLString);
             
 &rsStep = GetLevel0()(1).GetRowset(Scroll.MHN_PENDOC_TBL);
 &rsStep.Flush();
 &gridrow_i = 0;
While &sql1.Fetch(&HM_COMMON_ID, &HM_NAME, &HM_DESCR, &HM_XLATLONGNAME)
                  
&gridrow_i = &gridrow_i + 1;
&rsStep.InsertRow(&gridrow_i);
&rsStep(&gridrow_i).MHN_PENDOC_TBL.OPRID.Value = %OperatorId;
SQLExec("SELECT A.NAME FROM PS_PERSON_NAME A,psoprdefn B WHERE A.EMPLID = B.EMPLID AND NAME_TYPE = 'PRI' AND B.OPRID = :1", %OperatorId, &HM_OPR_NAME);
&rsStep(&gridrow_i).MHN_PENDOC_TBL.GetField(Field.NAME).Value = &HM_OPR_NAME;
 &rsStep(&gridrow_i).MHN_PENDOC_TBL.EMPLID.Value = &HM_COMMON_ID;
 &rsStep(&gridrow_i).MHN_PENDOC_TBL.FULL_NAME.Value = &HM_NAME;
 &rsStep(&gridrow_i).MHN_PENDOC_TBL.DESCR.Value = &HM_DESCR;
 &rsStep(&gridrow_i).MHN_PENDOC_TBL.XLATLONGNAME.Value = &HM_XLATLONGNAME;
SQLExec("SELECT DESCR,CLASS_SECTION,EXPIRATION_DATE,DESCR1,NATIONAL_ID FROM PS_MHN_PENDDOC_VW WHERE EMPLID = :1 AND ROWNUM = 1", &HM_COMMON_ID, &HM_PT_DESCR, &HM_PT_CLASS_SECTION, &HM_PT_EXPIRATION_DATE, &HM_PT_DESCR1, &HM_PT_NATIONAL_ID);;
&rsStep(&gridrow_i).MHN_PENDOC_TBL.CLASS_SECTION.Value = &HM_PT_CLASS_SECTION;
&rsStep(&gridrow_i).MHN_PENDOC_TBL.DESCR1.Value = &HM_PT_DESCR;
&rsStep(&gridrow_i).MHN_PENDOC_TBL.DESCR2.Value = &HM_PT_DESCR1;
&rsStep(&gridrow_i).MHN_PENDOC_TBL.EXPIRATION_DATE.Value = &HM_PT_EXPIRATION_DATE;
&rsStep(&gridrow_i).MHN_PENDOC_TBL.NATIONAL_ID.Value = &HM_PT_NATIONAL_ID;
             
End-While;
               &rsStep.DeleteRow(&gridrow_i + 1);

XML Publisher Step by step

  Analyse the Requirement and prepare Target Record with Required fields to Report(do all tthis using in Peoplecode)

Now XMLP Steps will start:
1) We have prepare Query with Target record (Reporting tools > PS Query > Query Manager -- Save).
2) Use this Query and Prepare Data Source (Reporting tools > BI Publisher > Data Source).
    a) Generate XML and XSD
    b) Save xml file to local System
3) Open a new Word Document and use BI-Publisher -  Add-in.
  a) Use Sample XML option to load saved xml on local system.
  b) will get Data load Successfull message.
  c) Now Prepare Template as per Client Requirement
       i) Table wizard - Table - option used to get data in Table Format
      ii) Form to Access the Fields
      iii) Free Form - Will prepare Letter/certificate Templates
  d) save Template name with ".rtf".
4) now upload this template File to Report definition in Template tab and make active status and test Visualise button.
 note: be carefull we have to use same query name
5) Then test using  xml viewer.
__________________________________
Same report to generate using people code

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* People code to Run BI Publisher           */
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
import PSXP_RPTDEFNMANAGER:*;

Local Record &rcdQryPrompts;
Local string &LanguageCd, &MyTemplate, &MyReportName, &OutFormat, &EMPLID;
Local date &AsOfDate, &BEGIN_DT, &END_DT;

Local Record &rcdSltEmp;
Local string &strEmplids;

Local Rowset &rsSltEmp;


Local Record &REC;


DoSaveNow();

&rsSltEmp = GetLevel0()(1).GetRowset(Scroll.MHN_PENDOC_TBL);
&REC = CreateRecord(Record.MHN_PENDOC_TBL);


 
 
   rem TransferPage(Page.LGE_TL_SEC);
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   /* Set XML Publisher report required parameters                            */
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   /**/
   &LanguageCd = "POR";
   &AsOfDate = %Date;
   &OutFormat = "PDF";
   REM &OutFormat = "HTML";

 
      &MyReportName = "MHN_TERM_HM";
      &MyTemplate = "MHN_TERM_HM_1";

 
 
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   /* Prompt values                                                           */
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
 
   Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn(&MyReportName);
   &oReportDefn.Get();
   &rcdQryPrompts = &oReportDefn.GetPSQueryPromptRecord();
 
   If Not &rcdQryPrompts = Null Then
      &oReportDefn.SetPSQueryPromptRecord(&rcdQryPrompts);
      &rcdQryPrompts.OPRID.Value = %OperatorId;
   End-If;

   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   /* Kick of the report process                                              */
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
 
   &oReportDefn.ProcessReport(&MyTemplate, &LanguageCd, &AsOfDate, &OutFormat);
 
   CommitWork();
 
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   /* Display Report to the user                                              */
   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
   &oReportDefn.DisplayOutput();
End-If;

Required Field property will not work in Derived work Record.

1) Enable Required fied property in Derived Work Record
2) Place this fied on the Page
3) then open component in PIA and saving the page with out value in the field
4) Page is Saving, not triggering the required field validation.
Reason: Derived Work Record is not a Physical Table so no value is going to save on the database.
i.e. reason Derived work record - Required field will not work so we have to write manual validataion.
Eg: If MHN_PENDDOC_REC.INSTITUTION.Value = "" Then
   /*Error - Por favor selecione o valor Instituição Acadêmica */
   MHN_PENDDOC_REC.INSTITUTION.Style = "PSERROR";
   Error MsgGet(32002, 2, "Message Not Found.");
Else
   MHN_PENDDOC_REC.INSTITUTION.Style = "";
 
end-if;

Wednesday, May 8, 2013

Sysdate in SQR

let $hdatenow = datenow()
let $hsysdate  = datetostr(datenow(),'YYYYMMDD')
$hsysdate   - value we can see Sysdate.