Pages

Tuesday, 30 April 2013

ALV BLOCK LIST REPORT


*&---------------------------------------------------------------------*
*& Report  ZR_ALV_INETR_PO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZR_ALV_BLOCK_LIST.

TABLESEKKOEKPO,LFA1.
TYPE-POOLSSLIS.
TYPESBEGIN OF ST_EKKO,
     EBELN TYPE EKKO-EBELN,
     BUKRS TYPE EKKO-BUKRS,
     BSTYP TYPE EKKO-BSTYP,
     BSART TYPE EKKO-BSART,
     LIFNR TYPE EKKO-LIFNR,
     ERNAM TYPE EKKO-ERNAM,
     AEDAT TYPE EKKO-BEDAT,
      END OF ST_EKKO.

TYPESBEGIN OF ST_EKPO,
      EBELN TYPE EKPO-EBELN,
      EBELP TYPE EKPO-EBELP,
      MATNR TYPE EKPO-MATNR,
      MENGE TYPE EKPO-MENGE,
      NETPR TYPE EKPO-NETPR,
  END OF ST_EKPO.

DATAIT_EKKO TYPE TABLE OF ST_EKKO,
      IT_EKPO TYPE TABLE OF ST_EKPO,
      WA_EKKO TYPE ST_EKKO,
      WA_EKPO TYPE ST_EKPO.

DATAIT_FC1 TYPE SLIS_T_FIELDCAT_ALV,
      IT_FC2 TYPE SLIS_T_FIELDCAT_ALV,
      WA_FC1 TYPE SLIS_FIELDCAT_ALV,
      WA_FC2 TYPE SLIS_FIELDCAT_ALV.

DATAIT_EVENT TYPE SLIS_T_EVENT,
      V_TABNAME TYPE SLIS_TABNAME,
      S_LAYOUT TYPE SLIS_LAYOUT_ALV.


SELECT-OPTIONSS_EBELN FOR EKPO-EBELN.

PERFORM GETDATA.
PERFORM FIELDCAT1.
PERFORM FIELDCAT2.
PERFORM DISPLAY.

FORM GETDATA.
  SELECT EBELN EBELP MATNR MENGE NETPR FROM EKPO INTO TABLE IT_EKPO WHERE EBELN IN S_EBELN.
    SELECT EBELN BUKRS BSTYP BSART ERNAM AEDAT FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO WHERE EBELN IN S_EBELN.
ENDFORM.

FORM FIELDCAT1.

  CLEARWA_FC1.
  WA_FC1-TABNAME 'IT_EKPO'.
  WA_FC1-FIELDNAME 'EBELN'.
  WA_FC1-SELTEXT_S 'PO DOC NO'.
  WA_FC1-COL_POS 1.
  APPEND WA_FC1 TO IT_FC1.

  CLEARWA_FC1.
  WA_FC1-TABNAME 'IT_EKPO'.
  WA_FC1-FIELDNAME 'EBELP'.
  WA_FC1-SELTEXT_S 'PO DOC ITEM'.
  WA_FC1-COL_POS 2.
  APPEND WA_FC1 TO IT_FC1.

  CLEARWA_FC1.
  WA_FC1-TABNAME 'IT_EKPO'.
  WA_FC1-FIELDNAME 'MATNR'.
  WA_FC1-SELTEXT_S 'MATERIAL NO'.
  WA_FC1-COL_POS 3.
  APPEND WA_FC1 TO IT_FC1.

  CLEARWA_FC1.
  WA_FC1-TABNAME 'IT_EKPO'.
  WA_FC1-FIELDNAME 'MENGE'.
  WA_FC1-SELTEXT_S 'QUANTITY'.
  WA_FC1-COL_POS 4.
  APPEND WA_FC1 TO IT_FC1.

  CLEARWA_FC1.
  WA_FC1-TABNAME 'IT_EKPO'.
  WA_FC1-FIELDNAME 'NETPR'.
  WA_FC1-SELTEXT_S 'NET PRICE'.
  WA_FC1-COL_POS 5.
  APPEND WA_FC1 TO IT_FC1.

ENDFORM.


FORM FIELDCAT2.
  CLEARWA_FC2.
  WA_FC2-TABNAME 'IT_EKKO'.
  WA_FC2-FIELDNAME 'EBELN'.
  WA_FC2-SELTEXT_S 'PO DOC NO'.
  WA_FC2-COL_POS 1.
  APPEND WA_FC2 TO IT_FC2.

  CLEARWA_FC2.
  WA_FC2-TABNAME 'IT_EKKO'.
  WA_FC2-FIELDNAME 'BUKRS'.
  WA_FC2-SELTEXT_S 'COMPANY CODE'.
  WA_FC2-COL_POS 2.
  APPEND WA_FC2 TO IT_FC2.

  CLEARWA_FC2.
  WA_FC2-TABNAME 'IT_EKKO'.
  WA_FC2-FIELDNAME 'BUTYP'.
  WA_FC2-SELTEXT_S 'PO DOC CAT'.
  WA_FC2-COL_POS 3.
  APPEND WA_FC2 TO IT_FC2.

  CLEARWA_FC2.
  WA_FC2-TABNAME 'IT_EKKO'.
  WA_FC2-FIELDNAME 'BSART'.
  WA_FC2-SELTEXT_S 'PO DOC TYPE'.
  WA_FC2-COL_POS 4.
  APPEND WA_FC2 TO IT_FC2.

  CLEARWA_FC2.
ENDFORM.

FORM DISPLAY.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    I_CALLBACK_PROGRAM             SY-REPID
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
          .


V_TABNAME 'ITAB1'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    IS_LAYOUT                        S_LAYOUT
    IT_FIELDCAT                      IT_FC1
    I_TABNAME                        V_TABNAME
    IT_EVENTS                        IT_EVENT
*   IT_SORT                          =
*   I_TEXT                           = ' '
  TABLES
    T_OUTTAB                         IT_EKPO
* EXCEPTIONS
*   PROGRAM_ERROR                    = 1
*   MAXIMUM_OF_APPENDS_REACHED       = 2
*   OTHERS                           = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

V_TABNAME 'ITAB2'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    IS_LAYOUT                        S_LAYOUT
    IT_FIELDCAT                      IT_FC2
    I_TABNAME                        V_TABNAME
    IT_EVENTS                        IT_EVENT
*   IT_SORT                          =
*   I_TEXT                           = ' '
  TABLES
    T_OUTTAB                         IT_EKKO
* EXCEPTIONS
*   PROGRAM_ERROR                    = 1
*   MAXIMUM_OF_APPENDS_REACHED       = 2
*   OTHERS                           = 3
          .
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_BLOCK_LIST_DISPLAY'
* EXPORTING
*   I_INTERFACE_CHECK             = ' '
*   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       =
*   ES_EXIT_CAUSED_BY_USER        =
* 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.


RESULT:


1 comment: