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: 

Block alv output

Former Member
0 Kudos

Hi ,

The below is the code from saptechinical and have tried to execute by making some changes to get the block alv output.

but i am unable to get o/p for the code.Please let me know if any mistake i commited or anything i need to change to get the desired o/p.

*&---------------------------------------------------------------------*

*& Report  Z102267_BLOCKALV2

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  Z102267_BLOCKALV2.

type-POOLs:slis.

TYPES: BEGIN OF ty_mara,

       matnr TYPE mara-matnr,

      matkl TYPE mara-matkl,

   END OF ty_mara.

TYPES: BEGIN OF ty_marc,

       matnr TYPE marc-matnr,

      werks TYPE marc-werks,

      END OF ty_marc.

TYPES : BEGIN OF ty_makt,

       matnr TYPE makt-matnr,

      maktx TYPE makt-maktx,

    END OF ty_makt.

DATA: it_mara TYPE TABLE OF ty_mara,

      wa_mara TYPE ty_mara.

DATA: it_marc TYPE TABLE OF ty_marc,

      wa_marc TYPE ty_marc.

DATA: it_makt TYPE TABLE OF ty_makt,

      wa_makt TYPE ty_makt.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.

  SELECT-OPTIONS: s_matnr for wa_mara-matnr.

  SELECTION-SCREEN END OF BLOCK B1.

DATA:it_fieldcat TYPE slis_t_fieldcat_alv,

     wa_fieldcat TYPE slis_fieldcat_alv.

DATA:v_layout TYPE slis_layout_alv.

DATA: wa_events TYPE slis_alv_event,

      it_events1 TYPE slis_t_event,

      it_events2 TYPE slis_t_event,

      it_events3 TYPE slis_t_event.

DATA:it_fieldcat_mara TYPE slis_t_fieldcat_alv,

     it_fieldcat_marc TYPE slis_t_fieldcat_alv,

     it_fieldcat_makt TYPE slis_t_fieldcat_alv.

START-OF-SELECTION.

SELECT matnr matkl FROM mara into TABLE it_mara WHERE matnr IN s_matnr.

   IF it_mara is NOT INITIAL.

     SELECT matnr werks FROM marc INTO TABLE it_marc FOR ALL ENTRIES IN it_mara WHERE matnr = it_mara-matnr.

       SELECT matnr maktx FROM makt INTO TABLE it_makt FOR ALL ENTRIES IN it_mara WHERE matnr = it_mara-matnr

         AND spras = sy-langu.

   ENDIF.

   end-of-SELECTION.

  PERFORM top_pag1.

   PERFORM top_pag2.

   PERFORM top_pag3.

    PERFORM buildfieldcatlog.

   CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

     EXPORTING

       i_callback_program             = sy-repid.

*      I_CALLBACK_PF_STATUS_SET       = ' '

*      I_CALLBACK_USER_COMMAND        = ' '

*      IT_EXCLUDING                   = IT_EXCLUDING

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

  EXPORTING

    is_layout                        = v_layout

    it_fieldcat                      = it_fieldcat_mara

    i_tabname                        = 'MARA'

    it_events                        = it_events1

*   IT_SORT                          = IT_SORT

*   I_TEXT                           = ' '

  TABLES

    t_outtab                         = it_mara

* EXCEPTIONS

*   PROGRAM_ERROR                    = 1

*   MAXIMUM_OF_APPENDS_REACHED       = 2

          .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

      is_layout                        = v_layout

      it_fieldcat                      = it_fieldcat_marc

      i_tabname                        = 'MARC'

      it_events                        = it_events2

*     IT_SORT                          = IT_SORT

*     I_TEXT                           = ' '

    TABLES

      t_outtab                         = it_marc

*   EXCEPTIONS

*     PROGRAM_ERROR                    = 1

*     MAXIMUM_OF_APPENDS_REACHED       = 2

            .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

    EXPORTING

      is_layout                        = v_layout

      it_fieldcat                      = it_fieldcat_makt

      i_tabname                        = 'MAKT'

      it_events                        = it_events3

*     IT_SORT                          = IT_SORT

*     I_TEXT                           = ' '

    TABLES

      t_outtab                         = it_makt

*   EXCEPTIONS

*     PROGRAM_ERROR                    = 1

*     MAXIMUM_OF_APPENDS_REACHED       = 2

            .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

*   EXPORTING

*     I_INTERFACE_CHECK             = ' '

