TABLES: MARA.
DATA: BEGIN OF I_ALV OCCURS 0,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MATKL TYPE MARA-MATKL,
GROES TYPE MARA-GROES,
MAKTX TYPE MAKT-MAKTX,
END OF I_ALV.
DATA: ALV_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER.
DATA: ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: LAYOUT TYPE LVC_S_LAYO.
DATA: FIELDCAT TYPE LVC_T_FCAT.
PARAMETERS: P_CHECK.
INITIALIZATION.
PERFORM GET_DATA.
AT SELECTION-SCREEN OUTPUT.
DATA: VARIANT TYPE DISVARIANT.
DATA: REPID TYPE SY-REPID.
REPID = SY-REPID.
VARIANT-REPORT = SY-REPID.
VARIANT-USERNAME = SY-UNAME.
LAYOUT-ZEBRA = 'X'.
LAYOUT-EDIT_MODE = 'X'.
CHECK ALV_CONTAINER IS INITIAL.
CREATE OBJECT ALV_CONTAINER
EXPORTING
REPID = REPID
DYNNR = SY-DYNNR
SIDE = ALV_CONTAINER->DOCK_AT_LEFT
EXTENSION = 1500.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = ALV_CONTAINER.
* ALV Specific. Data selection.
* Populate Field Catalog
PERFORM GET_FIELDCATALOG.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
IS_VARIANT = VARIANT
I_SAVE = 'U'
I_STRUCTURE_NAME = 'I_ALV'
CHANGING
IT_OUTTAB = I_ALV[]
IT_FIELDCATALOG = FIELDCAT[].
START-OF-SELECTION.
*************************************************************
* FORM GET_DATA
*************************************************************
FORM GET_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ALV
FROM MARA
INNER JOIN MAKT
ON MARA~MATNR = MAKT~MATNR
UP TO 100 ROWS
WHERE MAKT~SPRAS = SY-LANGU.
SORT I_ALV ASCENDING BY MATNR.
ENDFORM. "get_data
***************************************************************
*get_data
* Form Get_Fieldcatalog - Set Up Columns/Headers
****************************************************************
FORM GET_FIELDCATALOG.
DATA: LS_FCAT TYPE LVC_S_FCAT.
REFRESH: FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Number'.
LS_FCAT-FIELDNAME = 'MATNR'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '18'.
LS_FCAT-FIX_COLUMN = 'X'.
LS_FCAT-KEY = 'X'.
LS_FCAT-COL_POS = '1'.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Type'.
LS_FCAT-FIELDNAME = 'MTART'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-FIX_COLUMN = 'X'.
LS_FCAT-KEY = 'X'.
LS_FCAT-COL_POS = '2'.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Group'.
LS_FCAT-FIELDNAME = 'MATKL'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '12'.
LS_FCAT-COL_POS = '3'.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Size'.
LS_FCAT-FIELDNAME = 'GROES'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '30'.
LS_FCAT-COL_POS = '4'.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Description'.
LS_FCAT-FIELDNAME = 'MAKTX'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '40'.
LS_FCAT-COL_POS = '5'.
APPEND LS_FCAT TO FIELDCAT.
ENDFORM. "get_fieldcatalog
ALSO READ:
- Header In ALV Grid/List Display.
- Calling A Transacton From ALV Grid/List Report.
- Simple ALV Grid/List With Save Layout.
- Checkbox In ALV Program.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
No comments:
Post a Comment