PeopleSoft Wiki

psfluid-trianing.png

This post is about writing and manipulating data to a flat file using File Layout PeopleCode. I have found numerous simple examples of writing a record from a PS table to a File Layout. But what if you want to manipulate the data fields before writing out the line? How can that be accomplished?

Creating a export file from a file layout with Application Engine seidensc 30 Apr 2013 21:27

I have created a File Layout from specifications provided by a vendor. My Application Engine program is to read a record from a PeopleSoft view, manipulate the data if needed, and then write the line out to the File Layout. The next record is read in and the process is repeated.

The PeopleCode listed below is from the Application Engine Action. It is receiving a "BCUNIT is not a property of class File." error.

Local Record &rec1; Local File &myFile; Local SQL &sQL1; /* Create instance of Record */ &rec1 = CreateRecord(Record.W9M_MBSCRSE_VW); /* Instantiate the Output File */ &myFile = GetFile("c:\temp\help_me.txt", "A", %FilePath_Absolute); If &myFile.IsOpen Then If &myFile.SetFileLayout(FileLayout.TACOURIN) Then /* Create SQL object to populate rowset */ &sQL1 = CreateSQL("%Selectall(:1) Where INSTITUTION = :2", &rec1, W9M_MBSCRSE_AET.INSTITUTION); /* Cycle through the records */ While &sQL1.Fetch(&rec1) &myFile.BCUNIT = "1"; &myFile.BCTCD = &rec.W9M_MBS_TERM_CODE; &myFile.BCTYR = &rec.W9M_MBS_TERM_YEAR; &myFile.BCDPTN = &rec.ACAD_GROUP; &myFile.BCCOUR = substring(&rec.CATALOG_NBR,2,5); &myFile.BCSEC = &rec.CLASS_SECTION; &myFile.WriteRecord(); End-While; Else /* Process FileLayout Error here */ End-If; Else /* Process File Open Error here */ End-If; &myFile.Close();

Do I have to populate a rowset and then reference that in the WriteRecord statement? More than anything I would like to learn the correct way that this should be done. There are probably a lot of things wrong in this PeopleCode and if there are other areas I am missing the mark please let me know.