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

creating code from code

Former Member
0 Likes
971

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.

8 REPLIES 8
Read only

Former Member
0 Likes
921

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

Read only

Sm1tje
Active Contributor
0 Likes
921

This very much sounds like building a query via transaction SQVI, right? Better to use that instead of re-inventing the wheel....

Read only

JoffyJohn
Active Contributor
0 Likes
921

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.

Read only

Former Member
0 Likes
921

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

Read only

former_member222860
Active Contributor
0 Likes
921

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

Read only

0 Likes
921

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

Read only

0 Likes
921

Read ABAP help on INSERT REPORT.

matt

Read only

0 Likes
921

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)