Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic screen generation

Former Member
0 Likes
916

Hello everybody. I have to generate new screen and fields on it at runtime. Does anybody know how to do this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
806

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

4 REPLIES 4
Read only

sridhar_meesala
Active Contributor
0 Likes
806

Hi,

Could you expalin your requirement clearly.

Thanks,

Sri.

Read only

Former Member
0 Likes
807

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

Read only

0 Likes
806

Your answer was helpful but I need create a screen with fields, with flow logic etc. not a selection-screen.

Read only

0 Likes
806

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