XML Generation Code for a single staging table in PeopleSoft

REM ****************************************Modification Summary ******************************************;
REM SL.No    Developer      Mod. No.   Date          Changes
REM -----  -----------     ---------- ----------  -------------------------------------------
REM  01          Krishnam Raju      XX0005      11/17/2015      The below code will generate the XML file
REM********************************************************************************************************;
Function StartObjectNode(&ObjectTypeCode As string)
   Evaluate &ObjectTypeCode
   When "-1"
      &inXMLProjObjNode = &inXMLDoc.DocumentElement.AddElement("XXX_EOPS_RPT");
      Break;
   End-Evaluate;
End-Function;

Function EndObjectNode(&ObjectTypeCode As string)
   Evaluate &ObjectTypeCode
   When "0"
      &inXMLRecCount.NodeValue = String(&inXMLRecObjNode.ChildNodeCount - 1);
      Break;
   End-Evaluate;
End-Function;

Function CreateParentStgXML()
   Local XmlNode &inXMLProjNode, &inXMLClassNotesNode;
   Local Record &rec_XXX_EOPS_STG;
   Local Rowset &rs_XXX_EOPS_STG;
   Local integer &I, &J, &K, &L;

   &rec_XXX_EOPS_STG = CreateRecord(Record.XXX_EOPS_STG);
   &rs_XXX_EOPS_STG = CreateRowset(Record.XXX_EOPS_STG);


   MessageBox(0, "", 0, 0, "&ProcessInstance : " | &ProcessInstance);
   &rscount_header = &rs_XXX_EOPS_STG.Fill("where PROCESS_INSTANCE = :1", &ProcessInstance);


   For &Z = 1 To &rscount_header
      &inXMLHeaderNode = &inXMLProjObjNode.AddElement("HEADER");
      &EMPLID = &rs_XXX_EOPS_STG(&Z).XXX_EOPS_STG.EMPLID.Value;
      For &K = 1 To &rec_XXX_EOPS_STG.FieldCount
         &fieldname = &rec_XXX_EOPS_STG.GetField(&K).Name;
         &inxmlPNode1 = &inXML | &fieldname;
         &inxmlPNode1 = &inXMLHeaderNode.AddElement(&fieldname);
         &inxmlPNode1.NodeValue = &rs_XXX_EOPS_STG(&Z).XXX_EOPS_STG.GetField(@("FIELD." | &fieldname)).Value;
      End-For;
   End-For;
End-Function;

Local File &file;

&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><ROOT/>");
StartObjectNode("-1");
&ProcessInstance = XXX_EOPS_AET.PROCESS_INSTANCE.Value;
CreateParentStgXML();

EndObjectNode("-1");

&OUTPUTfile = "XXX_EOPS_" | XXX_EOPS_AET.PROCESS_INSTANCE.Value | ".XML";

&file = GetFile(&OUTPUTfile, "W", %FilePath_Absolute);
&file.WriteLine(&inXMLDoc.GenFormattedXmlString());
&file.Close();

Comments

Popular posts from this blog

BI Publisher: If Condition with sub-string in rtf template