Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Logic to run Unix script file through ABAP program

Former Member
0 Likes
1,947

Hi Friends,

I need to run the Unix script file from abap program, for that user provided file directory of application server.

Is there any logic/FM to run through abap programing.

pls can any one provide logic.

Thanks,

Ravi

5 REPLIES 5
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,381

link:[http://searchsap.techtarget.com/tip/0,289483,sid21_gci774071,00.html]

Read only

0 Likes
1,381

Hi

i could not get the above link information.

can you please provide some more clear.

Read only

0 Likes
1,381

This is the content of the link

Unix Shell scripts along with ABAP can be used to perform many tasks.

These can be used for sending internet mail w/o using SAP Connect,

archiving files, passing data from one system to another, etc.

The following example demonstrates how to use shell script for moving a file

from one folder to another folder. This can be used for archiving the processed files.

Requirement : SAP installed on Unix or

its clones. SAP version 4.0 or above.

Unix Setup to be done by Unix Admin

(1) Create a folder under unix

Eg: /home/ABAP/scripts/

Make sure this folder has Read Write and

Execute permissions.(Mode 777)

(2) Create a file Archive_file.sh in

Unix using any editor.

(2) Type

mv $1 $2

in the file. Make you type the command as shown.

(3)Save it.

(4) Make sure the file has read write

execute permissions (Mode 777)

SAP Configuration

(1) Run transaction SM69

(2) Hit F5 and then Hit F6

(3) Enter Command Name : ZSHELL

(4) Operating System will default to

Unix or HP-UX etc.

(5)Enter Operating System Command : sh

(6)Additional Parameters allowed : X

(7) Save it.

Read only

0 Likes
1,381

report zsrchsap.

*-This is a demo report for Search Sap
*-Author : Sandeep Kulkarni
*-Date : 09/20/2001

parameters : p_sfile(60) lower case
          "File to be moved
          "Eg : /home/in/SFILE1.txt
            p_dfile(60) lower case.
          "File's Destination
          "Eg: /home/archive/SFILE1.txt

data : t_btcxpm
       like btcxpm occurs 0,
       p_addparam 
       like sxpgcolist-parameters.

  concatenate 
  '/home/ABAP/scripts/Archive_file.sh'
  p_sfile
  p_dfile
  into p_addparam separated by space.

  refresh t_btcxpm. clear t_btcxpm.
  call function 'SXPG_CALL_SYSTEM'
    exporting
      commandname = 'ZSHELL'
      additional_parameters = p_addparam
    tables
      exec_protocol = t_btcxpm
    exceptions
      no_permission              = 1
      command_not_found          = 2
      parameters_too_long        = 3
      security_risk              = 4
      wrong_check_call_interface = 5
      program_start_error        = 6
      program_termination_error  = 7
      x_error                    = 8
      parameter_expected         = 9
      too_many_parameters        = 10
      illegal_command            = 11
      others                     = 12.
  if sy-subrc = 0.
    write : / 
    'File',p_sfile,'moved to',p_dfile.
  else.
    write : / 'Error Occured'.
  endif.
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,381

You can also use Function modules below

SXPG_COMMAND_EXECUTE or SXPG_COMMAND_EXECUTE_LONG