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

Calling programs

Former Member
0 Likes
682

Hi all,

I need to call an external program from a program.

Can u give some examples

5 REPLIES 5
Read only

Former Member
0 Likes
662

Hi ,

You can use Submit key word to call external program .

Example code from SAP Help:

SUBMIT REPORT01

VIA SELECTION-SCREEN

USING SELECTION-SET 'VARIANT1'

USING SELECTION-SETS OF PROGRAM 'REPORT00'

AND RETURN.

please award points to helpful answers!

Regards,

Lanka

Read only

Lakshmant1
Active Contributor
0 Likes
662

Hi Jayasree,

Have a look at url

http://www.sap-img.com/abap/ws-execute-to-call-external-program.htm

Check DEMO_LIST_SUBMIT_TO_SPOOL for calling another program within the same program.

Hope this helps.

Thanks

Lakshman

Read only

Former Member
0 Likes
662

An SAP program?

A program on the application server?

A program on the presentation server?

All have different answers.

Rob

Read only

former_member184495
Active Contributor
0 Likes
662

hi,

say you have report zprogram1,

and at run time you want to call report zprogram2,

then use the 'submit' statement in your zprogram1.

Report Zprogram1.

...

submit Zprogram2.

...

and if you want to return to your first program after its execution, then,

Report Zprogram1.

...

submit Zprogram2 and return.

...

cheers,

Aditya.

Read only

naimkhans_babi
Active Participant
0 Likes
662

Hi... see below mantion script...this script can give you some idea,,,

and use SUBMIT keyword.....

bye

PARAMETERS: PROG(70) DEFAULT

'C:\Program Files\Microsoft Office\Office\excel.EXE'.

PARAMETERS: FILE1(70) DEFAULT 'C:\TEMP\TEST.TXT'.

  • Tick to print the Text file after saving from MS

WORDS

PARAMETERS: S_UP AS CHECKBOX.

  • Tick to create new or overwrite Text file

PARAMETERS: S_NEW AS CHECKBOX.

IF S_UP = 'X'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'FILE1'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_OPEN_ERROR = 1.

IF SY-SUBRC = 0.

LOOP AT ITAB.

WRITE: / ITAB.

ENDLOOP.

ELSE.

WRITE: / 'File open error.'.

ENDIF.

ELSE.

IF S_NEW = 'X'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'FILE1'

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

OTHERS = 5.

ENDIF.

CASE SY-SUBRC.

WHEN 1.

WRITE: / 'GUI DOWNLOAD FILE WRITE ERROR'.

WHEN 2.

WRITE: / 'GUI DOWNLOAD NO BATCH'.

WHEN 3.

WRITE: / 'GUI DOWNLOAD GUI REFUSE

FILETRANSFER'.

WHEN 4.

WRITE: / 'GUI DOWNLOAD INVALID TYPE'.

WHEN 5.

WRITE: / 'GUI DOWNLOAD OTHERS'.

ENDCASE.

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

PROGRAM = PROG

COMMANDLINE = 'FILE1'

INFORM = ' '

EXCEPTIONS

FRONTEND_ERROR = 1

NO_BATCH = 2

PROG_NOT_FOUND = 3

ILLEGAL_OPTION = 4

GUI_REFUSE_EXECUTE = 5

OTHERS = 6.

CASE SY-SUBRC.

WHEN 1.

WRITE: / 'FRONTEND ERROR'.

WHEN 2.

WRITE: / 'NO BATCH'.

WHEN 3.

WRITE: / 'PROGRAM NOT FOUND'.

WHEN 4.

WRITE: / 'ILLEGA OPTION'.

WHEN 5.

WRITE: / 'GUI REFUSE EXECUTE'.

WHEN 6.

WRITE: / 'OTHERS'.

ENDCASE.

ENDIF.