Pages

Friday, 26 April 2013

ALV Interactive report 3 list

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

REPORT  ZR_ALV_INETR_PO_3LIST.

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_LH1 TYPE SLIS_T_LISTHEADER,
      IT_LH2 TYPE SLIS_T_LISTHEADER,
      WA_LH1 TYPE SLIS_LISTHEADER,
      WA_LH2 TYPE SLIS_LISTHEADER,
      LINE TYPE I,
      LINE1(10TYPE C,
      T_LINE LIKE WA_LH1-INFO.

SELECT-OPTIONSS_EBELN FOR EKPO-EBELN.

PERFORM GETDATA1.
PERFORM FIELDCAT1.
PERFORM DISPLAY1.

FORM GETDATA1.
  SELECT EBELN EBELP MATNR MENGE NETPR FROM EKPO INTO TABLE IT_EKPO 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 TOP_OF_PAGE1.

  CLEAR WA_LH1.
  WA_LH1-TYP 'H'.
  WA_LH1-INFO 'PURCHASE ORDER ITEM DATA'.
  APPEND WA_LH1 TO IT_LH1.

  CLEAR WA_LH1.
  WA_LH1-TYP 'S'.
  WA_LH1-KEY 'DATE:'.
  CONCATENATE SY-DATUM+6(2SY-DATUM+4(2SY-DATUM(4INTO WA_LH1-INFO SEPARATED BY '/'.
  APPEND WA_LH1 TO IT_LH1.

  CLEAR WA_LH1.
  DESCRIBE TABLE IT_EKPO LINES LINE.
  LINE1 LINE.
  CONCATENATE 'TOTAL NO OF RECORD SELECTED' LINE1 INTO T_LINE SEPARATED BY SPACE.
  WA_LH1-TYP 'A'.
  WA_LH1-INFO T_LINE.
  APPEND WA_LH1 TO IT_LH1.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY       IT_LH1.

REFRESH IT_LH1.
CLEARWA_LH1.
ENDFORM.

FORM DISPLAY1.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
     I_CALLBACK_PROGRAM                SY-REPID
     I_CALLBACK_USER_COMMAND           'USER_COMMAND'
     I_CALLBACK_TOP_OF_PAGE            'TOP_OF_PAGE1'
     I_BACKGROUND_ID                   'ALV_BACKGROUND'
     IT_FIELDCAT                       IT_FC1
    TABLES
      T_OUTTAB                          IT_EKPO .
ENDFORM.

form  USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELF TYPE SLIS_SELFIELD.
  CASE R_UCOMM.
    WHEN '&IC1'.
      READ TABLE IT_EKPO INTO WA_EKPO INDEX RS_SELF-TABINDEX.
      PERFORM FIELDCAT2.
      PERFORM GETDATA2.
      PERFORM DISPLAY2.
  ENDCASE.
ENDFORM.

FORM GETDATA2.
  SELECT EBELN BUKRS BSTYP BSART ERNAM AEDAT FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO WHERE EBELN WA_EKPO-EBELN.
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 DISPLAY2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   I_CALLBACK_PROGRAM                SY-REPID
   I_CALLBACK_USER_COMMAND           'USER_COMMAND2'
   I_CALLBACK_TOP_OF_PAGE            'TOP_OF_PAGE2'
   IT_FIELDCAT                       IT_FC2
  TABLES
    T_OUTTAB                          IT_EKKO.

CLEARWA_FC2.
REFRESH IT_FC2.
ENDFORM.

FORM TOP_OF_PAGE2.

  CLEAR WA_LH1.
  WA_LH1-TYP 'H'.
  WA_LH1-INFO 'PURCHASE ORDER HEADER DATA'.
  APPEND WA_LH1 TO IT_LH1.

  CLEAR WA_LH1.
  WA_LH1-TYP 'S'.
  WA_LH1-KEY 'DATE:'.
  CONCATENATE SY-DATUM+6(2SY-DATUM+4(2SY-DATUM(4INTO WA_LH1-INFO SEPARATED BY '/'.
  APPEND WA_LH1 TO IT_LH1.

  CLEARWA_LH1,LINE,LINE1,T_LINE.
  DESCRIBE TABLE IT_EKKO LINES LINE.
  LINE1 LINE.
  CONCATENATE 'TOTAL NO OF RECORD SELECTED' LINE1 INTO T_LINE SEPARATED BY SPACE.
  WA_LH1-TYP 'A'.
  WA_LH1-INFO T_LINE.
  APPEND WA_LH1 TO IT_LH1.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY       IT_LH1.

REFRESH IT_LH1.
CLEARWA_LH1.
ENDFORM.

FORM USER_COMMAND2 USING R_UCOMM2 LIKE SY-UCOMM RS_SELF2 TYPE SLIS_SELFIELD.
  READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELF2-TABINDEX.

  PERFORM FIELDCAT3.
  PERFORM DISPLAY3.

ENDFORM.

FORM FIELDCAT3.
CLEARWA_FC2,IT_FC2.
  WA_FC2-TABNAME 'IT_EKKO'.
  WA_FC2-FIELDNAME 'ERNAM'.
  WA_FC2-SELTEXT_S 'ENTER BY NAME'.
  WA_FC2-COL_POS 1.
  APPEND WA_FC2 TO IT_FC2.

  CLEARWA_FC2.
  WA_FC2-TABNAME 'IT_EKKO'.
  WA_FC2-FIELDNAME 'AEDAT'.
  WA_FC2-SELTEXT_S 'CREATED DATE'.
  WA_FC2-COL_POS 2.
  APPEND WA_FC2 TO IT_FC2.

ENDFORM.

FORM DISPLAY3.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_GRID_TITLE                      'VENDER DETAILS'
     IT_FIELDCAT                       IT_FC2
   TABLES
     T_OUTTAB                          IT_EKKO
            .
    CLEARWA_FC2.
  REFRESH IT_FC2.
ENDFORM.

RESULT:

  Basic list
 Secondary list 1
Secondary list 2

No comments:

Post a Comment