0% found this document useful (0 votes)
54 views12 pages

Include Include Include of Perform Perform Perform Perform Perform

This report displays material master data from the MARA table in an ALV grid. It includes forms to retrieve the data, create the field catalog and layout, and display the ALV grid. User interactions like selection and display of additional text are programmed but commented out.

Uploaded by

tauseef_ansari
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views12 pages

Include Include Include of Perform Perform Perform Perform Perform

This report displays material master data from the MARA table in an ALV grid. It includes forms to retrieve the data, create the field catalog and layout, and display the ALV grid. User interactions like selection and display of additional text are programmed but commented out.

Uploaded by

tauseef_ansari
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 12

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

*
*& Report  ZREPORT_INT
*&
*&---------------------------------------------------------------------
*
*&
*&
*&---------------------------------------------------------------------
*

report  zreport_int.

include zdata_dec_int.

include zsel_int.

include zdata_fetch_int.

start-of-selection.

perform get_data_mara.

perform create_fldcat.

perform create_layout.

perform create_event.

perform display_alv.

*PERFORM WRITE_DATA.

*SET PF-STATUS 'INFOCUS'.
*
*at USER-COMMAND.
*  case sy-ucomm.
*
*   when 'DISPLAY'.
*  WINDOW STARTING AT 5 5
*         ENDING AT  60 40.
*
*LOOP AT I_MARA INTO W_MARA.
*  WRITE: W_MARA-MATNR.
*ENDLOOP.
*
*   WHEN 'EXIT'.
*     LEAVE LIST-PROCESSING.
*
*  ENDCASE.

*
*AT LINE-SELECTION.
*
*  SELECT SINGLE MAKTX
*    FROM MAKT
*    INTO L_MAKTX
*    WHERE MATNR = W_HIDE
*    AND SPRAS = SY-LANGU.
*
*  WINDOW STARTING AT 5 5
*         ENDING AT  60 40.
*WRITE: L_MAKTX.

*&---------------------------------------------------------------------
*
*&  Include           ZDATA_DEC_INT
*&---------------------------------------------------------------------
*

tables: mara.
type-pools : slis.

types : begin of t_mara,
        matnr  type matnr,
        ersda  type ersda,
        ernam  type ernam,
        laeda  type laeda,
        space type char10,
        end of t_mara,

        begin of t_makt,
        matnr type matnr,
        maktx type maktx,
        end of t_makt.

data : i_mara type standard table of t_mara,
       w_mara type t_mara,
       i_makt type standard table of t_makt,
       w_hide type matnr,
       l_maktx type maktx.

* DATA DECLERATION FOR FIELD CATALOG
data: i_fldcat type slis_t_fieldcat_alv,
      w_fldcat type slis_fieldcat_alv,
      w_layout type slis_layout_alv.

data : i_fldcat1 type slis_t_fieldcat_alv,
       w_fldcat1 type slis_fieldcat_alv,
       w_layout1 type slis_layout_alv.

data : i_event type slis_t_event,
       w_event type slis_alv_event.
*&---------------------------------------------------------------------
*
*&  Include           ZSEL_INT
*&---------------------------------------------------------------------
*

selection-screen : begin of block c1 with frame title text-001.
select-options: s_matnr for mara-matnr.
selection-screen : end of block c1.

*&---------------------------------------------------------------------
*
*&  Include           ZDATA_FETCH_INT
*&---------------------------------------------------------------------
*
*&---------------------------------------------------------------------
*
*&      Form  GET_DATA_MARA
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form get_data_mara .

  select matnr
         ersda
         ernam
         laeda
    from mara
    into table i_mara
    where matnr in s_matnr.
endform.                    " GET_DATA_MARA
*&---------------------------------------------------------------------
*
*&      Form  WRITE_DATA
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form write_data .

  loop at i_mara into w_mara.
    write:/ w_mara-matnr,
             w_mara-ersda,
             w_mara-ernam,
             w_mara-laeda.

    w_hide = w_mara-matnr.
    hide: w_hide.

  endloop.

