*Generating Transient program
DATA : itab TYPE TABLE OF string,
prog TYPE program,
msg(120) TYPE c,
lin(10) TYPE c,
wrd(10) TYPE c,
off(3) TYPE c.
APPEND 'PROGRAM SUBPOOL.' TO itab.
APPEND 'FORM DYN1.' TO itab.
APPEND 'WRITE :/ ''I AM A TEMPORARY SUBROUTINE''.' TO itab.
APPEND 'ENDFORM.' TO itab.
GENERATE SUBROUTINE POOL itab NAME prog MESSAGE msg LINE lin WORD wrd OFFSET off.
*This statement creates a subroutine pool in the main memory area of the running prog
*You pass the source code of the subroutine pool in internal table <itab>.
* The statement returns the name of the generated subroutine pool in field <prog> .
IF sy-subrc <> 0.
WRITE :/ 'ERROR DURING GENERATION OF LINE ', LIN,
/ MSG,
/ 'WORD:', WRD, 'AT OFFSET :', OFF.
ENDIF.
WRITE :/ 'SUBROUTINE POOL NAME=', PROG.
PERFORM dyn1 IN PROGRAM (prog).
_____________________________________________________________________________________
*Generating Persistent Program Programatically
data : itab TYPE TABLE OF string.
CONSTANTS : rep(40) VALUE 'ZDYN_PRO'.
APPEND 'PROGRAM ZDYN_PRO.' TO ITAB.
APPEND 'WRITE :/ '' I AM DYNAMICALLY CREATED ''. ' TO ITAB.
INSERT REPORT REP FROM ITAB.
*above transfers the new executable pgm (ZDYN_PRO)into the program library
SUBMIT (REP) AND RETURN.
____________________________________________________________________________________
No comments:
Post a Comment