Extract Dynamic file name from file path in RPLGE - IBM I / AS400

 Extract Dynamic file name from file path:-

**Free                                                           

                                                                 

    // Variable  declarations                                    

                                                                 

       Dcl-s FilePath Varchar(30);                               

       Dcl-S FileName Varchar(30);                               

       Dcl-S LastSlash Zoned(4);                                 

                                                                 

    // File path                                                 

                                                                 

       Filepath = '/TehSharmit/RPGLE/Myfile.txt';                

                                                                 

    // Extracting the position of lastslash from the file path   

                                                                 

       LastSlash = %scanr('/' : FilePath);                       

                                                                 

    // Extracting the filename from the path                     

                                                                 

       FileName  = %subst(FilePath : LastSlash + 1);             

                                  

  // Displaying the filepath      

                                  

     Dsply FilePath;              

                                  

  // Displaying the filename      

                                  

     Dsply FileName;              

                                  

     *inlr = *on;                 


Subscribe Tech Sharmit for more videos on IBMi / AS400

Please refer to the below video for the same topic.          



       

Comments

Popular posts from this blog

Dynamic XMl file creation in IFS using RPGLE Program - IBMI / AS400

Compile Time Data Array in RPGLE - IBM i / AS400

Numeric Data type in RPGLE free format - IBM i / AS400