endform.                    " WRITE_DATA
*&---------------------------------------------------------------------
*
*&      Form  CREATE_FLDCAT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form create_fldcat .

  data: c_pos type i value 1,
        r_pos type i value 1.

  w_fldcat-col_pos = c_pos.
  w_fldcat-row_pos = r_pos.
  w_fldcat-fieldname = 'MATNR'.
  w_fldcat-tabname = 'I_MARA'.
  w_fldcat-seltext_l = 'Material Number'.
  w_fldcat-emphasize = 'C700'.
  append w_fldcat to i_fldcat.
  clear w_fldcat.

  c_pos = c_pos + 1.
  w_fldcat-col_pos = c_pos.
  w_fldcat-fieldname = 'ERSDA'.
  w_fldcat-tabname = 'I_MARA'.
  w_fldcat-seltext_l = 'Created On'.
  append w_fldcat to i_fldcat.
  clear w_fldcat.

  c_pos = c_pos + 1.
  w_fldcat-col_pos = c_pos.
  w_fldcat-fieldname = 'SPACE'.
  w_fldcat-tabname = 'I_MARA'.
  w_fldcat-seltext_l = '      '.
  append w_fldcat to i_fldcat.
  clear w_fldcat.

  c_pos = c_pos + 1.
  w_fldcat-col_pos = c_pos.
  w_fldcat-fieldname = 'ERNAM'.
  w_fldcat-tabname = 'I_MARA'.
  w_fldcat-seltext_l = 'Name of PersoN'.
  append w_fldcat to i_fldcat.
  clear w_fldcat.

  c_pos = c_pos + 1.
  w_fldcat-col_pos = c_pos.
  w_fldcat-fieldname = 'LAEDA'.
  w_fldcat-tabname = 'I_MARA'.
  w_fldcat-seltext_l = 'Date of Last Change'.
  append w_fldcat to i_fldcat.
  clear w_fldcat.

endform.                    " CREATE_FLDCAT
*&---------------------------------------------------------------------
*
*&      Form  CREATE_LAYOUT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form create_layout .

  w_layout-colwidth_optimize = 'X'.
  w_layout-zebra =  'X'.

endform.                    " CREATE_LAYOUT
*&---------------------------------------------------------------------
*
*&      Form  DISPLAY_ALV
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form display_alv .

*  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
*   EXPORTING
**   I_INTERFACE_CHECK                 = ' '
**   I_BYPASSING_BUFFER                = ' '
**   I_BUFFER_ACTIVE                   = ' '
*     I_CALLBACK_PROGRAM                = SY-REPID
*   I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
*   I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
*   I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
**   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
**   I_CALLBACK_HTML_END_OF_LIST       = ' '
**   I_STRUCTURE_NAME                  =
**   I_BACKGROUND_ID                   = ' '
**   I_GRID_TITLE                      =
**   I_GRID_SETTINGS                   =
*     IS_LAYOUT                         = W_LAYOUT
*     IT_FIELDCAT                       = I_FLDCAT
**   IT_EXCLUDING                      =
**   IT_SPECIAL_GROUPS                 =
**   IT_SORT                           =
**   IT_FILTER                         =
**   IS_SEL_HIDE                       =
**   I_DEFAULT                         = 'X'
**   I_SAVE                            = ' '
**   IS_VARIANT                        =
**   IT_EVENTS                         =
**   IT_EVENT_EXIT                     =
**   IS_PRINT                          =
**   IS_REPREP_ID                      =
**   I_SCREEN_START_COLUMN             = 0
**   I_SCREEN_START_LINE               = 0
**   I_SCREEN_END_COLUMN               = 0
**   I_SCREEN_END_LINE                 = 0
**   I_HTML_HEIGHT_TOP                 = 0
**   I_HTML_HEIGHT_END                 = 0
**   IT_ALV_GRAPHICS                   =
**   IT_HYPERLINK                      =
**   IT_ADD_FIELDCAT                   =
**   IT_EXCEPT_QINFO                   =
**   IR_SALV_FULLSCREEN_ADAPTER        =
** IMPORTING
**   E_EXIT_CAUSED_BY_CALLER           =
**   ES_EXIT_CAUSED_BY_USER            =
*    TABLES
*      T_OUTTAB                          = I_MARA
** 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.

call function 'REUSE_ALV_LIST_DISPLAY'
 exporting
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ' '
   i_callback_program             = sy-repid
   i_callback_pf_status_set       = 'SET_PF_STATUS'
   i_callback_user_command        = 'USER_COMMAND'
