How to use PeopleSoft File Attachments to FTP and Database Server

How to use PeopleSoft File Attachments to FTP and Database Server

You can use PeopleSoft File Attachments to FTP and Database Server information is provided below – focuses on actual working PeopleCode.  First, a simple example to load a file into a RECORD ( Database Server of PeopleSoft) using Application Engine.

—————-Beginning of Preview—————————————————–

Simple Example:
Create an Application Engine with just one Step in main and one PeopleCode Action in that step. Copy the following PeopleCode. Replace the file name and the path to any valid file on your system — on Unix or NT server where you intend to run the Application Engine.

/**********Start of PeopleCode*******************/
/* This code saves file from any server (NT/Unix) to Database Server using PutAttachment command*/
/* Unlike AddAttachment, PutAttachment does not open the file browse window for user to select one file to load */

Local File &MYFILE;
Local string &ATTACHUSERFILE, &ATTACHSYSFILENAME;

&URL_ID = “RECORD://HRS_ATTACHMENTS”;
&ATTACHUSERFILE = “/sw/app/psoft/psofthr/user/01161586201303283250187000.xml”; /* Actual File Name with path – shown here for UNIX, on NT use UNC naming convention example: \\server1\test1\test2\file.xml*/
&ATTACHSYSFILENAME = “01161586201303283250187000.xml”; /*This has to be unique file name – else will replace any previously loaded file – you may make this unique by appending something like data/time/etc*/
If Exact(Left(&URL_ID, 4), “URL.”) Then
&return_code = PutAttachment(@(&URL_ID), &ATTACHSYSFILENAME, &ATTACHUSERFILE); /* Upload file */
Else
&return_code = PutAttachment(&URL_ID, &ATTACHSYSFILENAME, &ATTACHUSERFILE); /* Upload file */
End-If;
/**********End of PeopleCode*******************/

Simple Test:
Step1: select * from PS_HRS_ATTACHMENTS;
No values
Step2: Run the Above Application Engine:
Step3: select * from PS_HRS_ATTACHMENTS;
01161586201303283250187000.xml    0    1    8214    .. BLOB NOT RETRIEVED
—————-End of Preview———————————————————–

References:
http://www.pscustomizer.com/peoplesoft-examples/attachments/
http://peoplesoft.ittoolbox.com/groups/technical-functional/peopletools-l/write-file-into-database-using-sqr-2528747
https://forums.oracle.com/forums/thread.jspa?messageID=10320192
http://docs.oracle.com/cd/E15645_01/pt850pbr0/eng/psbooks/tpcl/book.htm?File=tpcl/htm/tpcl02.htm#H4541 
http://docs.oracle.com/cd/E15645_01/pt850pbr0/eng/psbooks/tpcd/chapter.htm?File=tpcd/htm/tpcd11.htm
http://peoplesoftstuff.blogspot.com/2012/07/upload-file-from-local-to-server.html 
http://peoplesoft.ittoolbox.com/groups/technical-functional/peopletools-l/browse-functionality-on-run-control-page-819632

Posted in Peoplecode.