At times we are in need of executing OS command scripts automatically but we are also required to make these scripts flexible so that with further requirements we may edit this script to enhance the functionalities. In this blog I will try and explain one such requirement we had and how I worked with OS command process variants to execute the scripts.
Scenario: The need was to execute an OHD and share the resultant data file only to third party systems over Tibco’s File Transfer service TFTS.
Need for the OS command: The primary requirement to use OS command was to call the external TFTS adapter. (TFTS adapters could be called using a background job with external program as well).
However I have utilized OS command for the below purposes as well:
- Removing of the header file generated by the OHD.
- Creating a backup of the data file shared for tracking back requirements.
Transaction Codes Used: AL11, SM69, RSPC.
Creating Shell Scripts: Shell scripts were created using a notepad with “.sh” extension in this scenario.
The above script REMOVES (-r) the file which starts with the pattern which has been blocked out. The header files always start with “S”, hence the pattern “S*” has been coded to target just the header files.
Save this file with .sh extension:
This “.sh” file needs to be uploaded to a location on AL11. This can be achieved through transaction CG3Z, however for this scenario it was done through a custom program created for such purposes.
Creating OS commands to call the script:
From SM69 OS commands can be created as below:
Calling the OS command in PC:
Create a PC with variant type OS command in it to call this particular OS command which in turn executes the saved shell script.
Design Considerations: We wanted control over each script separately in the event where we had to execute just the copy or just deletion of header file, hence the scripts were not jumbled into one script but created as separate files. The scripts being created as files provides us extra flexibility, for instance, if we need the copy script to also copy the same file into another new folder then we just have to change the copy shell script file to achieve this.
Sample working scripts similarly uploaded to Application server: