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

Need to find Sort inside the loop

Former Member
0 Likes
1,718

Hi Experts,

   I need to find in the report where any sort are present inside the loop,we have almost 500 developments so it is impossible to look into it manually.

So we are writing a report to display the list.

Can anyone provide me some sample code for this .

Thanks in advance.

Hi Experts,

   I need to find in the report where any sort are present inside the loop,we have almost 500 developments so it is impossible to look into it manually.

So we are writing a report to display the list.

Can anyone provide me some sample code for this .

Thanks in advance.

4 REPLIES 4
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,230

Did you try report RS_ABAP_SOURCE_SCAN or similar program (use F4) or did you build you own report with statements like READ REPORT, what did you already try, and where are you stuck?

Regards,

Raymond

Read only

0 Likes
1,230

Hi Raymond Giuseppi,

   If we are using standard reports/T-Codes it is displaying all the records of sorts even if it is not inside the loop.

As suggested i had got all the coding lines of the report by using read report after that  once this is successfully we are planning it to extend for select inside loop etc.we don't want to run many times to loops the same internal table.

we are searching for the better way.we are planning to code by using of Keyword:Find all occurence of regex

Thanks.

Read only

Former Member
0 Likes
1,230

Try transaction CODE_SCANNER

Regards,

Pranav

Read only

Former Member
0 Likes
1,230

Hi Vinay,

You could try with below code:

TYPES : BEGIN OF gx_comm,

           name  TYPE char15,

           start TYPE int4,

           end   TYPE int4,

         END OF gx_comm,

         BEGIN OF abapsource,

           line TYPE char255,

         END OF abapsource.

DATA : lt_command TYPE TABLE OF gx_comm,

        lt_loop    TYPE TABLE OF gx_comm,

        lt_read    TYPE TABLE OF gx_comm,

        wa_command LIKE LINE OF lt_command,

        wa_read    LIKE LINE OF lt_read,

        wa_loop    LIKE LINE OF lt_loop,

        lv_line    TYPE int4,

        lv_counter TYPE int4,

        lv_found   TYPE char1,

        lt_source  TYPE TABLE OF abapsource,

        wa_source  LIKE LINE OF lt_source.

FIELD-SYMBOLS : <loop> LIKE LINE OF lt_command.

PARAMETERS : p_report TYPE sobj_name.

READ REPORT p_report INTO lt_source.

LOOP AT lt_source INTO wa_source.

   lv_line = sy-tabix.

   IF wa_source-line CS 'SORT'.

     wa_read-name = 'SORT'.

     wa_read-start = sy-tabix.

     APPEND wa_read TO lt_read.

   ELSEIF wa_source-line CS 'LOOP AT'.

     wa_command-name = 'LOOP'.

     wa_command-start = sy-tabix.

     APPEND wa_command TO lt_command.

     lv_counter = lv_counter + 1.

   ELSEIF wa_source-line CS 'ENDLOOP'.

     READ TABLE lt_command ASSIGNING <loop> INDEX lv_counter.

     IF sy-subrc EQ 0.

       <loop>-end = lv_line.

       APPEND <loop> TO lt_loop.

       DELETE lt_command INDEX lv_counter.

       lv_counter = lv_counter - 1.

     ENDIF.

   ENDIF.

ENDLOOP.

LOOP AT lt_read INTO wa_read.

   LOOP AT lt_loop INTO wa_loop WHERE start LT wa_read-start

                                  AND end GT wa_read-start.

     EXIT.

   ENDLOOP.

   IF sy-subrc EQ 0.

     lv_found = 'X'.

     EXIT.

   ENDIF.

ENDLOOP.



Reagrds,

Pranav