Tuesday, 8 May 2012

PeopleCode to Create XML and XSD file

The below code is useful to create XML and XSD file.  Create Application engine program with below code and run the AE program in App designer to get a file in local. You can get the same in server without specifying any path and give it as relative path instead of file absolute.
PSXP_XMLGEN application package used to create xml file. You can multiple parent and child records. This file is used for data import or export programs.
/*Create Rowsets*/
&RS_ADR = CreateRowset(Record.EMPLOYEES);
&RS_PER = CreateRowset(Record.PERSON, &RS_ADR);
/*Fill Parent*/
&RS_PER.fILL(“WHERE EMPLID = ‘11902′”);
/*Fill Child*/
For &i = 1 To &RS_PER.Activerowcount
&row = &RS_PER.Getrow(&i);
&rs = &row.Getrowset(Scroll.EMPLOYEES);
&rs.fill(“Where emplid = :1″, &row.PERSON.emplid.value);
/* Create XSD */
&rds = create PSXP_XMLGEN:RowSetDS();
&myschema = &rds.Getxsdschema(&RS_PER);
&f1 = GetFile(“C:\temp\rpt01.xsd”, “w”, %FilePath_Absolute);
/*Create Sample XML File */
&myXMLfile = &rds.GetXMLData(&RS_PER, “C:\temp\rpt01.xsd”);
&f2 = GetFile(“C:\temp\rpt01.xml”, “w”, %FilePath_Absolute);

No comments:

Post a comment