Mass Photo upload process in Peoplesoft

Process to upload the Photos/Pictures in to Peoplesoft

The following code can be used to upload the pictures/Photo of the employees in to Peoplesoft system easily.

/* This code loads the employee photo into the record EMPL_PHOTO record where filename photo will emplid. */

&REC = CreateRecord(Record.EMPL_PHOTO);

&REC.EMPLID.Value = &EMPLID; /* Emplid is retrived from sql */

/* Load the photo into an attachment record. This converts it to a blob. We use a chunk size large enough so that the whole image will be placed in one row. If chunk size is not modifed there will be mulitple rows in the for a single file in the record PSFILE_ATTDET with incrmenting sequence numbers. */
&Result = PutAttachment("record://PSFILE_ATTDET", &EMPLID | ".txt", &FILE_NAME);

/* Retrieve the blob from the file attachment record and put it in the record object and delete the row from the file attach record */
SQLExec("SELECT FILE_DATA FROM PSFILE_ATTDET WHERE ATTACHSYSFILENAME = :1 AND VERSION = 1", &EMPLID | ".txt", &Data);

&REC.EMPLOYEE_PHOTO.Value = &Data;
SQLExec("DELETE FROM PSFILE_ATTDET WHERE ATTACHSYSFILENAME = :1 AND VERSION = 1", &EMPLID | ".txt");

/* Set the version to seconds from year 2000 */
&REC.PSIMAGEVER.Value = (Days365(Date3(1999, 12, 31), %Date) * 86400) + (%Time - Time3(0, 0, 0));

/* Run and insert and update in case the record exist*/
&REC.Insert();
&REC.Update();


Note :- Before execution of this code the MAXCHUNKSIZE field in the PSOPTIONS (Peoplesoft Options should be set to the Max size of the photo file.

You can handle this in code as well by updating the max value to this field and begin of this code.
SQLExec("SELECT MAXCHUNKSIZE FROM PSOPTIONS", &Original);
SQLExec("UPDATE PSOPTIONS set MAXCHUNKSIZE = :1", CU_DB_AET.CHUNKSIZE);

At the end of the process you can replace the original value back.
/* Restore the default chunk size */
SQLExec("UPDATE PSOPTIONS set MAXCHUNKSIZE = :1", &Original);