File Operations in SAP Application Server (AL11) Using UNIX Command - SAP Blogs
File Operations in SAP Application Server (AL11) Using UNIX Command - SAP Blogs
Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner
About
About
Vishnudas N.M
more by this author
share
0 share
0 tweet share
0 0
like
Follow
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 1/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
Summary
Introduction
UNIX shell
to translate command lines typed at a terminal into system actions. The shell
itself is a program through which other programs are invoked. The shell has
some built-in functions, which it performs directly, but most commands that you
enter cause the shell to execute programs that are external to the shell. This
sets the shell apart from other command interpreters, because it is just another
mechanism for invoking other programs. With Shell we can use standard UNIX
External Commands
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 2/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
Business Scenario
There can be scenarios to perform basic file operations (like move, merge,
Zip, delete etc.) on files generated in AL11 via Open hub destinations or APDs.
Consider that an open hub destination is generating .csv file in AL11. Every time
when you run the DTP for that Open hub it will overwrite the existing file which
was already generated. So if we need to retain the previously generated file,
then every time when a file is generated we can move it to a new file with time
stamp in the file name. There can be a requirement to merge files generated in
AL11 to a single file before sending out of SAP BW. Similarly as a part of data
retention & clean up activity it may be required to delete older files.
In this approach we will create a UNIX script file (UNIX commands for the
file handling operations are written in this file) and access this UNIX script
file through OS command.
Step 1:
Create UNIX script file containing UNIX commands for performing the required
file handling operations.
Write the UNIX script in notepad and save it as .sh file format.
Below provided sample code will merge two files (FILE1 and FILE 2) into a
single file with a new name (MERGERFILE) and timestamp. It will also delete
files with name starting MERGEFILE in AL11 older than 30 days.
Sample code:
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 3/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
*/ Combine the data in FILE1 & FILE2 present the path /var/opt/sapbi/
into a new file and the new file will have name MERGEFILE preceded
by the timestamp at which it was generated.
*/ Files having name starting with MERGEFILE and older than 30 days
present in the path /var/opt/sapbi/ in AL11 will be deleted
cat [path of file1] [path of file2] > [path of merged file] : This command
will merge the mentioned files present in the given path and make a new
merged file in the mentioned path with the given name.
Step 2:
Parameters for operating system command: enter the UNIX script file
path.
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 4/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
FILE1 & FILE2 present in AL11. This may be generated by open hub
destinations or APDs or flat file loads.
Data in FILE1:
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 5/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
Data in FILE2:
Click on Execute button after opening the OS command in SM69 to execute it.
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 6/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
If gzip command is used, then generated file will be zipped and will have
extension as.gz
If this file handling has to be done after the execution of Open hub DTPs or
APD execution or flat file load via process chain, then this can be added in to
the process chain flow.
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 7/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
Inside the process variant enter the OS command Name & details which was
already created.
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 8/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
So when the process chain executes this step, it will trigger the OS command &
which in turn will trigger the UNIX script script.sh and the file handling
operations will be carried out.
Alert Moderator
10 Comments
Suman Chakravarthy K
Nicely explained with screen shots. Thanks for sharing this scenario. It may come
handy whenever I come across this similar scenario.
Matthew Jones
Hi Vishnu,
Good Work, Its a nice that you have shared a document which is realy helpful for us.
Thanks!
Sharmila Selvaraj
Shruti Suresh
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 9/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
Ameya Bobhate
Thank you!
Ninu Sankar
Mohan Babu K J
Hi Vishnu,
Thanks for sharing. Do you have any similar wiki for decrypting gpg file? Im not able
to execute from SM69. Do I need to have Script file for that as well?
Regards,
MB
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 10/11
27/7/2017 File operations in SAP Application server (AL11) using UNIX Command | SAP Blogs
KD Jain
Hi Vishnu,
Very nice document and Thanks for sharing, Definitely it gonna use someday.
Thanks,
KD Jain
Prakash K
Hi Vishnu,
Great work.
BR,
Prakash
Add Comment
https://blogs.sap.com/2014/03/09/file-operations-in-sap-application-server-al11-using-unix-command/# 11/11