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: 

Question about ALV blocking

Former Member
0 Kudos

Hi,

I use theis FM, 'REUSE_ALV_BLOCK_LIST_APPEND', to display my ALV having 2 blocks... i have the sample code below... I need that at every loop pass,,, it will have to display entries in the i_alv_sku at that particular pass...

However, the current scenario is that, it only displays the entries contained in the i_alv_sku for the las loop pass...

Is it possible that it stores the alv for that particular loop pass in the FM and will display everything in it after the last loop pass...

Thanks a lot!

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = v_repid.

Loop at i_mseg.

***Processing to populate i_alv_sku...**

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = i_layout

it_fieldcat = i_fieldcat[]

i_tabname = i_sku_resource

it_events = i_events[]

TABLES

t_outtab = i_alv_sku

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.

Refresh i_alv_sku.

Endloop.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

program_error = 1

OTHERS = 2.

.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Mark...

Currently wat u r doin is ..u r looping into the function module'

"REUSE_BLOCK_LIST_APPEND'...

But ur Function MOdule "REUSE_BLOCK_LIST_DISPLAY"

is called outside your loop....

HEnce at the end of the loop the data which is in the ALV is displayed.

Suppose if u include the same inside the loop,

the same info in the ALV will get displayed repeatedly...

till the loop condition is satisfied

There is no provision where some table can hold data of the ALV & display it together at the end....

Let me know ur requirement....

May be able to help u better....

Thanx,

Navin.

10 REPLIES 10

Former Member
0 Kudos

Hi,

you are refreshing Refresh ' i_alv_sku. ' this table.

Before refreshing you just append this details to some other internal table and then refresh it.

Then pass that new internal table for display.

hope this might help u.

Reward if helpful.

Thanks

Swati.

0 Kudos

Hi,

Thanks so much...

the reason i refreshed that i_alv_sku... is that it's entries should have been already stored in the alv_block fm ready for display... and store again another values for the next block of alv for display with different entries...

Is it possible?

Thanks a lot!

Former Member
0 Kudos

Hi Mark...

Currently wat u r doin is ..u r looping into the function module'

"REUSE_BLOCK_LIST_APPEND'...

But ur Function MOdule "REUSE_BLOCK_LIST_DISPLAY"

is called outside your loop....

HEnce at the end of the loop the data which is in the ALV is displayed.

Suppose if u include the same inside the loop,

the same info in the ALV will get displayed repeatedly...

till the loop condition is satisfied

There is no provision where some table can hold data of the ALV & display it together at the end....

Let me know ur requirement....

May be able to help u better....

Thanx,

Navin.

0 Kudos

Hi Navin,

Thanks so much for your time...

My requirement would be...

At the first loop pass,,, entries in the internal table should be held... and ready for display for the first alv block...

then at the next loop pass... the entries from the previous loop pass of the internal table should be refreshed so that the new entries gathered will be displayed in the next alv block... and so on...

fieldcat and layout of the alv is just the same for every block,,, only the data differs...

Thanks so much... let me know if my requirement is not clear to you... thanks a lot... God bless...

0 Kudos

Hi Mark...

OKie...u can call the alv for display within the loop each time u want to display the ALV whenever i_alv_sku gets populated...

or append the entire data to a new table ..to be dislpayed at the end...

Thanx,

Navin.

0 Kudos

HI Navin,

Thanks for that...

For the 1st soln... the output displays only after clicking the back button one at a time..

Is there anything that can be done to suppress the display and display everything after the loop process?

For teh 2nd soln... it would not meet my requirement since it will display all entries in just one alv block... and not block by block..

thanks a lot!

0 Kudos

Hi Mark, I have noticed few things regarding Blocked ALV. I will share with u . 1. 19 lists can be appended in block mode. If it is crossed ,Exception will be raised. Check in the function module REUSE_ALV_BLOCK_LIST_APPEND expection list. You can see that. In your case you dont know, i_mseg can have records at runtime .This is not suitable for u . It does not work out within LOOP -ENDLOOP. Check this sample program . Developed and checked. It is not working properly. If i clear or refresh after APPEND function module.


REPORT  zvenkat_blocked_alv1.

**********************************************************************
* Declarations.
**********************************************************************

DATA:
      i_0006   TYPE STANDARD TABLE OF pa0006,
      i_0006_1 TYPE STANDARD TABLE OF pa0006.
