From ancient days I used to hear that ABAP is the language which is only used to develop business transaction, it’s not at all Developer friendly langauge. So if you want to do your R&D or want to develop something out of the BOX application put your focus to C/C++ or “the king of programming” JAVA. One can ask counter question here saying “Dude, ABAP is Business language its not developed for developing something out of BOX transaction.
Now let’s not get into the Fight mode J
This article talks about one of such out of the BOX solution you can provide to your client if they ask for the same.
How to Execute the EXE file from your transaction?
There are many ways you can achive this functionality.
- you can use standard class for front end services CL_GUI_FRONTEND_SERVICES .
- try a function module GUI_RUN .
Both use shell script internally to execute the command at system level.Unix shell scripts along with ABAP can be used to perform many tasks. These can be used for sending internet mail w/o using SAP Connect, archiving files, passing data from one system to another, etc.
Below is the sample code which is used to open calculator and notepad from the abap report program. You can pass any command which is valid in command promt.
Note : for Function module GUI_RUN its says it’s valid for 32 bits system . But It goes smooth for 64 bits tooo J
REPORT ZTEST_EXE.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text–001.
SELECTION-SCREEN PUSHBUTTON /10(10) bt_calc USER-COMMAND CALC.
SELECTION-SCREEN PUSHBUTTON /10(10) bt_note USER-COMMAND NOTE.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
MOVE ‘Calc’ TO bt_calc.
MOVE ‘Notepad’ TO bt_note.
START–OF–SELECTION.
END–OF–SELECTION.
at SELECTION–SCREEN.
case sy–ucomm.
when ‘CALC’.
CALL FUNCTION ‘GUI_RUN’
EXPORTING
COMMAND = ‘CALC.EXE’.
* PARAMETER = ‘c:\TEST.TXT’
** CD = ‘
* IMPORTING
* RETURNCODE = lv_return.
when ‘NOTE’.
CALL FUNCTION ‘GUI_RUN’
EXPORTING
COMMAND = ‘NOTEPAD.EXE’
PARAMETER = ‘c:\TEST.TXT’.
* CD = ‘
* IMPORTING
* RETURNCODE = lv_return.
ENDCASE.
When you execute it, click on the Button Calc to open calculator and notepad to open notepad.