Pay Slips as attachments in PeopleSoft
With the attachment functions in PeopleSoft it is possible to load pay slips, annual statements or other documents into the database. It is a good idea to have the attachments into the database, because then you can handle the security with PeopleSoft (and with Oracle on the database level), instead of on the file system. In this case the attachments are in PDF format. Once the pay slips are uploaded into the database, it is possible to view them by clicking on a link in ESS (Employee Self Service). When you click on the link, acrobat reader will start and present the pay slip in a new window. The user can print the pay slip or annual statement from acrobat reader.
When all pay slips and annual statements would be printed by everyone, surely there is no business case for saving paper. But nevertheless there is a business case for saving stamps. In practice not all of the pay slips will actually be printed, however.
You could also create an application engine to take care of the distribution / notification. People who can use ESS will then get a notification that their pay slip is uploaded and can be viewed. Some other people will receive the pay slip as an attachment in an e-mail. For still some other people the pay slip is printed and send by post. An example of this last group could be someone who is retired, and therefore cannot reach ESS, and who doesn’t want to or cannot receive the pay slip as an attachment on his private e-mail address. Pay slips that are e-mailed as an attachment (with the PeopleSoft command sendmail) and pay slips that are printed in a batch, are first downloaded from the database to the file system (and afterwards deleted). To download the files to the file system, you can use the PeopleSoft command getfile() – writeraw. To delete the file getfile() – delete. For purposes of printing you can use writeraw to create one big PDF file containing all of the pay slips that should be printed in one run, so that they can be send to the printer all at the same time. The printing itself can be done by means of a java class that sends the PDF to the printer. A method of the java class can be called from PeopleSoft. Instead of java you can also use command line acrobat reader commands, that you put in a cmd-file. But take into account that Adobe doesn’t support command line commands with modern versions of Acrobat Reader (although it still works nevertheless).
I do not discuss attachment framework here, because this blog discusses techniques you would use in earlier versions.
Importing pay slips into the database
The import can be done by an application engine. When the user starts this process, he needs to specify the server and path where the PDF-files are placed, in UNC-notation on windows. For example \\srv12345\temp\. For unix you would use an FTP-notation, for instance ftp://psftp:Password@srv12345.myorg.org/psoft/temp/.
The application engine peoplecode can use the command PutAttachment(URL.MYPAYSLIPREC, &thisbasefile, &thisfilename) in order to import the pay slips into the database. The content of URL.MYPAYSLIPREC then would be a record that contains the subrecord FILE_ATTDET_SBR. In the URL-definition before the record name you need to specify that it is a record:
The variable &thisbasefile contains a filename without a path, while the variable &thisfilename contains a filename including the path. In the directory that contains all the files to import, you want to evaluate all the PDF-files present. You can do that to put all of the filenames in an array:
&FNAMES = FindFiles(&path | “*.PDF”, %FilePath_Absolute);
Then you go step by step along the files with the command While &FNAMES.Len > 0 …. and then use the command PutAttachment for each file.
Viewing a pay slip in ESS
On the ESS page you can make a link, and the Field Change peoplecode contains the command viewattachment to start acrobat reader and view the attachment:
&retcode = ViewAttachment(URL.MYPAYSLIPREC, somerecord.ATTACHSYSFILENAME, somerecord.ATTACHSYSFILENAME);
Distribution of the pay slips
When the pay slip is in the database and you want to e-mail it as an attachment to an e-mail, or if you want to send payslips to the printer from an application engine, first you want to download the file back to the file system.
You can do that with the following code:
&SQLATT = GetSQL(SQL.GET_ATTACHMENT, Record.PAY_SLIP_ATT, &MAIL_TITLE);
&THISFILE = GetFile(&MAIL_FILE, “w”, “a”, %FilePath_Absolute);
While &SQLATT.Fetch(&ATTREC)
&THISFILE.WriteRaw(&ATTREC.FILE_DATA.Value);
End-While;
&THISFILE.Close();
The SQL GET_ATTACHMENT being:
%SelectAll(:1) WHERE ATTACHSYSFILENAME = :2 AND version = (SELECT MAX(version) FROM PS_PAY_SLIP_ATT WHERE ATTACHSYSFILENAME = :2) ORDER BY FILE_SEQ
The command writeraw writes the raw data from the database table directly into the file, so that the original PDF-file appears on the filesystem. You can delete the file with %THISFILE.delete(). The flag “w” in the GetFile command means that you write it in a new file. You can also append it to an existing file instead: &THISFILE = GetFile(&PRINT_FILE, “a”, “a”, %FilePath_Absolute). In this way you can add different pay slips into one big PDF-file that you can send to the printer in one go.
Calling a java method from peoplecode
The accual printing can be done by means of a java class, containg a method. In peoplecode you must declare a java object: Local JavaObject &java_obj. Then you should create the object:
&java_obj= CreateJavaObject(“PDFPrinter”). Where PDFPrinter is the name of the java class.
Then, given a filename (including the path) and the printername including the servername, you can call a method from the java-class (in this case the method print).
&RET = &java_obj.print(&PRINT_FILE, A_ADL_AET.PRINTER_NAME);
And last but not least the the javaobject variable should be nullified: &java_obj = Null.
Viewed 37484 times by 14563 visitors



Payslips as attachments in PoepleSoft seems to be a very good idea. It’s more convenient to the employees and also to the company. The employees could see or view their payslips via PeopleSoft because the company has already uploaded it to their database and can save more than distributing it via conventional mail.
[Reply to this comment]