Uploading a file to the file server in peoplesoft peoplecode

Local string &InOutAttachUserfile, &file_name, &temp_dir, &InOutAttachSysfilename;

Local integer &InMaxSize, &Result, &Return_Code;

Local string &uniquefilename, &ATTACHSYSFILENAME, &ATTACHUSERFILE, &strFolderpath;

 

 

Local string &URL_ID = "record://HRS_ATTACHMENTS";

&Return_Code = AddAttachment(&URL_ID, &ATTACHSYSFILENAME, "", &ATTACHUSERFILE, &InMaxSize, True);

 

 

/*Create unique file name*/

&uniquefilename = "QBU_UPLOAD" | "_" | String(Month(%Date)) | "_" | String(Day(%Date)) | "_" | String(Year(%Date)) | "_" | String(Hour(%Time)) | "_" | String(Minute(%Time)) | "_" | String(Second(%Time)) | ".csv";

 

&ATTACHSYSFILENAME = Left(&uniquefilename, 64);

&ATTACHSYSFILENAME = &uniquefilename;

 

COP_QBU_RCNTL.ATTACHSYSFILENAME.Value = &ATTACHSYSFILENAME;

COP_QBU_RCNTL.ATTACHUSERFILE.Value = &ATTACHUSERFILE;

COP_QBU_RCNTL.FILENAME.Value = &ATTACHSYSFILENAME;

Rem &strFolderpath = GetURL(URL.AFA_FILESERVER);

Rem &strFolderpath = &strFolderpath | "ad/" | Lower(%DbName) | "/in/other/";

&strFolderpath = GetURL(URL.COP_INBOUND_FILE_DIR);

 

If All(&ATTACHSYSFILENAME) Then

   &Result = GetAttachment(&URL_ID, &ATTACHUSERFILE, &strFolderpath | &ATTACHSYSFILENAME);

   If &Result = 0 Then

      MessageBox(0, "", 0, 0, "File Uploaded");

   Else

      MessageBox(0, "", 0, 0, "File Upload Failed" | &Result);

   End-If;

End-If;

DoSaveNow();

Comments

Popular posts from this blog

BI Publisher: If Condition with sub-string in rtf template