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

Help me please

Former Member
0 Likes
412

Hi all,

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

Reply wil be appreciated,

Varsha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
393

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.

2 REPLIES 2
Read only

Former Member
0 Likes
394

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.

Read only

Former Member
0 Likes
393

Hi Varsha,

DATA: BEGIN OF TABL OCCURS 10.

TEXT(80) TYPE C,

END OF TABL.

DATA: COMMAND(256) TYPE C.

COMMAND = 'ls'.

CALL FUNCTION 'RFC_REMOTE_PIPE' DESTINATION 'SERVER_EXEC'

EXPORTING COMMAND = COMMAND

READ = 'X'

TABLES PIPEDATA = TABL.

LOOP AT TABL.

WRITE:/ TABLE.

ENDLOOP.

Reward points if helpful..

Regards,

Goutham.