*&---------------------------------------------------------------------*
*& REPORT Z_ALV_INT_REPORT2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_ALV_INT_REPORT2.
TYPE-POOLS: SLIS.
TABLES: EKKO, EKPO, MAKT.
TYPES :BEGIN OF TY_EKKO,
EBELN TYPE EBELN,
LIFNR TYPE ELIFN,
BUKRS TYPE BUKRS,
END OF TY_EKKO,
BEGIN OF TY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE MATNR,
LGORT TYPE LGORT_D,
MATKL TYPE MATKL,
MENGE TYPE BSTMG,
END OF TY_EKPO,
BEGIN OF TY_MAKT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TY_MAKT.
DATA: T_EKKO TYPE STANDARD TABLE OF TY_EKKO,
T_EKPO TYPE STANDARD TABLE OF TY_EKPO,
T_MAKT TYPE STANDARD TABLE OF TY_MAKT,
T_FCAT TYPE SLIS_T_FIELDCAT_ALV,
T_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
T_FCAT2 TYPE SLIS_T_FIELDCAT_ALV.
DATA: W_EKKO TYPE TY_EKKO,
W_EKPO TYPE TY_EKPO,
W_MAKT TYPE TY_MAKT,
W_FCAT TYPE SLIS_FIELDCAT_ALV.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: PURCHASE FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
SELECT EBELN LIFNR BUKRS
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN PURCHASE.
IF SY-SUBRC <> 0.
MESSAGE 'NO DATA AVAILABLE FOR THIS SO NO.' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
W_FCAT-COL_POS = 1.
W_FCAT-FIELDNAME = 'EBELN'.
W_FCAT-TABNAME = 'T_EKKO'.
W_FCAT-SELTEXT_M = 'PURCHSING NO'.
APPEND W_FCAT TO T_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = 2.
W_FCAT-FIELDNAME = 'LIFNR'.
W_FCAT-TABNAME = 'T_EKKO'.
W_FCAT-SELTEXT_M = 'VENDOR NO'.
APPEND W_FCAT TO T_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = 3.
W_FCAT-FIELDNAME = 'BUKRS'.
W_FCAT-TABNAME = 'T_EKKO'.
W_FCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND W_FCAT TO T_FCAT.
CLEAR W_FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = T_FCAT
TABLES
T_OUTTAB = T_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
FORM USER_COMMAND USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKKO INTO W_EKKO INDEX SELFIELD-TABINDEX.
IF COMMAND EQ '&IC1'.
CLEAR: T_FCAT1[].
SELECT EBELN EBELP MATNR LGORT MATKL MENGE
FROM EKPO
INTO TABLE T_EKPO
WHERE EBELN EQ W_EKKO-EBELN.
W_FCAT-FIELDNAME = 'EBELP'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'PURCHSING ITEM NO'.
W_FCAT-COL_POS = 1.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'MATERIAL NO'.
W_FCAT-COL_POS = 2.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'LGORT'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'STORAGE LOCATION'.
W_FCAT-COL_POS = 2.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'MATKL'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'MATERIAL GROUP'.
W_FCAT-COL_POS = 4.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'MENGE'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'QUANTITY'.
W_FCAT-COL_POS = 5.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND2'
IT_FIELDCAT = T_FCAT1
TABLES
T_OUTTAB = T_EKPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF.
ENDFORM.
FORM USER_COMMAND2 USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKPO INTO W_EKPO INDEX SELFIELD-TABINDEX.
IF COMMAND EQ '&IC1'.
CLEAR T_FCAT2[].
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE T_MAKT
WHERE MATNR EQ W_EKPO-MATNR
AND SPRAS EQ SY-LANGU.
W_FCAT-COL_POS = '1'.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-TABNAME = 'GT_MAKT'.
W_FCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND W_FCAT TO T_FCAT2.
CLEAR W_FCAT.
W_FCAT-COL_POS = '3'.
W_FCAT-FIELDNAME = 'MAKTX'.
W_FCAT-TABNAME = 'GT_MAKT'.
W_FCAT-SELTEXT_M = 'MATERIAL DESC.'.
APPEND W_FCAT TO T_FCAT2.
CLEAR W_FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = T_FCAT2
TABLES
T_OUTTAB = T_MAKT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF.
ENDFORM.
Output:
Input Screen:
Output Screen:
List Display-1:
List Display-2:
List Display-3:
*& REPORT Z_ALV_INT_REPORT2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_ALV_INT_REPORT2.
TYPE-POOLS: SLIS.
TABLES: EKKO, EKPO, MAKT.
TYPES :BEGIN OF TY_EKKO,
EBELN TYPE EBELN,
LIFNR TYPE ELIFN,
BUKRS TYPE BUKRS,
END OF TY_EKKO,
BEGIN OF TY_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE MATNR,
LGORT TYPE LGORT_D,
MATKL TYPE MATKL,
MENGE TYPE BSTMG,
END OF TY_EKPO,
BEGIN OF TY_MAKT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TY_MAKT.
DATA: T_EKKO TYPE STANDARD TABLE OF TY_EKKO,
T_EKPO TYPE STANDARD TABLE OF TY_EKPO,
T_MAKT TYPE STANDARD TABLE OF TY_MAKT,
T_FCAT TYPE SLIS_T_FIELDCAT_ALV,
T_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
T_FCAT2 TYPE SLIS_T_FIELDCAT_ALV.
DATA: W_EKKO TYPE TY_EKKO,
W_EKPO TYPE TY_EKPO,
W_MAKT TYPE TY_MAKT,
W_FCAT TYPE SLIS_FIELDCAT_ALV.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: PURCHASE FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
SELECT EBELN LIFNR BUKRS
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN PURCHASE.
IF SY-SUBRC <> 0.
MESSAGE 'NO DATA AVAILABLE FOR THIS SO NO.' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
W_FCAT-COL_POS = 1.
W_FCAT-FIELDNAME = 'EBELN'.
W_FCAT-TABNAME = 'T_EKKO'.
W_FCAT-SELTEXT_M = 'PURCHSING NO'.
APPEND W_FCAT TO T_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = 2.
W_FCAT-FIELDNAME = 'LIFNR'.
W_FCAT-TABNAME = 'T_EKKO'.
W_FCAT-SELTEXT_M = 'VENDOR NO'.
APPEND W_FCAT TO T_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = 3.
W_FCAT-FIELDNAME = 'BUKRS'.
W_FCAT-TABNAME = 'T_EKKO'.
W_FCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND W_FCAT TO T_FCAT.
CLEAR W_FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = T_FCAT
TABLES
T_OUTTAB = T_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
FORM USER_COMMAND USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKKO INTO W_EKKO INDEX SELFIELD-TABINDEX.
IF COMMAND EQ '&IC1'.
CLEAR: T_FCAT1[].
SELECT EBELN EBELP MATNR LGORT MATKL MENGE
FROM EKPO
INTO TABLE T_EKPO
WHERE EBELN EQ W_EKKO-EBELN.
W_FCAT-FIELDNAME = 'EBELP'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'PURCHSING ITEM NO'.
W_FCAT-COL_POS = 1.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'MATERIAL NO'.
W_FCAT-COL_POS = 2.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'LGORT'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'STORAGE LOCATION'.
W_FCAT-COL_POS = 2.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'MATKL'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'MATERIAL GROUP'.
W_FCAT-COL_POS = 4.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
W_FCAT-FIELDNAME = 'MENGE'.
W_FCAT-TABNAME = 'T_EKPO'.
W_FCAT-SELTEXT_M = 'QUANTITY'.
W_FCAT-COL_POS = 5.
APPEND W_FCAT TO T_FCAT1.
CLEAR W_FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND2'
IT_FIELDCAT = T_FCAT1
TABLES
T_OUTTAB = T_EKPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF.
ENDFORM.
FORM USER_COMMAND2 USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKPO INTO W_EKPO INDEX SELFIELD-TABINDEX.
IF COMMAND EQ '&IC1'.
CLEAR T_FCAT2[].
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE T_MAKT
WHERE MATNR EQ W_EKPO-MATNR
AND SPRAS EQ SY-LANGU.
W_FCAT-COL_POS = '1'.
W_FCAT-FIELDNAME = 'MATNR'.
W_FCAT-TABNAME = 'GT_MAKT'.
W_FCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND W_FCAT TO T_FCAT2.
CLEAR W_FCAT.
W_FCAT-COL_POS = '3'.
W_FCAT-FIELDNAME = 'MAKTX'.
W_FCAT-TABNAME = 'GT_MAKT'.
W_FCAT-SELTEXT_M = 'MATERIAL DESC.'.
APPEND W_FCAT TO T_FCAT2.
CLEAR W_FCAT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = T_FCAT2
TABLES
T_OUTTAB = T_MAKT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDIF.
ENDFORM.
No comments:
Post a Comment