DATA:
      w_0006   TYPE p0006.
*&---------------------------------------------------------------------*
* ALV Declarations
*----------------------------------------------------------------------*
* Types Pools
TYPE-POOLS:
   slis.
* Types
TYPES:
   t_fieldcat         TYPE slis_fieldcat_alv,
   t_events           TYPE slis_alv_event,
   t_layout           TYPE slis_layout_alv.
* Workareas
DATA:
   w_fieldcat1        TYPE t_fieldcat,
   w_fieldcat2        TYPE t_fieldcat,
   w_fieldcat3        TYPE t_fieldcat,
   w_fieldcat4        TYPE t_fieldcat,
   w_events           TYPE t_events,
   w_layout           TYPE t_layout.
* Internal Tables
DATA:
   i_fieldcat1         TYPE STANDARD TABLE OF t_fieldcat,
   i_fieldcat2         TYPE STANDARD TABLE OF t_fieldcat,
   i_fieldcat3         TYPE STANDARD TABLE OF t_fieldcat,
   i_fieldcat4         TYPE STANDARD TABLE OF t_fieldcat,
   i_events            TYPE STANDARD TABLE OF t_events.

**********************************************************************
* start-of-selection.
**********************************************************************
START-OF-SELECTION.
  PERFORM get_data.

**********************************************************************
* end-of-selection.
**********************************************************************
END-OF-SELECTION.
  PERFORM display_data.
**********************************************************************
* FORM    :  get_data
***********************************************************************
FORM get_data.

  SELECT *
  FROM pa0006
  INTO TABLE i_0006 UP TO 200 ROWS.
  SORT i_0006 BY pernr.

ENDFORM. "get_data
**********************************************************************
* FORM    :  display_data
***********************************************************************
FORM display_data.

  PERFORM build_fieldcatalog USING 'PA0006' CHANGING i_fieldcat1.

  PERFORM display_data_alv.

ENDFORM. "display_data
*&---------------------------------------------------------------------*
*&      Form  display_data_ALV
*&---------------------------------------------------------------------*
FORM display_data_alv .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program = 'ZVENKAT_BLOCKED_ALV'.
  LOOP AT i_0006 INTO w_0006 .
    APPEND w_0006 TO i_0006_1.
    CLEAR w_0006.
    IF sy-tabix < 19.
      PERFORM build_block_list_append TABLES i_0006_1[] USING w_layout i_fieldcat1[] 'I_0006_1' i_events[].
      REFRESH i_0006_1.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
  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.                    " display_data_ALV
*&---------------------------------------------------------------------*
*&      Form  build_block_list_append
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0141   text
*      -->P_0142   text
*      -->P_0143   text
*      -->P_0144   text
*----------------------------------------------------------------------*
FORM build_block_list_append  TABLES outtab USING  layout fieldcat tabname events .


  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = layout
      it_fieldcat                      = fieldcat
      i_tabname                        = tabname
      it_events                        = events
    TABLES
      t_outtab                         = outtab
*   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.
ENDFORM.                    " build_block_list_append
*&---------------------------------------------------------------------*
*&      Form  build_fieldcatalog
*&---------------------------------------------------------------------*

FORM build_fieldcatalog  USING    structure CHANGING i_fieldcat1.
  DATA:
        program TYPE sy-repid.
  program = sy-repid.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name   = program
      i_structure_name = structure
    CHANGING
      ct_fieldcat      = i_fieldcat1.
  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.                    " build_fieldcatalog
Regards, Venkat.O

0 Kudos

HI Venkat....

I think we really have the same requirement... We have almost the same logic in the program... Since I also put the block_append_alv inside loop-endloop...

I want to know, what have you done in order to meet this requirement? Please share...

Thanks so much...

Former Member
0 Kudos

hi..

after each loop pass for the alv refersh it...

without it the prevoius data would be stored in it....

then pass the next loop...

thanks..

Former Member
0 Kudos

Hi,

FM 'REUSE_ALV_BLOCK_LIST_APPEND' always works for an internal table.

Consider the blocks as one individual internal table.

So basically make sure that the internal tables are populated first & then passed to 'REUSE_ALV_BLOCK_LIST_APPEND' which will be appended to the main itab which u are using for final display using 'REUSE_ALV_BLOCK_LIST_DISPLAY' .

Thanks

SMS