Application Development 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 Report

Former Member
0 Kudos

Dear All,

I have a requirement where i need to read the source code of a report into an internal table along with the line number.

We have READ REPORT programname INTO tablename but in this case i will get only the source code.

Ex : If the source code of programname is


       DATA : a TYPE c,                               
              b TYPE c,                               
              c TYPE c.                               
       a = 'A'.                                       
       b = 'B'.                                       
       CONCATENATE a b INTO C.                        
       WRITE: c.                                      

If i do a read report for the above program i will get output in my table as


       TEXT                                          LINENO
       DATA : a TYPE c,                               
              b TYPE c,                               
              c TYPE c.                               
       a = 'A'.                                       
       b = 'B'.                                       
       CONCATENATE a b INTO C.                        
       WRITE: c.                                      

What i need is something like the below.


       TEXT                                          LINENO
       DATA : a TYPE c,                               1
              b TYPE c,                               2
              c TYPE c.                               3
       a = 'A'.                                       4
       b = 'B'.                                       5
       CONCATENATE a b INTO C.                        6
       WRITE: c.                                      7

I dont want to do a loop and add line numbers to each line as it may take time when the souce code is large.

Thanks,

Hari Prasad

5 REPLIES 5

Former Member
0 Kudos

you already have a field called sy-tabix which can give the particular line number any time you need.

what exactly you need with this line number?

former_member209217
Active Contributor
0 Kudos

Hi,

Add one more component to ur internal table which holds the line number

Like, LIneno type i.

Populate sy-tabix into this field.

Regards,

Lakshman.

0 Kudos

lakshman,

he doesnt want to loop again.

Former Member
0 Kudos

Hi ,

Check out this prog , we can easily display the line no .

REPORT  ZDEMO                                   .

TYPES: BEGIN OF T_TYPE,
         LINE(72),
       END OF T_TYPE.

DATA: PROGRAM LIKE SY-REPID VALUE 'YSCR_RPTRD00006_HOT_PICK',
      ITAB    TYPE STANDARD TABLE OF T_TYPE WITH
                            NON-UNIQUE DEFAULT KEY INITIAL SIZE 500 ,
      WA      TYPE T_TYPE.

READ REPORT PROGRAM INTO ITAB.
IF SY-SUBRC = 0.
LOOP AT ITAB INTO WA.
WRITE 😕 sy-tabix ,WA-LINE .
ENDLOOP.
ENDIF.

Regards ,

Rajesh .

0 Kudos

>

> Hi ,

>

> Check out this prog , we can easily display the line no .

>

>

REPORT  ZDEMO                                   .
> 
> TYPES: BEGIN OF T_TYPE,
>          LINE(72),
>        END OF T_TYPE.
> 
> DATA: PROGRAM LIKE SY-REPID VALUE 'YSCR_RPTRD00006_HOT_PICK',
>       ITAB    TYPE STANDARD TABLE OF T_TYPE WITH
>                             NON-UNIQUE DEFAULT KEY INITIAL SIZE 500 ,
>       WA      TYPE T_TYPE.
> 
> READ REPORT PROGRAM INTO ITAB.
> IF SY-SUBRC = 0.
> LOOP AT ITAB INTO WA.
> WRITE 😕 sy-tabix ,WA-LINE .
> ENDLOOP.
> ENDIF.

>

>

> Regards ,

> Rajesh .

You are anyway looping the full report. Which he does not want.