Blog Pro de Jean-Baptiste HEREN

Notes d'un consultant Freelance en Informatique

To content | To menu | To search

Déplacer un fichier avec Peoplecode

Pour faire court voici un exemple d'utilisation de la commande exec() et d'un fichier batch pour déplacer un fichier.

/********************************/
/* Initialisation des variables */
/********************************/
Local File &File;
 
&file_dir = UNE_TABLE_AET.FILE_DIRECTORY;
&file_name = UNE_TABLE_AET.FILE_NAME;
 
&new_file_dir = UNE_TABLE_AET.FILE_DIR_SERVER;
&new_file_name = &file_name | "_" | UNE_TABLE_AET.PROCESS_INSTANCE;
 
&cheminbatch = &new_file_dir | UNE_TABLE_AET.PROCESS_INSTANCE | ".bat ";
&chemin = &file_dir | &file_name;
&cheminnouveau = &new_file_dir | &new_file_name;
 
&commandcp = "move " | &chemin | " " | &cheminnouveau;
&commandrm = "del " | &chemin;
&commandrm2 = "del " | &cheminbatch;
 
/* Ecriture d'un BATCH script de déplacement & renommage du fichier */
&File = GetFile(&cheminbatch, "W", "A", %FilePath_Absolute);
&File.WriteLine(&commandcp);
&File.WriteLine(&commandrm);
&File.WriteLine(&commandrm2);
&File.Close();
 
/* création d'un fichier log.*/
REM &cheminbatch = &cheminbatch | " > " | &new_file_dir | UNE_TABLE_AET.PROCESS_INSTANCE | ".log";
 
/* Exécution de du batch */
If Exec(&cheminbatch, %Exec_Synchronous + %FilePath_Absolute) >= 0 Then
   MessageBox(0, "", 0, 0, "Déplacement du fichier de %1 à %2 réussi", &chemin, &cheminnouveau);
End-If;

Post updated on Wednesday 04 November 2009, 21:39

Jean-Baptiste Heren

Author: Jean-Baptiste Heren

Stay in touch with the latest news and subscribe to the RSS Feed about this category

Be the first to comment on this article

Add a comment This post's comments feed

no attachment



You Might Also Like

Finding one component location in the peoplesoft portal

Just replace the 'MY_COMPONENT_GBL' parameter in the following sql script. This works for MS SQl Server. You can add more levels by adding Outer Joins. /* Where is my component in the portal */...

Continue reading

02_-_new_component_interface.png

Peoplesoft Component interface HOWTO

Here is a tutorial explaining how you can create a function containing one Component INterface, and make use of it from any peolplecode. Following example takes the PO Receipt Component to make...

Continue reading