Background - I got a requirement to create a folder on a specified path on application server, on monthly basis, and place a file in the folder.
Initially I thought it would be very simple, as we have used OPEN DATASET statements to access the path on the application server. I believed that if we could pass the new folder concatenated with the path then it would create a folder automatically. I have made necessary changes to the program. Only at the time of testing, I have realized that the statement OPEN DATASET failed with reason “Invalid path”.
With my requirement “Creation of a folder on application server”, I have searched on the internet and could found information about external command, it makes possible to create a folder on the applications server. I got very little support from my basis on external command, so I have searched again on how to create an external command and how to use it.
Then I came to know about Function Module ‘SXPG_COMMAND_EXECUTE’ which can be called by passing external command and external Paramters which can be passed to the external command. I even got a piece of information about external command, which I thought I would share it here.
External Command – External command operates at OS level which calls a batch file in Windows or a Shell file in UNIX (This information is limited to my knowledge) and can be created in SAP from transaction SM69 or SM49.
Eg: External Command – ZCREATE_FOLDER;
OS – Windows NT;
OS Command – C:\Path\batch.bat ;
Paramters for OS command - &1
Batch file / Shell file – These files contains simple DOS commands or Shell commands.
Eg: To create a folder with dynamic parameter we can batch file have a command similar to
MKDIR C:\PATH\%1
Where C:\Path – is known Path
%1 – Parameter 1, the value can be passed from external Command