SAP BLOG Calling shell scripts from process chains through OS command variants.

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
1,925
Tepki puanı
7
Puanları
6
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.

1-7.jpg




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:

2-5.jpg


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.

3-5.jpg




Creating OS commands to call the script:

From SM69 OS commands can be created as below:

4-4.jpg


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.

5-2.jpg


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:

6-3.jpg


Okumaya devam et...
 
Üst