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: 

How to execute external command from SAP

Former Member
0 Kudos

Hi gurus,

i need to execute an external command from a Sap (rel ECC.5.0) to a server UNIX (no SAP); precisely i have to write a file into a directory in unix server.

I see transaction SM49 and Sm69 but i don't know how can i use these features.

Please coul'd you help me or give me a documentation.

Thank's in advance

Maurizio Ortolani

email. maurizio.ortolani@trilog.it

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
5 REPLIES 5

Former Member
0 Kudos

Hi Maurizio,

i do it in this way:

CONSTANTS: CMD_LS(50) VALUE 'ls -al /transfer/sap'.

*

DATA: BEGIN OF ITAB_LS OCCURS 0,

LINE(200),

END OF ITAB_LS.

*

CALL 'SYSTEM'

ID 'COMMAND' FIELD CMD_LS

ID 'TAB' FIELD ITAB_LS-SYS.

*

How do you write the file, via an UNIX-COMMAND than try the above call

with your command.

Another way is to write the file via OPEN DATASET ..., TRANSFER ... TO ..., CLOSE DATASET.

If you mean this i can give you an example.

Hope it helps.

Regards, Dieter

andreas_mann3
Active Contributor

Former Member
0 Kudos

apart from open dataset.. transfer... close dataset.

u can also use C3GY or C3GZ tcodes.

also the function module SXPG_COMMAND_EXECUTE

Former Member
0 Kudos

Hi everyone,

thank's a lot for your helpful answers.

I try to do this and when i finished i give you a feedback.

Best regards

Maurizio Ortolani

0 Kudos

but u have to maintain those commands in SM69

u can execute using SM49