03-10-2009 10:33 AM
Hi,
sorry if it's a noob question but I didn't use to develop since à long time.
I remember that there was a way to generate dynamic ABAP source code.
Fro example, generate the source code of an ABAP form depending on input parameters.
I do not remember exactly how it worked, I think that was something like that :
- you do à form that generate à string variable
- you pass the string variable + a form name too a standard function module
- the standard function module generate a form that contain the code in string variable
Please help,
Regards
Morgan
03-10-2009 11:14 AM
Hey Morgan,
Here's the logic for dynamic program generation
Report z_dynamic.
data: begin of itab occurs 0,
line(150),
end of itab.
data: v_name like sy-repid.
parameters: p_table like dd02l-tabname.
itab-line = 'Report sy-repid.'.
append itab. clear itab.
itab-line = 'tables:'.
append itab. clear itab.
concatenate p_table '.' into itab.
itab-line = 'data: begin of itab occurs 0.'.
append itab. clear itab.
concatenate 'include structure' p_table '.' into itab separated by space.
itab-line = 'data:end of itab.'.
append itab. clear itab.
itab-line = 'form f_select.'.
append itab. clear itab.
itab-line = 'select * into table itab'.
append itab. clear itab.
concatenate 'FROM' p_table '.' INTO itab separated by space.
itab-line = 'endform.'.
append itab. clear itab.
generate subroutine pool itab name v_name.
perform f_select in program (v_name).
thanks\
Mahesh
03-10-2009 11:14 AM
Hey Morgan,
Here's the logic for dynamic program generation
Report z_dynamic.
data: begin of itab occurs 0,
line(150),
end of itab.
data: v_name like sy-repid.
parameters: p_table like dd02l-tabname.
itab-line = 'Report sy-repid.'.
append itab. clear itab.
itab-line = 'tables:'.
append itab. clear itab.
concatenate p_table '.' into itab.
itab-line = 'data: begin of itab occurs 0.'.
append itab. clear itab.
concatenate 'include structure' p_table '.' into itab separated by space.
itab-line = 'data:end of itab.'.
append itab. clear itab.
itab-line = 'form f_select.'.
append itab. clear itab.
itab-line = 'select * into table itab'.
append itab. clear itab.
concatenate 'FROM' p_table '.' INTO itab separated by space.
itab-line = 'endform.'.
append itab. clear itab.
generate subroutine pool itab name v_name.
perform f_select in program (v_name).
thanks\
Mahesh
03-10-2009 11:15 AM
03-10-2009 11:43 AM