Using PeopleSoft File Layout (Third Party Administrator File Generation) Judi Doolittle, OCP, Oracle ACE Natasha Garcia Sandia National Laboratories
What we will cover Writing Data to a Flat File Methods to Read and Write (Plain Text Files) Writing Files (Defined by a File Layout) Creating an App Engine (to Export Data to Flat File) Creating Multilevel File Layout PeopleCode for Multilevel File Layout Segments in File Layout N
Writing Data to a Flat File File Class Methods ReadLine (string) Wit WriteLine (string) ti WriteString (string) N
PeopleCode Example Local string &string; Local File &Myfile, &Myfile2; &MyFile = GetFile( test.txt txt, R ); R); &MyFile2 = GetFile( c:\temp\test2.txt, W, %FilePath_Absolute); If &MyFile.IsOpen Then While &Myfile.ReadLine(&string); &MyFile2.WriteLine(&string); End-While; End-If; &MyFile.Close(); &MyFile2.Close(); N
PeopleCode Example Local XmlDoc &inxmldoc /* load message to file */ &xmlfile = GetFile("IB_MSG_TEMP.xml", "W"); If &xmlfile.isopen Then &xmlstring = &inxmldoc.genformattedxmlstring(); &xmlfile.writestring(&xmlstring); &xmlfile.close(); End-If; N
Methods to Read and Write (Plain Text Files) WriteRecord- writes the contents of a record object to the file. You can use this to write one file record at a time and not have to instantiate and populate a rowset object. WriteRowset- writes the contents of a rowset object, rowset, to the output file associated with the file object that calls the method. Calling this method one time writes the entire contents of the rowset to the file. N
CreateRowset Local Rowset &rs_carry_desig; &rs_carry_desig = CreateRowset(Record.AV_DESIGNATION); N
CreateSQL Function Instantiates ti t a SQL object from the SQL class then it opens it on the sqlstring and/or input values. The sqlstring is the parameter that holds the SQL statement SQL errors will cause PeopleCode to terminate with an error MetaSQL %SelectAll is a way to select everything in a record Tip: Remember to wrap DateTime fields with %DateOut, %TimeOut, %DateIn, and %TimeIn N
PeopleCode Example Local Record &rec1; Local SQL &SQL; /*Create Instance of Record */ &rec1 = CreateRecord(record.tc_help_me_tbl); tc tbl); /*Create SQL object to populate rowset */ &SQL = CreateSQL( %selectall(:1), &rec1); N
Writing Files using File Layout Local File &MyFile; Local Record &rec1; Local SQL &SQL1; /*Create Instance of Record */ &rec1 = CreateRecord(record.tc_help_me_tbl); &MyFile = GetFile( c:\temp\help p_ me.txt, A, %FilePath_ Absolute); &MyFile.setFileLayout(FileLayout.help_me); /*Create SQL object to populate rowset */ &SQL1 = CreateSQL( %selectall(:1), &rec1); While &SQL1.Fetch(&rec1) &MyFile.WriteRecord(&rec1); End-While; &MyFile.Close(); N
Creating an App Engine (to Export Data to Flat File) Steps Application Designer, File, New, Application Engine Program Select Insert, Action Save the Program Change the Action type to PeopleCode Enter Code Save Run N
Steps for Creating a Multilevel File Layout 1. Create a View 2. Create a new file layout 3. Drop and drag the view into the layout 4. Use the toolbar arrows to determine hierarchy 5. Double-click the record name to set segment properties 6. Assign a unique file record ID to each record 7. Note: start position and length are set automatically 8. Click OK 9. Click Yes to increment the start position of all fields 10. Save the File J
Easiest Way to do File Layout Match to View Record SL_BEN_COBC_VW
File Layout one to one to View
File Record ID Identifies the record Can be used with fixed and CSV files ID must be included in your flat file Assigned at the file layout segment level
COBRA TPA (Third Party Administrator) File Layout Example
Creating Rowsets and File /***Create Rowset Instance***/ &sl_rowset = CreateRowset(Record.SL_BEN_COBC_VW); &sl_rowset2 = &sl_rowset.getrow(1).getrowset(1); /***Create File Instance***/ If &whereto = "local" Then &path = "c:\temp\"; Else /* Get Unix path for files */ SQLExec("Select sl_charval from sl_pr_parm_tbl where sl_keyval = 'PATH-PROD-UNIX'", &path); End-If; /* Filename */ &filename = &curdate "_CB_PAR_" &clientid ".txt"; /** Create an instance of the File - this will be opened in Write mode with an absolute path. Then associate it with the appropriate File Layout */ &COBRAFile = GetFile(&path th &filename, "W", %FilePath_Absolute); l t /*********** Filelayout ************************************/ &COBRAFile.SetFileLayout(FileLayout.SL_COB_PAR);
SQL Statements /* Create SQL object to retrieve values */ &SQL1 = CreateSQL("%selectall(:1)", &recl); &SQL2 = CreateSQL("%selectall(:1)", &rec2); &SQL3 = CreateSQL("%selectall(:1)", &rec3);
Looping the Level One Record /* Loop through the rowset to get the values and write the rowset to file */ While &SQL_HDR.Fetch(&recl) /*copy record to rowset */ &recl.copyfieldsto(&rowset1.getrow(1).sl_ben_cob_hdr); /* Write rowset to file */ &COBRAFile.WriteRowset(&rowset1); it R t(& t1) End-While; /* Fetch data from SL_BEN_COBP_VW */ While &SQL_PAR.Fetch(&rec2) &I = 1; /* Copy record to the rowset */ &rec2.copyfieldsto(&rowset2.getrow(&i).sl_ben_cobp_vw); &rowset2.insertrow(&i); &COBRAFile.WriteRowset(&rowset2); &I = &I + 1; End-While; While &SQL_TRL.Fetch(&rec3) /*copy record to rowset */ &rec3.copyfieldsto(&rowset3.getrow(1).sl_ben_cob_trl); /* Write rowset to file */ &COBRAFile.WriteRowset(&rowset3); End-While;
Segments Uses: Specify the action to take for rows of data Limit it fields on the file layout Identify File Layout
Indicate Action You need to send a flat file to another app Indicate Action Insert Update Delete Use Segment to indicate the action
Limit Fields Following provided from: PeopleSoft Integration Tools and Utilities, File Layout and Data Interchange section You have a file and you only want two fields from it One way is to update everything and then manually delete the unwanted data Or insert a segment name it the same as the table and insert only the two fields you want
Limit Fields Cont. You have data that changes or you need to insert new rows Create a single field named AUDIT_ACTION ACTION which will indicate if the record is new or changed Use PeopleCode to look for the field and value and process conditional logic
Identifying the File Layout Use a segment to identify the part of the file you want to import 999 Product /*use PRODUCT layout*/
Steps to work with a Segment Drag and drop your record into the file layout Select Insert Segment Record Name, Max Length, & File Record ID (if you have one) Place your cursor on the Segment Name Select Insert File Field or Insert Database Field Then arrange the Segments in the order you want
Stepping Through Inserting a Stepping Through Inserting a Segment
Creating a Child Segment Insert a Child Segment highlight record, select Insert, ChildSegment, and enter file record name
Putting it all together Putting it all together (real world example)
What we covered Writing Data to a Flat File Methods to Read and Write (Plain Text Files) Writing Files (Defined by a File Layout) Creating an App Engine (to Export Data to Flat File) Creating Multilevel File Layout PeopleCode for Multilevel File Layout Segments in File Layout N
Book Signing Time: 11:45 am to 12:45 pm Location: Bookstore
Download Presentation http://www.oraclepressbooks.com/downloads/
Questions jhotsin@sandia.gov Judi_doolittle@ioug.org nygarci@sandia.gov