03-30-2009 6:28 AM
Hi Experts,
i need to develop a program which has selection screen to take the input from user like target program name, fields and tables from which the data comes, data selection conditions etc. . On dat basis it will create a new alv program code. Do u guys have any idea?
Thanks.
03-30-2009 6:33 AM
Hi,
Could you please be more specific , do you want to display the code on the alv or create a new program based on the selection
Its pretty simple we can easily do this in both the cases
Regards,
Siddarth
03-30-2009 6:36 AM
This very much sounds like building a query via transaction SQVI, right? Better to use that instead of re-inventing the wheel....
03-30-2009 6:47 AM
Whenever there is a need to generate reports without doing any ABAP coding in a quick span of time, go for ABAP Queries.
The transaction codes associated with ABAP Query are
SQ01 - ABAP Query
SQ02 - Infoset
SQ03 - User group
Or use report painter
Tcode FGRP - It shows a sap menu structure only for report painter/writer.
03-30-2009 6:55 AM
Hi,
If your requirement is creating a report from within a report then its quite easy:
REPORT ZRAJ_DYNAMIC.
DATA: code TYPE TABLE OF rssource-line.
APPEND 'REPORT ZRAJ_DYN1.'
TO code.
APPEND 'WRITE / ''This is a dynamically created report...''.'
TO code.
.............................
(you may append watever code you need to append this way)
.............................
INSERT REPORT 'ZRAJ_DYN1' FROM code.
Hope this helps..
Regards.
Edited by: rajan roy on Mar 30, 2009 8:00 AM
03-30-2009 6:58 AM
If you are looking for dynamic source code generation within the program.
Here's sample code
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).
Mahesh
03-30-2009 8:02 AM
I dont need to generate the code in same program...i need it to make a new program from my existing program..In my existing prog selection screen, it takes the names of required tables and fields which are used in target prog . .this target prog is totally diffrent from existing prog.
Thanks..
Edited by: khan on Mar 30, 2009 1:01 PM
03-30-2009 8:42 AM
03-31-2009 1:06 PM
Use INSERT REPORT <Target Program Name> FROM <internal table> PROGRAM TYPE <pid>
pid indicates whethe the program is Executable program , Function group or function pool , Include program ,M Module pool,Subroutine pool . Try this one
Thanks
Srikanth(sriiiiii)