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: 

how to use REUSE_ALV_BLOCK_LIST_APPEND in loop

Former Member
0 Kudos

Hi Experts,

     I would like to use the  REUSE_ALV_BLOCK_LIST_APPEND in my report for multiple times depend on the selection data, I use it in the loop but it show only one ALV.

20 REPLIES 20

Former Member

0 Kudos

Hi Juan,

          The link doesn't show REUSE_ALV_FIELDCATALOG_MERGE use in the loop, I need to use it in loop end loop statement to show multiple table

Former Member
0 Kudos

Hi Ashwin,

To use multiple ALVs in the list display, first you to initialize the ALV using,

REUSE_ALV_BLOCK_LIST_INIT.

Then in LOOP, use your FM REUSE_ALV_BLOCK_LIST_APPEND for different tables which you want to use.

After ENDLOOP. finally use the Function Module, REUSE_ALV_BLOCK_LIST_DISPLAY.

Hope this solves your purpose.

Regards,

Sumit

0 Kudos

Yes you are right this is the way I am following but how to create table in the loop dynamically that I am not getting, for every loop we need to pass different table then only it will be display otherwise in the same table complete data will be display

0 Kudos

Come on man.... You have to have an internal table which is having numbers. Loop at that table and for first passof the loop, pass itab1, for second pass itab2 ans so on.

First determine how many tables would be there, then either use dynamic table, or use DO ENDDO, with a variable count.

DO.

count = count+1.

case count.

when 1.

pass itab1.

when 2.

pass itab2.

exit the loop when count reaches, the number of tables.

ENDDO.

0 Kudos

Come on man.... You have to have an internal table which is having numbers. Loop at that table and for first passof the loop, pass itab1, for second pass itab2 ans so on.

First determine how many tables would be there, then either use dynamic table, or use DO ENDDO, with a variable count.

DO.

count = count+1.

case count.

when 1.

pass itab1.

when 2.

pass itab2.

exit the loop when count reaches, the number of tables.

ENDDO.

0 Kudos

Hi Sumit,

     I appreciate you are help, but as you say in this case I do no know how many internal table I should create , I need to display the RFQ against the material that mean the no of internal table is completely dynamic , now if I make it dynamic with field symbol I need to pass the internal table name to the function module REUSE_ALV_BLOCK_LIST_APPEND how would I know the internal table name since its dynamic   

0 Kudos

This message was moderated.

Former Member
0 Kudos

Have a look at program BCALV_TEST_BLOCK_LIST.

In selection screen, "Number of Lists" value determine how many lists will be shown in output.

0 Kudos

Hi thanks

     In this program no of internal table are fix but in my case the no of internal table are completely dynamic, in the loop the no of internal table should be created and pass to this function module

0 Kudos

Here is what you need to do.

Create an internal table that has dictionary table name, and references to internal table of that type.

TYPES:

BEGIN OF ty_dyn,

  tabname TYPE dd02l-tabname,

  tabref  TYPE REF TO data,

END OF ty_dyn.

DATA: lt_dyn TYPE TABLE OF ty_dyn,

      ls_dyn TYPE ty_dyn.

ls_dyn-tabname = 'SFLIGHT'.

GET REFERENCE OF lt_sflight INTO ls_dyn-tabref.

APPEND ls_dyn TO lt_dyn.

ls_dyn-tabname = 'SCARR'.

GET REFERENCE OF lt_scarr INTO ls_dyn-tabref.

APPEND ls_dyn TO lt_dyn.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

LOOP AT lt_dyn INTO ls_dyn.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    i_structure_name = ls_dyn-tabname

Assign ls_dyn-tabref->* to <fs>.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    i_tabname = ls_dyn-tabname

    t_outtab = <fs>

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

0 Kudos

Solve by myself with creating the 50 Internal tables

close the thread

0 Kudos

Hi thanks for the reply, I find another way for this

0 Kudos

Hi Ashwin,

You just post the solution and mark that as correct answer. Because this may be useful to someone  have the same problem.

Regards,

John.

0 Kudos

Dear Manish ji,

                   I have the requirement to display ALV Block, i have one table in which i have multiple  header items. another table in which i have items data for these header items.

Now My requirement is Header Field catalog will come first then one line of  header item

After that Line items field catalog and its items suppose 3 items for one header item.

Suppose i have ten Items in Header & 20 Items in Items details table, so it means it will repeat 10 times.

Kindly check my code & suggest me the changes.

FORM sub_alv_display .

   is_layout-zebra ='X'.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

    EXPORTING

      i_callback_program             = sy-repid

*    I_CALLBACK_PF_STATUS_SET       = ' '

*    I_CALLBACK_USER_COMMAND        = ' '

*    IT_EXCLUDING                   =

            .

  BREAK-POINT.

  loop at gt_final into gs_final.

   CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

      is_layout                        = is_layout

      it_fieldcat                      = it_fieldcat1

      i_tabname                        = 'GT_FINAL'

      it_events                        = it_event

*    IT_SORT                          =

*    I_TEXT                           = ' '

    tables

      t_outtab                         = gt_final

   EXCEPTIONS

     PROGRAM_ERROR                    = 1

     MAXIMUM_OF_APPENDS_REACHED       = 2

     OTHERS                           = 3

            .

  IF sy-subrc <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

loop at it_final into is_final where belnr = gs_final-belnr.

 

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

      is_layout                        = is_layout

      it_fieldcat                      = it_fieldcat

      i_tabname                        = 'IT_FINAL'

      it_events                        = it_event

*    IT_SORT                          =

*    I_TEXT                           = ' '

    tables

      t_outtab                         = it_final

   EXCEPTIONS

     PROGRAM_ERROR                    = 1

     MAXIMUM_OF_APPENDS_REACHED       = 2

     OTHERS                           = 3

            .

  IF sy-subrc <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

endloop.

Clear IS_final.

  ENDLOOP.


  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

*  EXPORTING

*    I_INTERFACE_CHECK             = ' '

*    IS_PRINT                      =

*    I_SCREEN_START_COLUMN         = 0

*    I_SCREEN_START_LINE           = 0

*    I_SCREEN_END_COLUMN           = 0

*    I_SCREEN_END_LINE             = 0

*  IMPORTING

*    E_EXIT_CAUSED_BY_CALLER       =

*    ES_EXIT_CAUSED_BY_USER        =

   EXCEPTIONS

     PROGRAM_ERROR                 = 1

     OTHERS                        = 2

            .

  IF sy-subrc <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

ENDFORM.                    " sub_alv_display

I am getting this output.


0 Kudos

This should have been posted as a new discussion or question.

Your requirement is more suited for ALV Hierarchical list, and not ALV Block list.

Check out demo program BCALV_TEST_HIERSEQ_LIST.

0 Kudos

Dear Manish,

                Thanks for your reply, is it possible to do this without using <fs> in my report. Please suggest me.

Thanks & regards,

0 Kudos

Your query should have been posted as a new discussion or question.

BCALV_TEST_HIERSEQ_LIST does not use <fs>

<fs> is mentioned in my previous reply, but that is for ALV block lists in loop, which is not suitable for your requirement.

mayur_priyan
Active Participant
0 Kudos

This message was moderated.

Former Member
0 Kudos

This message was moderated.