Submit abap program and gets output from memory



User Rating:  / 0
PoorBest 
Details
Category: ABAP
Created on Monday, 02 July 2012 09:06
Last Updated on Monday, 02 July 2012 09:09
Published on Monday, 02 July 2012 09:06
Written by Administrator
Hits: 8192

The following program runs an abap program and gets the output list from memory into internal table :

program EXEC_CMD

View source
report ztest_submit.
*&---------------------------------------------------------------------*
*&     www.developerpages.gr
*&
*&---------------------------------------------------------------------*
 
 
SUBMIT ZEXEC_CMD
*          with par1 = ''           " Parameters
                          EXPORTING LIST TO MEMORY AND RETURN.
PERFORM write_list.
 
 
*&---------------------------------------------------------------------*
*&      Form  WRITE_LIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM WRITE_LIST.
  DATA : BEGIN OF MYLIST1 OCCURS 100.
          include structure ABAPLIST.
  DATA : END OF MYLIST1.
 
 
  DATA: BEGIN OF DOWNTAB OCCURS 1,
           LINE(255),
         END OF DOWNTAB.
 
  CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
      LISTOBJECT = MYLIST1
    EXCEPTIONS
      NOT_FOUND  = 1
      OTHERS     = 2.
 
  CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
      LISTASCI   = DOWNTAB
      LISTOBJECT = MYLIST1.
 
  LOOP AT DOWNTAB.
    WRITE :/ DOWNTAB-LINE.
  ENDLOOP.
 
 
  CLEAR MYLIST1. REFRESH MYLIST1.
  CLEAR DOWNTAB. REFRESH DOWNTAB.
 
ENDFORM.                    "WRITE_LIST