*   I_STRUCTURE_NAME               =
   is_layout                      = w_layout
   it_fieldcat                    = i_fldcat
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
   it_events                      = i_event
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  tables
    t_outtab                       = i_mara
* 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.

endform.                    " DISPLAY_ALV

*&---------------------------------------------------------------------
*
*&      Form  top_of_page
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
form top_of_page.

data :i_top type slis_t_listheader,
      w_top type slis_listheader.

w_top-typ = 'H'.
w_top-info = 'Infocus Training'.
append w_top to i_top.
clear w_top.

w_top-typ = 'S'.
w_top-info = 'Saltlake - Kolkata'.
append w_top to i_top.
clear w_top.
w_top-typ = 'A'.
w_top-info = sy-datum.
concatenate w_top-info+6(2)
            w_top-info+4(2)
            w_top-info+0(4)
        into w_top-info
        separated by '/'.
append w_top to i_top.
clear w_top.

           call function 'REUSE_ALV_COMMENTARY_WRITE'
             exporting
               it_list_commentary       = i_top
*              I_LOGO                   =
*              I_END_OF_LIST_GRID       =
*              I_ALV_FORM               =
                     .

endform.                    "top_of_page

*&---------------------------------------------------------------------
*
*&      Form  set_pf_status
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------
*
form set_pf_status using rt_extab type slis_t_extab.

  set pf-status 'INFPF'.

endform.                    "set_pf_status

*&---------------------------------------------------------------------
*
*&      Form  user_command
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------
*
form user_command  using r_ucomm like sy-ucomm
                                   rs_selfield type slis_selfield.
  case r_ucomm.

    when 'DISPLAY1'.

      perform get_data_makt.

      perform create_fldcat1.

      perform create_layout1.

      perform display_alv1.

    when 'EXIT1'.

      leave program.

  endcase.

endform.                    "user_command
*&---------------------------------------------------------------------
*
*&      Form  GET_DATA_MAKT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form get_data_makt .

  select matnr
         maktx
    from makt
    into table i_makt
    for all entries in i_mara
    where matnr = i_mara-matnr
    and   spras = sy-langu.

endform.                    " GET_DATA_MAKT
*&---------------------------------------------------------------------
*
*&      Form  CREATE_FLDCAT1
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form create_fldcat1 .
  data: c_pos type i value 1,
        r_pos type i value 1.

  w_fldcat1-col_pos = c_pos.
  w_fldcat1-row_pos = r_pos.
  w_fldcat1-fieldname = 'MATNR'.
  w_fldcat1-tabname = 'I_MAKT'.
  w_fldcat1-seltext_l = 'Material No'.
  append w_fldcat1 to i_fldcat1.
  clear w_fldcat1.

  c_pos = c_pos + 1.
  w_fldcat1-col_pos = c_pos.
  w_fldcat1-fieldname = 'MAKTX'.
  w_fldcat1-tabname = 'I_MAKT'.
  w_fldcat1-seltext_l = 'Material Desc'.
  append w_fldcat1 to i_fldcat1.
  clear w_fldcat1.

endform.                    " CREATE_FLDCAT1
*&---------------------------------------------------------------------
*
*&      Form  CREATE_LAYOUT1
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form create_layout1 .

  w_layout1-zebra = 'X'.
  w_layout1-colwidth_optimize = 'X'.

endform.                    " CREATE_LAYOUT1
*&---------------------------------------------------------------------
*
*&      Form  DISPLAY_ALV1
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form display_alv1 .

  call function 'REUSE_ALV_GRID_DISPLAY'
   exporting
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
     i_callback_program                = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
     is_layout                         = w_layout1
     it_fieldcat                       = i_fldcat1
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    tables
      t_outtab                          = i_makt
* 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.

endform.                    " DISPLAY_ALV1
*&---------------------------------------------------------------------
*
*&      Form  CREATE_EVENT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
form create_event .

call function 'REUSE_ALV_EVENTS_GET'
 exporting
   i_list_type           = 0
 importing
   et_events             = i_event
 exceptions
   list_type_wrong       = 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.

read table i_event into w_event with key name = 'TOP_OF_PAGE'.
if sy-subrc eq 0.
  w_event-form = 'TOP_OF_PAGE'.
  modify i_event from w_event transporting form
  where name = 'TOP_OF_PAGE'..
endif.

endform.                    " CREATE_EVENT

You might also like