Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem regarding ALV block list...

Hello Experts, 

I am currently developing a report wherein I need to display 3 different tables but the
catch is, I need to replicate those 3 tables depending on the sort criteria. Lets
say I have a sort criteria by company code(BUKRS) and in my tables I have 3 company codes. So
what I need to do is to display 3 ALV blocks per company code so in my case I need to
display 9 ALV blocks because per company =  3 display. 

My problem is only the last company code is being displayed. Below is my code:

*   Initialize ALV
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        i_callback_program = gv_repid.
*        I_CALLBACK_PF_STATUS_SET       = ' '
*        I_CALLBACK_USER_COMMAND        = ' '
*        IT_EXCLUDING                   =

*   Prepare fields of internal tables for fieldcatalog
    DO lv_lines TIMES.
      ADD 1 TO lv_tabix.
      LOOP AT lt_itab_name INTO wa_itab_name.
        CALL METHOD cl_abap_structdescr=>describe_by_name
          EXPORTING
            p_name         = wa_itab_name-itab_name
          RECEIVING
            p_descr_ref    = lcl_typedescr
          EXCEPTIONS
            type_not_found = 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.

        REFRESH lt_components.
        lcl_structdescr ?= lcl_typedescr.
        lt_components = lcl_structdescr->components.

        me->prepare_components( ).
        me->build_layout( ).
        me->set_print( ).
        me->build_events( ).

        ASSIGN (wa_itab_name-itab_name2) TO <fs_itab>.

        CASE 'X'.
          WHEN rb_bukrs.
            READ TABLE lcl_process_data=>gt_sort_crit ASSIGNING <fs_sort_crit>
                                                      INDEX lv_tabix.
            IF sy-subrc = 0.
              CASE wa_itab_name-itab_name2.
                WHEN 'LT_OUTPUT_ACQ'.
                  lt_output_acq[] = lt_output_acq_dum[].
                  DELETE lt_output_acq WHERE bukrs <> <fs_sort_crit>-bukrs.
                WHEN 'LT_OUTPUT_RET'.
                  lt_output_ret[] = lt_output_ret_dum[].
                  DELETE lt_output_ret WHERE bukrs <> <fs_sort_crit>-bukrs.
                WHEN 'LT_OUTPUT_NET'.
                  lt_output_net[] = lt_output_net_dum[].
                  DELETE lt_output_net WHERE bukrs <> <fs_sort_crit>-bukrs.
              ENDCASE.
            ENDIF.
          WHEN rb_kostl.
            READ TABLE lcl_process_data=>gt_sort_crit ASSIGNING <fs_sort_crit>
                                                      INDEX lv_tabix.
            IF sy-subrc = 0.
              CASE wa_itab_name-itab_name2.
                WHEN 'LT_OUTPUT_ACQ'.
                  lt_output_acq[] = lt_output_acq_dum[].
                  DELETE lt_output_acq WHERE kostl <> <fs_sort_crit>-kostl.
                WHEN 'LT_OUTPUT_RET'.
                  lt_output_ret[] = lt_output_ret_dum[].
                  DELETE lt_output_ret WHERE kostl <> <fs_sort_crit>-kostl.
                WHEN 'LT_OUTPUT_NET'.
                  lt_output_net[] = lt_output_net_dum[].
                  DELETE lt_output_net WHERE kostl <> <fs_sort_crit>-kostl.
              ENDCASE.
            ENDIF.
        ENDCASE.

*       Append internal table for ALV block            
        me->call_alv_block_fm(                          "<---This is where I append the internal tables
              EXPORTING
                im_itab_name = wa_itab_name-itab_name2
                im_itab      = <fs_itab> ).
      ENDLOOP.
    ENDDO.

    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.
Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question