Wednesday, June 27, 2018

How to Delete a File With PeopleCode

           I had a requirement to create a log file with an Application Engine based upon a User entering a Bad Voucher's when utilizing the Excel to CI ExcelUploadforVoucher.xlsm. I created an Application Engine that will validate that the voucher's are correct according to the Business Rules set forth by the Functional Business team. Once this log file is created the file had to be attached to an Email and send to the User and to the Functional Business Analyst who is in charge of the Voucher build process. Once the file has been attached to the email, it needed to be deleted off the file server and this is how I accomplished this.
 
           I created a peoplecode step in my application engine and used this code to remove the file.


Local string &OPRID, &FileName, &DATABASE, &Path;
Local File &file;

/* Set the Operator Id from the State Record in the Application Engine*/;

&OPRID = VCHR_EDT_AET.OPRID2;

&FileName = &OPRID | "_Bad_Vouchers.txt";

/* Set the Database dynamically to the Database you are currently logged into*/;

&DATABASE = Lower(%DbName);

/* Open the file and delete it off of the file server*/;

&file = GetFile("&Path | &DATABASE | &FileName, "W", "A", %FilePath_Absolute);
&file.Delete();






No comments:

Post a Comment

8 Steps To Building an Application in PeopleSoft

Designing the Application:             This is the most important step in creating an application; most of the time in creating an applicat...