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: 

ALV list/grid in a loop

Former Member
0 Kudos

Experts,

I have requirment where-in i have to display 3 ALV lists in loop.

The field_catlog remains the same for 3 lists but the table data is going to be changed (Ex: based on material no and plant).

As of now it is displaying last set of data on the screen but when i hit back button it shows previous set of data and so on..

is there any way to dispplay evrything at once?

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi, you must use ALV grid Control for doing that. When Creating ALV's with class cl_gui_alv_grid you can Split the screen in three parts and every part can have a different ALV display. If i understood the question wrong please let me know.

Bye.

15 REPLIES 15

Former Member
0 Kudos

Hi, you must use ALV grid Control for doing that. When Creating ALV's with class cl_gui_alv_grid you can Split the screen in three parts and every part can have a different ALV display. If i understood the question wrong please let me know.

Bye.

0 Kudos

I think there is misscommunication.

it is not just 3 lists, it is just set, no' of list-set may vary with input at run time.

i need to display as below:

list1

list2

list3

list11

list22

list33

list111

list222

list333

and on...

but 3 field catlog remains same only data varies...

0 Kudos

Then in that case you call the function

REUSE_ALV_BLOCK_LIST_APPEND in loop, and pass different data to that.

0 Kudos

Thanks Vijay !

do you have any examples for that?

0 Kudos

I tried it long time back, i used Deep structures and passed , and it worked fine in my case. you show me your code. we can see what is wrong.

0 Kudos

Vijay, I could work around that.

what is the No' of lists it displays?

In my case: for less no' of lists it displays very well. and if I'm trying to dispaly more no' of lists it is getting short dump.

0 Kudos

what is the Dump says..

I tried it for 5 or 6 Lists.

How many in your case..?

0 Kudos

You can go upto 29 lists. if it crosses then it gives dump.

REPORT  ztest_block_sub.

TYPE-POOLS: slis.

types: begin of ty_deep_flight,
        flight type sflight_tab1,
       end of ty_deep_flight.
data: it_flight type standard table of ty_deep_flight with header line.

DATA:it_fieldcat  TYPE  slis_t_fieldcat_alv,
     is_layout TYPE slis_layout_alv,
     it_events TYPE  slis_t_event ,
    it_sort TYPE  slis_t_sortinfo_alv .

DATA: wa_fcat LIKE LINE OF it_fieldcat,
      wa_sort LIKE LINE OF it_sort.

DATA: i_flight TYPE sflight_tab1.

SELECT * FROM sflight
INTO TABLE i_flight
UP TO 10 ROWS.

do 29 times.

it_flight-flight = i_flight.
append it_flight.

enddo.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    i_program_name         = sy-repid
    i_structure_name       = 'SFLIGHT'
  CHANGING
    ct_fieldcat            = it_fieldcat
  EXCEPTIONS
    inconsistent_interface = 1
    program_error          = 2.


CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    i_callback_program = sy-repid.

loop at it_flight.          .

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    is_layout                        = is_layout
    it_fieldcat                      = it_fieldcat
    i_tabname                        = '1'
    it_events                        = it_events
   it_sort                          = it_sort
*   I_TEXT                           = ' '
  TABLES
    t_outtab                         = it_flight-flight
 EXCEPTIONS
   program_error                    = 1
   maximum_of_appends_reached       = 2
          .
endloop.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
  .

0 Kudos

Vijay,

But in my case it may exceed 29 lists, in that case how do i handle?

0 Kudos

will some one see that kind of report...?

anyway..if you copy the function REUSE_ALV_BLOCK_LIST_APPEND then change the logic you may get the functionality.

copy of one function may not be sufficient, you should copy other two also. since some data and variables shared by the functions, since all of them are in one function group.

use normal ALV list with group functionality you can get same output. just check that option..

0 Kudos

The thing is for each material i have 3 lists to display (this is the requirement ) . so if i give 10 materials it will work fine (which will have 30 lists to display) but for 11 n more it will not work.

my program restrict the user to 25 materials as of now (then in this case it is not possible to display multi lists i.e it need to display 75 lists), which is not possible.

even if i restrict the user to only 10 materials, the 11 n more materials are run at the background, that is how my code handles.

Kindly let me know, how do i acheive this.

0 Kudos

I think for your requirement, you can use the IT_SORT table of the simple ALV.

FM: REUSE_ALV_LIST_DISPLAY

Parameter: IT_SORT


IA_SORT-SPOS = '01'.
IA_SORT-FIELDNAME = 'MATNR'.
IA_SORT-UP = 'X'.
IA_SORT-GROUP = '*'.  < This will generate a Group on the output
APPEND IA_SORT TO IT_SORT.

* Use FM REUSE_ALV_LIST_DISPLAY to generate the list

You can look at the report FBL5N. It is generating the report based on the Company Code and Customer groups.

Regards,

Naimesh Patel

0 Kudos

Thanks Naimesh , i got it resolved by your answer..

Former Member
0 Kudos

you have to create 3 custom containers and assign the list/grid to these containers.

or check this standard report.

BALVBT01

former_member188685
Active Contributor
0 Kudos

with out looping you can do that using the BLOCK list. it is a simple one.

Need to call the Functions

REUSE_ALV_BLOCK_LIST_INIT "Only once

REUSE_ALV_BLOCK_LIST_APPEND "Three times you need to call for 3 lists

REUSE_ALV_BLOCK_LIST_DISPLAY "Only once