Application Development 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: 

execute unix script from abap.

Former Member
0 Kudos

Hi friends,

I have a abap report which generate a text file in<b> /usr/tmp/</b> directory . Now i have a unix script which encript the text file. I want to this from abap report. How I can do this . and in which path I should keep this unix script Please help.

Regards

4 REPLIES 4

Former Member
0 Kudos

1. You should work with your basis/unix team to determine the path of where to store the UNIX script.

2. Use transaction SM69 to create an external command that points to your UNIX Script. (If you don't have access, your basis team may have to help with this)

3. In your abap program, use function module SXPG_COMMAND_EXECUTE to call the command you cretaed in SM69.

Best Regards,

Chris H.

Former Member
0 Kudos

Hi,

try the below code

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.

Reward points if found helpful……

Cheers,

Chandra Sekhar.

Former Member
0 Kudos

hi,

I have maintain the unix script in SM69 .

type = customer

command name = ZENC

operating system = UNIX

external program = enc.sh

parameters = eft.txt eftdo eftdo

in abap script I am using function SXPG_COMMAND_EXECUTE.

my unix script enc.sh contains the following lines.

echo "hello"

echo $1 $2 $3

java -jar Encryptor.jar $1 $2 $3

Now while runing the abap program is throwing error message.

****

hello

eft.txt eftdo eftdc

The jar file is not found: Encryptor.jar

External program terminated with exit code 1

***

Mys basis person is not sure in which path we should kept this java utility .

At present I have placed my <b>enc.sh and encriptor.jar </b> utility in usr/tmp/ directory.

Please suggest ..

Regasrds

.

0 Kudos

HI,

Can we call a shell script to do operations outside SAP system using SM69 transaction..

I have to archive files out side the SAP system from one folder to another which are mapped to APP server using NFS.

Chaitu