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: 

Displaying dynamic No. of blocks in alv

syed_ibrahim5
Active Participant
0 Kudos
200

hi experts,

i have a blocked alv list and the blocks are displayed with respect to the department...i want to display the block alv but i dont know the number of departments so the number of blocks would be dynamic that i will get from the internal table..

i tried to use append block in loop with respect to the department but could not display it..can any one guide me..

with thanks in advance,

syed

9 REPLIES 9

syed_ibrahim5
Active Participant
0 Kudos
105

hi,

this is my code


CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    i_callback_program      = SY-REPID
    i_callback_user_command = 'USER_COMMAND'.

LOOP AT IPUT INTO WPUT.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE WPUT TO <OUTTAB>.
      APPEND <OUTTAB> TO OUTTABLE.
ON CHANGE OF WPUT-DEPARTMENT.
PERFORM APPEND_BLOCK.
REFRESH OUTTABLE.CLEAR OUTTABLE.
ENDON.
CLEAR WPUT.
  ENDLOOP.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
  EXPORTING
    i_interface_check = ' '
  EXCEPTIONS
    program_error     = 1
    OTHERS            = 2.
"perform append _block
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    it_fieldcat                = gt_fieldcatcH[]
    is_layout                  = t_layout
    i_tabname                  = 'OUTTABLE'
    it_events                  = t_event
  TABLES
    t_outtab                   = OUTTABLE
  EXCEPTIONS
    program_error              = 1
    maximum_of_appends_reached = 2
    OTHERS                     = 3.

with thanks in advance,

syed

Edited by: SYED_ibbu on Dec 16, 2010 4:28 AM

Edited by: SYED_ibbu on Dec 17, 2010 11:18 AM

Edited by: SYED_ibbu on Dec 31, 2010 6:45 AM

0 Kudos
105

Try using FM CALL FUNCTION REUSE_ALV_BLOCK_LIST_DISPLAY after REUSE_ALV_BLOCK_LIST_APPEND

Use :

 data : print_layout TYPE slis_print_alv
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
exporting
is_print =  print_layout

Edited by: K.Manas on Dec 31, 2010 6:59 AM

0 Kudos
105

hi manas,

thanks for the reply.

i have actually used list display after block append .I have Called the Block append through subroutine...

Any way Around..

thanks in advance,

syed

0 Kudos
105

Try passing I_INTERFACE_CHECK = 'X'. If you read the FM documentation it says not to use that. IF this fails comment the EXPORTING.

Edited by: K.Manas on Dec 31, 2010 8:49 AM

0 Kudos
105

thanks again,

i tried it but no luck..any other way?

thanks in advance,

syed

0 Kudos
105

Syed,

May be you can check if you are clearing or refreshing your internal table before display. Debug and see if that would be happening.

This is a sample code of using blocks in ALV. Hope this would help you in any way.

[Using Block ALV|http://www.sap-img.com/abap/reuse-alv-block-list-display.htm]

0 Kudos
105

thanks again,

My problem is not displaying the Block ALV but to Display it dynamically.. that is i will not know how many blocks i will need until runtime..so i cannot predefine my no of blocks as in the Code you provide..

for example...if i have 4 departments i need to have four blocks for 4 departments and if 5 means 5 departments

below is my code.


CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    i_callback_program      = SY-REPID
    i_callback_user_command = 'USER_COMMAND'.
 
LOOP AT IPUT INTO WPUT.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE WPUT TO <OUTTAB>.
      APPEND <OUTTAB> TO OUTTABLE.
ON CHANGE OF WPUT-DEPARTMENT."i need to find the no. of blocks with respect to the number of department 
PERFORM APPEND_BLOCK."when there is a change in department a block has to be added..
REFRESH OUTTABLE.CLEAR OUTTABLE."here the value is getting refreshed as it should but if i call reuse alv block list alv before refreshing the the first block appeara then when i click back the 2nd block apperas twice. and 3rd and 4th as such..
ENDON.
CLEAR WPUT.
  ENDLOOP.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
  EXPORTING
    i_interface_check = ' '
  EXCEPTIONS
    program_error     = 1
    OTHERS            = 2.
"perform append _block
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    it_fieldcat                = gt_fieldcatcH[]
    is_layout                  = t_layout
    i_tabname                  = 'OUTTABLE'
    it_events                  = t_event
  TABLES
    t_outtab                   = OUTTABLE
  EXCEPTIONS
    program_error              = 1
    maximum_of_appends_reached = 2
    OTHERS                     = 3.

thanks in advance,

syed

0 Kudos
105

Hi Syed, I have run into the same problem. Have you found a solution to it?

Thanks,

0 Kudos
105

hi hinlai,

no, i have not found a solution ..do post the solution if you found one.

regards,

syed