ALV_SET_LAYOUT


*&---------------------------------------------------------------------*
*& Report  ZALV_LAY2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZALV_LAY2.

TYPE-POOLS: SLIS.

DATA: I_MARA TYPE TABLE OF MARA,
      WA_MARA TYPE MARA.

DATA: V_POS TYPE I.

DATA:WA_LAYOUT TYPE  SLIS_LAYOUT_ALV.
DATA:IT_FCAT TYPE  SLIS_T_FIELDCAT_ALV.
DATA:WA_FCAT TYPE  SLIS_FIELDCAT_ALV.




SELECT-OPTIONS :P_MATNR FOR WA_MARA-MATNR.


START-OF-SELECTION.

PERFORM GET_DATA.
PERFORM CREATE_FIELDCAT.
PERFORM DISPLAY_DATA.
PERFORM CREATE_LAYOUT.

*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form GET_DATA .

SELECT * FROM MARA
  INTO TABLE I_MARA
  UP TO 100 ROWS
  WHERE MATNR IN P_MATNR.


endform.                    " GET_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form DISPLAY_DATA .

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                         = WA_LAYOUT
   IT_FIELDCAT                       = IT_FCAT
*   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             = ' '
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
   I_STRUCTURE_NAME               = 'MARA'
*   IS_LAYOUT                      =
*   IT_FIELDCAT                    =
*   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
*   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_DATA
*&---------------------------------------------------------------------*
*&      Form  CREATE_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form CREATE_FIELDCAT .



V_POS = 1.

WA_FCAT-COL_POS = V_POS.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-SELTEXT_M = 'MATERIAL NO'.
WA_FCAT-HOTSPOT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

V_POS = V_POS.
WA_FCAT-COL_POS = V_POS.
WA_FCAT-FIELDNAME = 'MTART'.
WA_FCAT-SELTEXT_M = 'MATERIAL TYPE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

V_POS = V_POS.
WA_FCAT-COL_POS = V_POS.
WA_FCAT-FIELDNAME = 'MBRSH'.
WA_FCAT-SELTEXT_M = 'INDUST GROUP'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

V_POS = V_POS.
WA_FCAT-COL_POS = V_POS.
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-SELTEXT_M = 'UNIT'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.



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

 WA_LAYOUT-ZEBRA = 'X'.
 WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
 WA_LAYOUT-EDIT = 'X'.
 WA_LAYOUT-NO_VLINE = 'X'.
 WA_LAYOUT-NO_HLINE = 'X'.


endform.                    " CREATE_LAYOUT




SAVE AND ACTIVE.





SEE  REPORT.



BACK THE REPORT.


Comments

Popular posts from this blog

FOR ALL ENTRIES (FAE) -4 TABLES USING ALV_GRID_DISPLAY

RADIO-BUTTONS IN BASIC REPORT

MODULE POOL -TABLE CONTROL_1: