*&———————————————————————*
*& Report ZTEST_TRANSIENT_SUBROUTINE
*&
*&———————————————————————* REPORT ZTEST_TRANSIENT_SUBROUTINE. DATA:
code type TABLE OF string,
subrtnm(10) type c,
prog type program,
msg(20) type c,
line(10) type c,
word(10) type c,
off(3) type c,
lw_string type string. “ for concatenate * prepare the ”Dynamic Subroutine sentence”
append ‘PROGRAM SUBPOOL.’ to code. subrtnm = ‘TEST’.
CONCATENATE ‘FORM’ subrtnm ‘.’ into lw_string SEPARATED BY space.
“CONCATENATE ’FORM’ ’TEST’ ’.’ into lw_string SEPARATED BY space.
APPEND lw_string to code. append ‘Write:/10 ”This is one transient subroutine”.’ to code. APPEND ‘ENDFORM.’ to code. * create subroutine dynamically
GENERATE SUBROUTINE POOL code NAME prog MESSAGE msg LINE lineWORD word OFFSET off.
IF sy-subrc <> 0 .
write:/ ‘Error occurs in line:’,line,
/ msg,
/‘Word:’, word,
/ ‘Offset:’, off.
ENDIF. * call the subroutine dynamically
PERFORM (subrtnm) IN PROGRAM (prog). |