Thursday, April 18, 2013

PeopleSoft - PeopleCode for archiving the file in PSNT server using Application Engine


PeopleSoft - PeopleCode for archiving the file in PSNT server using Application Engine and Exec command

&TargetFilePath = "D:\FDEV9\Interface\Backup\Alliance\";

SQLExec("SELECT descr254,substr(descr254,instr(descr254,'\',-1)+1,length(descr254)) FROM PS_Z_AR_FILE_TMP WHERE PROCESS_INSTANCE = :1 AND FILE_SEQ = :2 AND ARCHIVE_PROCESS = 'A'", Z_AR_ALNCE_AET.PROCESS_INSTANCE.Value, Z_AR_ALNCE_AET.FILE_SEQ.Value, &SourceFileFull, &SrsFileName);


If Not None(&SourceFileFull) Then
 
   &ArchiveResult = 1;
   &TargetFile = &TargetFilePath | &SrsFileName;
   &ArchiveResult = PutAttachment("\\10.0.24.231\", &TargetFile, &SourceFileFull);
   &ExecCommand = "cmd /c move " | &SourceFileFull | " " | &TargetFile | " " | " > C:\movefile.log 2>&1";
   rem MessageBox(0, "", 0, 0, "&ExecCommand-" | &ExecCommand);
   try
    
      &ArchiveResult = Exec(&ExecCommand, %Exec_Asynchronous + %FilePath_Absolute);
   catch Exception &ex
      rem Handle the exception;
      MessageBox(0, "", 0, 0, &ex.ToString());
   end-try;
  
   If &ArchiveResult = 0 Then
      MessageBox(0, "", 0, 0, "File archive failed for - " | &TargetFile);
   Else
      MessageBox(0, "", 0, 0, "File archived successfully to folder- " | &TargetFile);
   End-If;
Else
   MessageBox(0, "", 0, 0, "File not archived DUE TO ERROROS");
End-If;


************************************************************************************************************************************************************************************

No comments: