Occasionally, I have the opportunity to utilize a feature in SAP that I have never used before. It is not necessarily a new feature, and it may have existed in SAP for several releases. There are several reasons for ignoring new functionality, but the primary reason that comes to mind is “I’ve always done it this way, I’ve installed hundreds of these, and I know it works”.
Sometimes, a special business or security requirement does not permit the “business as usual” scenario. It is these situations which nudge me down the path which I have never explored.
Take, for example, a simple flat file interface outbound from SAP to an external system. In the typical scenario, at the 50,000 foot level, it works like this:
In a scheduled batch job step, an SAP ABAP program extracts data and creates a flat file in a folder somewhere on the network that is commonly visible to both SAP and the external system.
The external system acquires the flat file, processes the data and then archives the file, just in case we need to play “where is my data” or “I sent it, why didn’t you get it”.
Here is the process diagram:
In this scenario, OS administrators on both sides of the interface have agreed to grant to the common folder all of the permissions needed so that each side of the interface can perform its tasks.
But what if that is not the case? What if the external system administrator cannot permit a common SAP/external system mount; but will permit receiving the file via ftp?
Let’s redraw the process diagram:
In this scenario, SAP drops the output file into its own outbound network OS folder.
The file is then moved to an inbound network folder on the external system via an ftp script.
The question now becomes, how do we execute the ftp script after the first step of the batch job which creates the outbound data file?
It turns out that SAP provides a facility to do just that. Effectively, SAP will allow the ftp script to be entered as a step in a batch job.
We begin to assemble our batch job with SM36 as usual.
As shown here, the batch job is named Z_OUT_INTERFACE_2_EXTERNAL_SYST.
The first step of the batch job executes ABAP program Z_OUT_MATERIAL_EXTRACT with variant PRODUCTION_VAR.
This is the step which creates the outbound data file.
Once the file is created by the ABAP program in step 1, we would like an ftp script to execute, and copy the file to a folder on the remote system.
SAP allows an external program (e.g. our ftp script) to be executed as a batch job step. We are going to make this step 2 in our job.
(This is the section of batch job land which I had never before explored.)
To set up an external program as an SAP batch job step, click the External Program button.
The External program block is now open for input.
In the Name box, enter the complete path name of the location of the external program.
In this case, our external program is an ftp script which takes two input parameters:
1) The complete pathname of the data file.
In this example, the complete pathname is /data/dx1/ftpscript.ksh.
2) The path name and the name of the outbound data file.
In this example, the path name of the outbound data file is /data/dx1/interfaces/materials/outbound,
and the name of the outbound data file is materials.txt.
Both of these parameters are entered in the Parameter box.
SAP also allows for the external program standard output or error output to be displayed in the SAP job log.
These are turned on/off using control flags.
In this example, I have turned on the control flags which allow any standard output and error output from the external program to be displayed in the SAP job log. I have also set the control flag which requires that the external program complete before the SAP job ends. If this control flag is not set and there are no further job steps, the SAP job will complete without waiting for the external program.
Here is the entire SAP batch job with two job steps.
The first step is the ABAP program which creates the outbound data file.
The second step is the ftp script which will ftp the file to the external system.
This is the result that we want.
And, for all of you SAP documentation fans, yes, this is documented in SAP. This documentation describes the external command and external program facilities, as well as the authorizations needed to utilize them.
SAP Documentation about using External Commands and External Programs as batch job steps can be found at: https://help.sap.com/saphelp_nw70/helpdata/EN/c4/3a7f2c505211d189550000e829fbbd/content.htm
Hi ,
I do have a report in SAP which gives output in the excel file format. It is run manually now. I tried by scheduling as a batch job, but I am unable to get the excel file. I was looking, is there any way can we run this as a batch job using an external program as dicussed above. Any help is really appreciated.