‎2009 Sep 04 6:53 AM
Hello everybody. I have to generate new screen and fields on it at runtime. Does anybody know how to do this?
‎2009 Sep 04 8:55 AM
I had implemented similar thing 6 months back.
I am giving some guideline to fulfill your requirements.
1. There will be include in your main program, say ZMAIN which will be filled by another program, say ZCONTROL.
2. You will fill include (which will contain dynamic code for your selection screen) in ZCONTROL and submit ZMAIN from ZCONTROL
REPORT ZMAIN.
include zdyn_screen. (include it in your main program)
....
Report ZCONTROL.
data : gt_code TYPE TABLE OF string,
wa_code type string,
c_prog type sy-repid.
wa_code = 'Parameters : test type matnr.'.
append wa_code to gt_code.
c_prog = 'ZDYN_SCREEN'.
insert report c_prog from gt_code.
commit work.
SUBMIT ZMAIN AND RETURN.
* Clear up the screen as you exit.
REFRESH GT_CODE.
READ REPORT C_PROG INTO GT_CODE.
* You may insert some check if your want OR you can omit the step of reading report
refresh gt_code.
insert report c_prog from gt_code.Remember, you may need much more logic to handle various scenarios.
To get the text from your dictionary field for your selection screen parameters / select-options you can also use code
INSERT TEXTPOOL
To check syntax before inserting code into your include, you can try SYNTAX-CHECK or use FM EDITOR_SYTAX_CHECK.
Regards,
Mohaiyuddin
‎2009 Sep 04 8:19 AM
‎2009 Sep 04 8:55 AM
I had implemented similar thing 6 months back.
I am giving some guideline to fulfill your requirements.
1. There will be include in your main program, say ZMAIN which will be filled by another program, say ZCONTROL.
2. You will fill include (which will contain dynamic code for your selection screen) in ZCONTROL and submit ZMAIN from ZCONTROL
REPORT ZMAIN.
include zdyn_screen. (include it in your main program)
....
Report ZCONTROL.
data : gt_code TYPE TABLE OF string,
wa_code type string,
c_prog type sy-repid.
wa_code = 'Parameters : test type matnr.'.
append wa_code to gt_code.
c_prog = 'ZDYN_SCREEN'.
insert report c_prog from gt_code.
commit work.
SUBMIT ZMAIN AND RETURN.
* Clear up the screen as you exit.
REFRESH GT_CODE.
READ REPORT C_PROG INTO GT_CODE.
* You may insert some check if your want OR you can omit the step of reading report
refresh gt_code.
insert report c_prog from gt_code.Remember, you may need much more logic to handle various scenarios.
To get the text from your dictionary field for your selection screen parameters / select-options you can also use code
INSERT TEXTPOOL
To check syntax before inserting code into your include, you can try SYNTAX-CHECK or use FM EDITOR_SYTAX_CHECK.
Regards,
Mohaiyuddin
‎2009 Sep 04 11:44 AM
Your answer was helpful but I need create a screen with fields, with flow logic etc. not a selection-screen.
‎2009 Sep 04 11:51 AM
Still the concept will be same.
In main program you write
CALL SCREEN 100.
In screen 100, you define a subscreen which can be filled in dynamic include similar to selection screen.
You creaet PBO and PAI dynamically in another include. (you can do it in same dynamic include, but it would be more easy to use to different dynamic include to do so. Alternatively, you can create dynamic SUBROUTINE-POOL - refer help on GENERATE SUBROUTINE-POOL)
Regards,
Mohaiyuddin