This source code is an ABAP Program for Execute Unix command from within SAP
REPORT YSMT018A
MESSAGE-ID YL.
* ABAP to append ribesnsl to ribes
* and remove input file using sxpg_command_execute
DATA: FILE1(25) VALUE '/vmedata/???/file1nsl'.
DATA: FILE2(25) VALUE '/vmedata/???/file2'.
DATA: W_MESSAGE(50).
DATA: RLBES LIKE RLBES.
FILE1+9(3) = SY-SYSID.
FILE2+9(3) = SY-SYSID.
* sxpg_command_execute parameters
DATA: REMOVE_FILE LIKE SXPGCOLIST-PARAMETERS.
DATA: PROTOCOL LIKE BTCXPM OCCURS 0.
*
OPEN DATASET FILE2 FOR APPENDING IN TEXT MODE MESSAGE W_MESSAGE.
IF SY-SUBRC NE 0 .
MESSAGE E114 WITH FILE2 W_MESSAGE.
ENDIF.
OPEN DATASET FILE1 FOR INPUT IN TEXT MODE MESSAGE W_MESSAGE.
IF SY-SUBRC NE 0.
MESSAGE E114 WITH FILE1 W_MESSAGE.
ENDIF.
DO.
READ DATASET FILE1 INTO RLBES.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
TRANSFER RLBES TO FILE2.
IF SY-SUBRC NE 0.
MESSAGE E009 WITH FILE2 SY-SUBRC.
ENDIF.
ENDDO.
MESSAGE I114 WITH FILE1 'appended'.
***----------------------------------------------------------------****
DATA: COMMAND3(60)
* VALUE 'rm /vmedata/???/rlbesnsl' .
VALUE 'rm /vmedata/???/file1nsl' .
COMMAND3+12(3) = SY-SYSID.
*submit the unix command remove file1
REMOVE_FILE = COMMAND3+3.
* create y_remove command in sm69
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = 'Y_REMOVE'
* OPERATINGSYSTEM = SY-OPSYS
* TARGETSYSTEM = SY-HOST
* STDOUT = 'X'
* STDERR = 'X'
* TERMINATIONWAIT = 'X'
* TRACE = ' '
ADDITIONAL_PARAMETERS = REMOVE_FILE
* IMPORTING
* STATUS =
TABLES
EXEC_PROTOCOL = PROTOCOL
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
WRONG_ASYNCHRONOUS_PARAMETERS = 12
CANT_ENQ_TBTCO_ENTRY = 13
JOBCOUNT_GENERATION_ERROR = 14
OTHERS = 15.
IF SY-SUBRC = 0.
MESSAGE I114 WITH FILE1 'deleted'.
ENDIF.
Related 10 Sample Programs Tutorials
- ABAP Program for Module Pool containing screen loop processing
- ABAP Program to DIALOGUE FLOW LOGIC
- ABAP Program to Upload table using new function GUI_UPLOAD
- ABAP Program for Output Table Fields to a List
- ABAP Program for Execute Unix command from within SAP
- Source Code of ABAP Program to Browse a file on the application server
- ABAP Program for Submitting report with selection table
- ABAP Program to Get Output in EXCEL
- ABAP Program for Search Layout sets for given String
- ABAP program to send a report to an external mail-id
Most readed SAP Tutorials
- WRITE - Output to a list ( SAP ABAP Keyword)
WRITE ( Output to a list ) is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - List of SAP HR TABLES and Infotypes tables
Detailed full list of tables and infotypes used in SAP HR module. - List of SAP MM Transaction codes
This documentation covers the details of SAP MM Transaction codes - SELECT-OPTIONS ( SAP ABAP Keyword)
SELECT-OPTIONS is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - FI Accounts Receivable and Accounts Payable | SAP FI PDF manual
The following topics are an introduction to the Accounts Receivable and Accounts Payable application components. - SELECT clause ( SAP ABAP Keyword)
SELECT clause is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - SAP MM Process Flow
The typical procurement cycle for a service or material consists of the following phases:
Latest Added SAP documents
- 9KE9 Transaction code
Details about SAP transaction code 9KE9 - 9KE8 Transaction code
Details about SAP transaction code 9KE8 - 9KE7 Transaction code
Details about SAP transaction code 9KE7 - 9KE6 Transaction code
Details about SAP transaction code 9KE6 - 9KE5 Transaction code
Details about SAP transaction code 9KE5 - 9KE4 Transaction code
Details about SAP transaction code 9KE4 - 9KE3 Transaction code
Details about SAP transaction code 9KE3 - 9KE2 Transaction code
Details about SAP transaction code 9KE2 - 9KE1 Transaction code
Details about SAP transaction code 9KE1 - 9KE0 Transaction code
Details about SAP transaction code 9KE0