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

to execute from ABAP code an external Unix program

Former Member
0 Likes
332

HI,

I would like to know how to execute from ABAP code an external Unix program and check for a return code?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
314

HI,

There are different ways to this:

(1) OPEN DATASET <file> FOR OUTPUT 'unix command'

CLOSE DATASET <file>

This command executes the unix command and writes the output into <file>

Look into OSS Note 9391.

(2) or try the following program but unfortunately the command CALL SYSTEM is

not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.

REPORT ZUNIXCOM .

DATA: U_COMMAND(200).

  • Table for system messages

DATA: BEGIN OF RT OCCURS 100 ,

LINE(100) ,

END OF RT .

START-OF-SELECTION .

MOVE 'unix command' to U_COMMAND .

REFRESH RT.

CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND

ID 'TAB' FIELD RT-SYS .

LOOP AT RT.

WRITE : / RT-LINE .

ENDLOOP.

Reward Points if found helpfull..

Cheers,

Chandra Sekhar.

1 REPLY 1
Read only

Former Member
0 Likes
315

HI,

There are different ways to this:

(1) OPEN DATASET <file> FOR OUTPUT 'unix command'

CLOSE DATASET <file>

This command executes the unix command and writes the output into <file>

Look into OSS Note 9391.

(2) or try the following program but unfortunately the command CALL SYSTEM is

not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.

REPORT ZUNIXCOM .

DATA: U_COMMAND(200).

  • Table for system messages

DATA: BEGIN OF RT OCCURS 100 ,

LINE(100) ,

END OF RT .

START-OF-SELECTION .

MOVE 'unix command' to U_COMMAND .

REFRESH RT.

CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND

ID 'TAB' FIELD RT-SYS .

LOOP AT RT.

WRITE : / RT-LINE .

ENDLOOP.

Reward Points if found helpfull..

Cheers,

Chandra Sekhar.