*     IS_PRINT                      = 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       = E_EXIT_CAUSED_BY_CALLER

*     ES_EXIT_CAUSED_BY_USER        = ES_EXIT_CAUSED_BY_USER

*   EXCEPTIONS

*     PROGRAM_ERROR                 = 1

            .

*&---------------------------------------------------------------------*

*&      Form  BUILDFIELDCATLOG

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

form BUILDFIELDCATLOG .

  wa_fieldcat-col_pos = 1.

  wa_fieldcat-fieldname = 'MATNR'.

  wa_fieldcat-ref_tabname = 'MARA'.

  APPEND wa_fieldcat to it_fieldcat_mara.

  CLEAR wa_fieldcat.

   wa_fieldcat-col_pos = 2.

  wa_fieldcat-fieldname = 'MATKL'.

  wa_fieldcat-ref_tabname = 'MARA'.

  APPEND wa_fieldcat to it_fieldcat_mara.

  CLEAR wa_fieldcat.

   wa_fieldcat-col_pos = 1.

  wa_fieldcat-fieldname = 'MATNR'.

  wa_fieldcat-ref_tabname = 'MARA'.

  APPEND wa_fieldcat to it_fieldcat_marc.

  CLEAR wa_fieldcat.

   wa_fieldcat-col_pos = 2.

  wa_fieldcat-fieldname = 'WERKS'.

  wa_fieldcat-ref_tabname = 'MARC'.

  APPEND wa_fieldcat to it_fieldcat_marc.

  CLEAR wa_fieldcat.

   wa_fieldcat-col_pos = 1.

  wa_fieldcat-fieldname = 'MATNR'.

  wa_fieldcat-ref_tabname = 'MARA'.

  APPEND wa_fieldcat to it_fieldcat_makt.

  CLEAR wa_fieldcat.

   wa_fieldcat-col_pos = 2.

  wa_fieldcat-fieldname = 'MATKX'.

  wa_fieldcat-ref_tabname = 'MAKT'.

  APPEND wa_fieldcat to it_fieldcat_makt.

  CLEAR wa_fieldcat.

  wa_events-name = 'TOP-OF-PAGE'.

  wa_events-form = 'top_pag1'.

  APPEND wa_events to it_events1.

  CLEAR wa_events.

  wa_events-name = 'TOP-OF-PAGE'.

  wa_events-form = 'top_pag2'.

  APPEND wa_events to it_events2.

  CLEAR wa_events.

  wa_events-name = 'TOP-OF-PAGE'.

  wa_events-form = 'top_pag3'.

  APPEND wa_events to it_events3.

  CLEAR wa_events.

endform.                    " BUILDFIELDCATLOG

*&---------------------------------------------------------------------*

*&      Form  TOP_PAG1

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

form TOP_PAG1 .

  WRITE:/'MARA DETAILS' COLOR 5.

endform.                    " TOP_PAG1

*&---------------------------------------------------------------------*

*&      Form  TOP_PAG2

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

form TOP_PAG2 .

  WRITE:/'MARC DETAILS' COLOR 5.

endform.                    " TOP_PAG2

*&---------------------------------------------------------------------*

*&      Form  TOP_PAG3

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

form TOP_PAG3 .

  WRITE:/'MAKT DETAILS' COLOR 5.

endform.                    " TOP_PAG3

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi wasim,

change the beloe code

wa_events-name = 'TOP_OF_PAGE'.  event name TOP-OF-PAGE REPLACE TO TOP_OF_PAGE

  wa_events-form = 'TOP_PAG1'.       " form name always caps letters       

wa_events-name = 'TOP_OF_PAGE'.

wa_events-form = 'TOP_PAG2'.

wa_events-name = 'TOP_OF_PAGE'.

wa_events-form = 'TOP_PAG3'.

THANKS,

NAVEEN

2 REPLIES 2

Former Member
0 Kudos

hi wasim,

change the beloe code

wa_events-name = 'TOP_OF_PAGE'.  event name TOP-OF-PAGE REPLACE TO TOP_OF_PAGE

  wa_events-form = 'TOP_PAG1'.       " form name always caps letters       

wa_events-name = 'TOP_OF_PAGE'.

wa_events-form = 'TOP_PAG2'.

wa_events-name = 'TOP_OF_PAGE'.

wa_events-form = 'TOP_PAG3'.

THANKS,

NAVEEN

0 Kudos

Hi Naveen,

Thanks a lot.

I got the O/P.