*&---------------------------------------------------------------------*
*& Report ZSAMPLE_ALV
*&
*&---------------------------------------------------------------------*
*& TITLE: ALV INTERACTIVE REPORT FOR SALES AND BILLING REPORTS
*& CREATED BY : ABCDEFGH
*& CREATED DATE: 20 SEPT 2010.
*&
*&---------------------------------------------------------------------*
REPORT ZSAMPLE_ALV MESSAGE-ID ZSAMPLE_MSG.
TABLES: VBAK, VBAP, VBRK, VBRP, VBFA.
TYPE-POOLS : SLIS.
************************************************************************
* BASIC INTERNAL TABLE FOR VBAK
************************************************************************
TYPES :BEGIN OF I_VBAK,
VBELN TYPE VBAK-VBELN, " SALES DOCUMENT
ERDAT TYPE VBAK-ERDAT, " DATE ON WHICH RECORD IS CREATED
ERNAM TYPE VBAK-ERNAM, " NAME OF THE PERSON WHO CREATED THE OBJECT
AUDAT TYPE VBAK-AUDAT, " DOCUMENT DATE
NETWR TYPE VBAK-NETWR, " NET VALUE OF SALES ORDER
KUNNR TYPE VBAK-KUNNR, " SOLD TO PARTY
VTWEG TYPE VBAK-VTWEG, " DISTRIBUTION CHANNEL
VKORG TYPE VBAK-VKORG, " SALES ORGANIZATION
SPART TYPE VBAK-SPART, " DIVISION
END OF I_VBAK.
DATA : IT_VBAK TYPE STANDARD TABLE OF I_VBAK INITIAL SIZE 0,
WA_VBAK TYPE I_VBAK.
************************************************************************
* SECONDARY INTERNAL TABLE FOR VBAP
************************************************************************
TYPES :BEGIN OF I_VBAP ,
VBELN TYPE VBAP-VBELN, " SALES DOCUMENT
POSNR TYPE VBAP-POSNR, " SALES DOCUMENT ITEM
MATNR TYPE VBAP-MATNR, " MATERIAL NUMBER
MATKL TYPE VBAP-MATKL, " MATERIAL GROUP
MEINS TYPE VBAP-MEINS, " BASE UNIT OF MEASURE
ZWERT TYPE VBAP-ZWERT, " TARGET VALUE FOR OUTLINE AGREEMENT
END OF I_VBAP.
DATA: IT_VBAP TYPE STANDARD TABLE OF I_VBAP INITIAL SIZE 0,
WA_VBAP TYPE I_VBAP .
*************************************************************************
* BASIC INTERNAL TABLE FOR VBRK *
*************************************************************************
TYPES: BEGIN OF I_VBRK,
VBELN TYPE VBRK-VBELN, " BILLING DOCUMENT
FKART TYPE VBRK-FKART, " BILLING TYPE
FKDAT TYPE VBRK-FKDAT, " BILLING DATE
GJAHR TYPE VBRK-GJAHR, " FISCAL YEAR
POPER TYPE VBRK-POPER, " POSTING PERIOD
LAND1 TYPE VBRK-LAND1, " COUNTRY OF DESTINATION
REGIO TYPE VBRK-REGIO, " REGION
BUKRS TYPE VBRK-BUKRS, " COMPANY CODE
VKORG TYPE VBRK-VKORG, " SALES ORGANIZATION
SPART TYPE VBRK-SPART, " DIVISION
VTWEG TYPE VBRK-VTWEG, " DISTRIBUTION CHANNEL
ERDAT TYPE VBRK-ERDAT, " DATE ON WHICH RECORD IS CREATED
* VBELV TYPE VBRK-VBELV, " PRECEDING SALES AND DISTRIBUTION DOC
END OF I_VBRK.
DATA: IT_VBRK TYPE STANDARD TABLE OF I_VBRK INITIAL SIZE 0,
WA_VBRK TYPE I_VBRK.
*****************************************************************************
* SECONDARY LIST INTERNAL TABLE FOR VBRP *
*****************************************************************************
TYPES: BEGIN OF I_VBRP,
VBELN TYPE VBRP-VBELN, " BILLING DOC
POSNR TYPE VBRP-POSNR, " BILLING ITEM
VRKME TYPE VBRP-VRKME, " SALES UNIT
MEINS TYPE VBRP-MEINS, " BASE UNIT OF MEASURE
NETWR TYPE VBRP-NETWR, " NET VALUE
AUBEL TYPE VBRP-AUBEL, " SALES DOCUMENT
AUPOS TYPE VBRP-AUPOS, " SALES DOCUMENT ITEM
MATNR TYPE VBRP-MATNR, " MATERIAL NUMBER
VKORG TYPE VBRP-VKORG_AUFT, " SALES ORGANIZATION
SPART TYPE VBRP-SPART, " DIVISION
VTWEG TYPE VBRP-VTWEG_AUFT, " DISTRIBUTION CHANNEL
ERDAT TYPE VBRP-ERDAT, " DATE ON WHICH RECORD IS CREATED
END OF I_VBRP.
DATA: IT_VBRP TYPE STANDARD TABLE OF I_VBRP INITIAL SIZE 0,
WA_VBRP TYPE I_VBRP.
*****************************************************************************
* INTERNAL TABLE FOR VBFA
*****************************************************************************
TYPES: BEGIN OF I_VBFA,
VBELV TYPE VBFA-VBELN,
VBELN TYPE VBFA-VBELN,
END OF I_VBFA.
DATA: IT_VBFA TYPE STANDARD TABLE OF I_VBFA INITIAL SIZE 0,
WA_VBFA TYPE I_VBFA.
**********************************************************************
* PROGRAM NAME
**********************************************************************
DATA: V_REPID LIKE SY-REPID .
**********************************************************************
**** FIELD CATELOG TYPE DELARATIONS
**********************************************************************
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
***********************************************************************
**** LISTHEADER TYPE DECLARATIONS
***********************************************************************
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
***********************************************************************
***** EVENTS TYPE DECLARATIONS
***********************************************************************
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
*************************************************************************
**** REPORT TITLE
*************************************************************************
DATA: TITLE_VBAK TYPE LVC_TITLE VALUE 'CONTRACT BASIC LIST'.
DATA: TITLE_VBAP TYPE LVC_TITLE VALUE 'CONTRACT SECONDRY LIST'.
DATA: TITLE_VBRK TYPE LVC_TITLE VALUE 'BILLING BASIC LIST'.
DATA: TITLE_VBRP TYPE LVC_TITLE VALUE 'BILLING SECONDARY LIST'.
*************************************************************************
* SELECTION BLOCK ONE
*************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE T1.
PARAMETERS : S_VKORG TYPE VBAK-VKORG,
S_SPART TYPE VBAK-SPART,
S_VTWEG TYPE VBAK-VTWEG.
SELECTION-SCREEN : END OF BLOCK BLK1.
*************************************************************************
* SELECTION BLOCK TWO
*************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK2 WITH FRAME TITLE T2.
SELECT-OPTIONS : S_VBELN FOR WA_VBAK-VBELN OBLIGATORY.
SELECT-OPTIONS : S_AUDAT FOR WA_VBAK-ERDAT OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK BLK2.
*************************************************************************
* SELECTION SCREEN THREE
*************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK3 WITH FRAME TITLE T3.
PARAMETERS : R1 RADIOBUTTON GROUP RAD1 DEFAULT 'X',
R2 RADIOBUTTON GROUP RAD1,
R3 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF BLOCK BLK3.
**************************************************************************
* INITIALAZATION
**************************************************************************
INITIALIZATION.
T1 = 'SALES HEADER DATA'.
T2 = 'SALES ITEM DATA'.
T3 = 'SELECT SALES INFORMATION'.
S_VKORG = '1000'.
S_SPART = '00'.
S_VTWEG = '12'.
V_REPID = SY-REPID.
**************************************************************************
* AT SELECTION SCREEN
**************************************************************************
AT SELECTION-SCREEN ON S_VKORG .
IF NOT S_VKORG IS INITIAL.
SELECT SINGLE * FROM VBAK WHERE VKORG EQ S_VKORG.
IF SY-SUBRC NE 0.
MESSAGE E000.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON S_SPART.
IF NOT S_SPART IS INITIAL.
SELECT SINGLE * FROM VBAK WHERE SPART EQ S_SPART.
IF SY-SUBRC NE 0.
MESSAGE E001.
ENDIF.
ENDIF.
*AT SELECTION-SCREEN ON S_VTWEG.
* IF NOT S_VTWEG IS INITIAL.
* SELECT SINGLE * FROM VBAK WHERE VTWEG EQ S_VTWEG.
* IF SY-SUBRC NE 0.
* MESSAGE E002.
* ENDIF.
* ENDIF.
**************************************************************************
* START OF SELECTION
**************************************************************************
START-OF-SELECTION.
IF R1 = 'X'.
PERFORM GET_DATA.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
*
*PERFORM GET_DATA.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
ELSEIF R2 = 'X'.
PERFORM GET_DATA2.
PERFORM BUILD_FCAT2.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT2.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_GRID2.
ELSEIF R3 = 'X'.
PERFORM BUILD_FCAT3.
PERFORM EVENT_CALL3.
PERFORM POPULATE_EVENT_VBRP.
PERFORM GET_DATA3.
PERFORM BUILD_LISTHEADER_3 USING IT_LISTHEADER.
PERFORM DISPLAY_GRID_VBRP.
ENDIF.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG .
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'ERDAT'.
WA_FIELDCAT-SELTEXT_M = 'Date on Which Record Was Created'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'ERNAM'.
WA_FIELDCAT-SELTEXT_M = 'Name of Person who Created the Object'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'AUDAT'.
WA_FIELDCAT-SELTEXT_M = 'Document Date (Date Received/Sent)'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SELTEXT_M = 'Net Value of the Sales Order in Document Currency'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'KUNNR'.
WA_FIELDCAT-SELTEXT_M = 'Sold-to party'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'VTWEG'.
WA_FIELDCAT-SELTEXT_M = 'Distribution ChanneL'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form EVENT_CALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EVENT_CALL .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. " EVENT_CALL
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. " POPULATE_EVENT
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT2 .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND2'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND2'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. " POPULATE_EVENT2
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT VBELN
ERDAT
ERNAM
AUDAT
NETWR
KUNNR
VTWEG
VKORG
SPART FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN S_VBELN AND
VKORG = S_VKORG AND
SPART = S_SPART AND
VTWEG = S_VTWEG AND AUDAT IN S_AUDAT.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_LISTHEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_LISTHEADER text
*----------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING P_IT_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
*HLINE-INFO = 'INTERACTIVE ALV REPORT'.
*HLINE-TYP = 'H'.
ENDFORM. " BUILD_LISTHEADER
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = TITLE_VBAK
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBAK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID 'ZSAMPLE_MSG' TYPE 'E' NUMBER '000'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
*READ TABLE IT_VBAK INDEX RS_SELFIELD-TABINDEX INTO WA_VBAK.
READ TABLE IT_VBAK INTO WA_VBAK INDEX RS_SELFIELD-TABINDEX.
*PERFORM DATA_RETRIEVAL_VBAP.
PERFORM BUILD_FIELDCATLOG_VBAP.
PERFORM EVENT_CALL_VBAP.
PERFORM POPULATE_EVENT_3.
PERFORM GET_DATA_VBAP.
PERFORM BUILD_LISTHEADER_VBAP USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_VBAP.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_VBAP
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_VBAP.
CLEAR I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'Sales Document Item'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'Material Number'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATKL'.
WA_FIELDCAT-SELTEXT_M = 'Material Group'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'Base Unit of Measure'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'ZWERT'.
WA_FIELDCAT-SELTEXT_M = ' Document Currency'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_VBAP
*&--------------------------------------------------------------------*
*& Form event_call_VBAP
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_VBAP.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call_VBAP
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*--------------------------------------------------------------------*
FORM POPULATE_EVENT_VBAP.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table VBAK
FORM GET_DATA_VBAP.
SELECT VBELN
POSNR
MATNR
MATKL
MEINS
ZWERT FROM VBAP INTO TABLE IT_VBAP WHERE VBELN = WA_VBAK-VBELN.
ENDFORM.
FORM BUILD_LISTHEADER_VBAP USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
*HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_VBAP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'CONTRACT SECONDARY LIST DISPLAY'
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBAP
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.
*&---------------------------------------------------------------------*
*& Form BUILD_FCAT2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FCAT2 .
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Billing Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'FKART'.
WA_FIELDCAT-SELTEXT_M = 'Billing Type'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'FKDAT'.
WA_FIELDCAT-SELTEXT_M = 'Billing Date'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'GJAHR'.
WA_FIELDCAT-SELTEXT_M = 'Fiscal Year'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'POPER'.
WA_FIELDCAT-SELTEXT_M = 'Posting Period'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'LAND1'.
WA_FIELDCAT-SELTEXT_M = 'Country Of Destination'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'REGIO'.
WA_FIELDCAT-SELTEXT_M = 'Region'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'Company Code'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " BUILD_FCAT2
*&---------------------------------------------------------------------*
*& Form GET_DATA2
*&--------------ઞ------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM GET_DATA2 .
SELECT VBELV VBELN FROM VBFA INTO CORRESPONDING FIELDS OF TABLE IT_VBFA WHERE VBELV IN S_VBELN.
*BREAK-POINT.
SELECT VBELN
FKART
FKDAT
GJAHR
POPER
LAND1
REGIO
BUKRS
VKORG
SPART
VTWEG
ERDAT FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
FOR ALL ENTRIES IN IT_VBFA
WHERE VBELN = IT_VBFA-VBELN AND
VKORG = S_VKORG AND
SPART = S_SPART AND
VTWEG = S_VTWEG." AND FKDAT = S_AUDAT.
*BREAK-POINT.
*SELECT * FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK WHERE VBELN IN S_VBELN.
ENDFORM. " GET_DATA2
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID2 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND2'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = TITLE_VBRK
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBRK
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_GRID2
*&--------------------------------------------------------------------*
*& Form USER_COMMAND2
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND2 USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
*WRITE:/ RS_SELFIELD-TABINDEX.
*IF RS_SELFIELD = 'VBELN'.
READ TABLE IT_VBRK INTO WA_VBRK INDEX RS_SELFIELD-TABINDEX.
*ENDIF.
PERFORM BUILD_FIELDCATLOG_VBRP.
PERFORM EVENT_CALL_VBRP.
PERFORM POPULATE_EVENT_VBRP.
PERFORM DATA_RETRIEVAL_VBRP.
PERFORM BUILD_LISTHEADER_VBRP USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_VBRP.
ENDCASE.
ENDFORM. "user_command2
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_VBRP
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_VBRP.
CLEAR I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Billing Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'Billing Item'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VRKME'.
WA_FIELDCAT-SELTEXT_M = 'Sales Unit'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'Base Unit of Measure'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SELTEXT_M = 'Net Value'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUBEL'.
WA_FIELDCAT-SELTEXT_M = ' Sales Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUPOS'.
WA_FIELDCAT-SELTEXT_M = ' Sales Document Item'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = ' Material Number'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_VBRP
*&--------ઞ-----------------------------------------------------------*
*& Form event_call_VBAP
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_VBRP.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call_VBRP
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_VBRP.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*----------------------------------------------------------ઞ----------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table VBRK
FORM DATA_RETRIEVAL_VBRP.
SELECT VBELN
POSNR
VRKME
MEINS
NETWR
AUBEL
AUPOS
MATNR FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP WHERE VBELN = WA_VBRK-VBELN.
ENDFORM.
FORM BUILD_LISTHEADER_VBRP USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_VBRP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'BILLING SECONDARY LIST'
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBRP
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.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FCAT3.
CLEAR I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'BILLING DOCUMENT'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'BILLING ITEM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VRKME'.
WA_FIELDCAT-SELTEXT_M = 'SALES UNIT'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UNIT OF MEASURE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SELTEXT_M = 'Net Value of the Sales Order in Document Currency'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUBEL'.
WA_FIELDCAT-SELTEXT_M = 'SALES DOCUMENT'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUPOS'.
WA_FIELDCAT-SELTEXT_M = 'SALES DOCUMENT ITEM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " BUILD_FIELDCATLOG_VBRP
*&---------------------------------------------------------------------*
*& Form EVENT_CALL_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EVENT_CALL3.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call3
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT_3.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT_VBRP
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE_VBRP.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA3.
SELECT VBELV VBELN FROM VBFA INTO CORRESPONDING FIELDS OF TABLE IT_VBFA WHERE VBELV IN S_VBELN.
SELECT VBELN
POSNR
VRKME
MEINS
NETWR
AUBEL
AUPOS
MATNR
VKORG_AUFT
SPART
VTWEG_AUFT
ERDAT FROM VBRP INTO TABLE IT_VBRP
FOR ALL ENTRIES IN IT_VBFA WHERE VBELN = IT_VBFA-VBELN AND
VKORG_AUFT = S_VKORG AND
SPART = S_SPART AND
VTWEG_AUFT = S_VTWEG." AND ERDAT IN S_AUDAT.
ENDFORM. " GET_DATA3
*&---------------------------------------------------------------------*
*& Form BUILD_LISTHEADER_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_LISTHEADER text
*----------------------------------------------------------------------*
FORM BUILD_LISTHEADER_3 USING P_IT_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM. " BUILD_LISTHEADER_3
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_VBRP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'CONTRACT AND BILLING SECONDARY LIST'
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBRP
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_GRID_VBRP
*& Report ZSAMPLE_ALV
*&
*&---------------------------------------------------------------------*
*& TITLE: ALV INTERACTIVE REPORT FOR SALES AND BILLING REPORTS
*& CREATED BY : ABCDEFGH
*& CREATED DATE: 20 SEPT 2010.
*&
*&---------------------------------------------------------------------*
REPORT ZSAMPLE_ALV MESSAGE-ID ZSAMPLE_MSG.
TABLES: VBAK, VBAP, VBRK, VBRP, VBFA.
TYPE-POOLS : SLIS.
************************************************************************
* BASIC INTERNAL TABLE FOR VBAK
************************************************************************
TYPES :BEGIN OF I_VBAK,
VBELN TYPE VBAK-VBELN, " SALES DOCUMENT
ERDAT TYPE VBAK-ERDAT, " DATE ON WHICH RECORD IS CREATED
ERNAM TYPE VBAK-ERNAM, " NAME OF THE PERSON WHO CREATED THE OBJECT
AUDAT TYPE VBAK-AUDAT, " DOCUMENT DATE
NETWR TYPE VBAK-NETWR, " NET VALUE OF SALES ORDER
KUNNR TYPE VBAK-KUNNR, " SOLD TO PARTY
VTWEG TYPE VBAK-VTWEG, " DISTRIBUTION CHANNEL
VKORG TYPE VBAK-VKORG, " SALES ORGANIZATION
SPART TYPE VBAK-SPART, " DIVISION
END OF I_VBAK.
DATA : IT_VBAK TYPE STANDARD TABLE OF I_VBAK INITIAL SIZE 0,
WA_VBAK TYPE I_VBAK.
************************************************************************
* SECONDARY INTERNAL TABLE FOR VBAP
************************************************************************
TYPES :BEGIN OF I_VBAP ,
VBELN TYPE VBAP-VBELN, " SALES DOCUMENT
POSNR TYPE VBAP-POSNR, " SALES DOCUMENT ITEM
MATNR TYPE VBAP-MATNR, " MATERIAL NUMBER
MATKL TYPE VBAP-MATKL, " MATERIAL GROUP
MEINS TYPE VBAP-MEINS, " BASE UNIT OF MEASURE
ZWERT TYPE VBAP-ZWERT, " TARGET VALUE FOR OUTLINE AGREEMENT
END OF I_VBAP.
DATA: IT_VBAP TYPE STANDARD TABLE OF I_VBAP INITIAL SIZE 0,
WA_VBAP TYPE I_VBAP .
*************************************************************************
* BASIC INTERNAL TABLE FOR VBRK *
*************************************************************************
TYPES: BEGIN OF I_VBRK,
VBELN TYPE VBRK-VBELN, " BILLING DOCUMENT
FKART TYPE VBRK-FKART, " BILLING TYPE
FKDAT TYPE VBRK-FKDAT, " BILLING DATE
GJAHR TYPE VBRK-GJAHR, " FISCAL YEAR
POPER TYPE VBRK-POPER, " POSTING PERIOD
LAND1 TYPE VBRK-LAND1, " COUNTRY OF DESTINATION
REGIO TYPE VBRK-REGIO, " REGION
BUKRS TYPE VBRK-BUKRS, " COMPANY CODE
VKORG TYPE VBRK-VKORG, " SALES ORGANIZATION
SPART TYPE VBRK-SPART, " DIVISION
VTWEG TYPE VBRK-VTWEG, " DISTRIBUTION CHANNEL
ERDAT TYPE VBRK-ERDAT, " DATE ON WHICH RECORD IS CREATED
* VBELV TYPE VBRK-VBELV, " PRECEDING SALES AND DISTRIBUTION DOC
END OF I_VBRK.
DATA: IT_VBRK TYPE STANDARD TABLE OF I_VBRK INITIAL SIZE 0,
WA_VBRK TYPE I_VBRK.
*****************************************************************************
* SECONDARY LIST INTERNAL TABLE FOR VBRP *
*****************************************************************************
TYPES: BEGIN OF I_VBRP,
VBELN TYPE VBRP-VBELN, " BILLING DOC
POSNR TYPE VBRP-POSNR, " BILLING ITEM
VRKME TYPE VBRP-VRKME, " SALES UNIT
MEINS TYPE VBRP-MEINS, " BASE UNIT OF MEASURE
NETWR TYPE VBRP-NETWR, " NET VALUE
AUBEL TYPE VBRP-AUBEL, " SALES DOCUMENT
AUPOS TYPE VBRP-AUPOS, " SALES DOCUMENT ITEM
MATNR TYPE VBRP-MATNR, " MATERIAL NUMBER
VKORG TYPE VBRP-VKORG_AUFT, " SALES ORGANIZATION
SPART TYPE VBRP-SPART, " DIVISION
VTWEG TYPE VBRP-VTWEG_AUFT, " DISTRIBUTION CHANNEL
ERDAT TYPE VBRP-ERDAT, " DATE ON WHICH RECORD IS CREATED
END OF I_VBRP.
DATA: IT_VBRP TYPE STANDARD TABLE OF I_VBRP INITIAL SIZE 0,
WA_VBRP TYPE I_VBRP.
*****************************************************************************
* INTERNAL TABLE FOR VBFA
*****************************************************************************
TYPES: BEGIN OF I_VBFA,
VBELV TYPE VBFA-VBELN,
VBELN TYPE VBFA-VBELN,
END OF I_VBFA.
DATA: IT_VBFA TYPE STANDARD TABLE OF I_VBFA INITIAL SIZE 0,
WA_VBFA TYPE I_VBFA.
**********************************************************************
* PROGRAM NAME
**********************************************************************
DATA: V_REPID LIKE SY-REPID .
**********************************************************************
**** FIELD CATELOG TYPE DELARATIONS
**********************************************************************
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
***********************************************************************
**** LISTHEADER TYPE DECLARATIONS
***********************************************************************
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
***********************************************************************
***** EVENTS TYPE DECLARATIONS
***********************************************************************
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
*************************************************************************
**** REPORT TITLE
*************************************************************************
DATA: TITLE_VBAK TYPE LVC_TITLE VALUE 'CONTRACT BASIC LIST'.
DATA: TITLE_VBAP TYPE LVC_TITLE VALUE 'CONTRACT SECONDRY LIST'.
DATA: TITLE_VBRK TYPE LVC_TITLE VALUE 'BILLING BASIC LIST'.
DATA: TITLE_VBRP TYPE LVC_TITLE VALUE 'BILLING SECONDARY LIST'.
*************************************************************************
* SELECTION BLOCK ONE
*************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK1 WITH FRAME TITLE T1.
PARAMETERS : S_VKORG TYPE VBAK-VKORG,
S_SPART TYPE VBAK-SPART,
S_VTWEG TYPE VBAK-VTWEG.
SELECTION-SCREEN : END OF BLOCK BLK1.
*************************************************************************
* SELECTION BLOCK TWO
*************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK2 WITH FRAME TITLE T2.
SELECT-OPTIONS : S_VBELN FOR WA_VBAK-VBELN OBLIGATORY.
SELECT-OPTIONS : S_AUDAT FOR WA_VBAK-ERDAT OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK BLK2.
*************************************************************************
* SELECTION SCREEN THREE
*************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK BLK3 WITH FRAME TITLE T3.
PARAMETERS : R1 RADIOBUTTON GROUP RAD1 DEFAULT 'X',
R2 RADIOBUTTON GROUP RAD1,
R3 RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF BLOCK BLK3.
**************************************************************************
* INITIALAZATION
**************************************************************************
INITIALIZATION.
T1 = 'SALES HEADER DATA'.
T2 = 'SALES ITEM DATA'.
T3 = 'SELECT SALES INFORMATION'.
S_VKORG = '1000'.
S_SPART = '00'.
S_VTWEG = '12'.
V_REPID = SY-REPID.
**************************************************************************
* AT SELECTION SCREEN
**************************************************************************
AT SELECTION-SCREEN ON S_VKORG .
IF NOT S_VKORG IS INITIAL.
SELECT SINGLE * FROM VBAK WHERE VKORG EQ S_VKORG.
IF SY-SUBRC NE 0.
MESSAGE E000.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON S_SPART.
IF NOT S_SPART IS INITIAL.
SELECT SINGLE * FROM VBAK WHERE SPART EQ S_SPART.
IF SY-SUBRC NE 0.
MESSAGE E001.
ENDIF.
ENDIF.
*AT SELECTION-SCREEN ON S_VTWEG.
* IF NOT S_VTWEG IS INITIAL.
* SELECT SINGLE * FROM VBAK WHERE VTWEG EQ S_VTWEG.
* IF SY-SUBRC NE 0.
* MESSAGE E002.
* ENDIF.
* ENDIF.
**************************************************************************
* START OF SELECTION
**************************************************************************
START-OF-SELECTION.
IF R1 = 'X'.
PERFORM GET_DATA.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
*
*PERFORM GET_DATA.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
ELSEIF R2 = 'X'.
PERFORM GET_DATA2.
PERFORM BUILD_FCAT2.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT2.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_GRID2.
ELSEIF R3 = 'X'.
PERFORM BUILD_FCAT3.
PERFORM EVENT_CALL3.
PERFORM POPULATE_EVENT_VBRP.
PERFORM GET_DATA3.
PERFORM BUILD_LISTHEADER_3 USING IT_LISTHEADER.
PERFORM DISPLAY_GRID_VBRP.
ENDIF.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG .
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'ERDAT'.
WA_FIELDCAT-SELTEXT_M = 'Date on Which Record Was Created'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'ERNAM'.
WA_FIELDCAT-SELTEXT_M = 'Name of Person who Created the Object'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'AUDAT'.
WA_FIELDCAT-SELTEXT_M = 'Document Date (Date Received/Sent)'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SELTEXT_M = 'Net Value of the Sales Order in Document Currency'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'KUNNR'.
WA_FIELDCAT-SELTEXT_M = 'Sold-to party'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAK'.
WA_FIELDCAT-FIELDNAME = 'VTWEG'.
WA_FIELDCAT-SELTEXT_M = 'Distribution ChanneL'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form EVENT_CALL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EVENT_CALL .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. " EVENT_CALL
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. " POPULATE_EVENT
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT2 .
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND2'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND2'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. " POPULATE_EVENT2
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT VBELN
ERDAT
ERNAM
AUDAT
NETWR
KUNNR
VTWEG
VKORG
SPART FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN S_VBELN AND
VKORG = S_VKORG AND
SPART = S_SPART AND
VTWEG = S_VTWEG AND AUDAT IN S_AUDAT.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_LISTHEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_LISTHEADER text
*----------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING P_IT_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
*HLINE-INFO = 'INTERACTIVE ALV REPORT'.
*HLINE-TYP = 'H'.
ENDFORM. " BUILD_LISTHEADER
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = TITLE_VBAK
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBAK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID 'ZSAMPLE_MSG' TYPE 'E' NUMBER '000'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
*READ TABLE IT_VBAK INDEX RS_SELFIELD-TABINDEX INTO WA_VBAK.
READ TABLE IT_VBAK INTO WA_VBAK INDEX RS_SELFIELD-TABINDEX.
*PERFORM DATA_RETRIEVAL_VBAP.
PERFORM BUILD_FIELDCATLOG_VBAP.
PERFORM EVENT_CALL_VBAP.
PERFORM POPULATE_EVENT_3.
PERFORM GET_DATA_VBAP.
PERFORM BUILD_LISTHEADER_VBAP USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_VBAP.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_VBAP
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_VBAP.
CLEAR I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'Sales Document Item'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'Material Number'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATKL'.
WA_FIELDCAT-SELTEXT_M = 'Material Group'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'Base Unit of Measure'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBAP'.
WA_FIELDCAT-FIELDNAME = 'ZWERT'.
WA_FIELDCAT-SELTEXT_M = ' Document Currency'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_VBAP
*&--------------------------------------------------------------------*
*& Form event_call_VBAP
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_VBAP.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call_VBAP
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*--------------------------------------------------------------------*
FORM POPULATE_EVENT_VBAP.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table VBAK
FORM GET_DATA_VBAP.
SELECT VBELN
POSNR
MATNR
MATKL
MEINS
ZWERT FROM VBAP INTO TABLE IT_VBAP WHERE VBELN = WA_VBAK-VBELN.
ENDFORM.
FORM BUILD_LISTHEADER_VBAP USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
*HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_VBAP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'CONTRACT SECONDARY LIST DISPLAY'
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBAP
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.
*&---------------------------------------------------------------------*
*& Form BUILD_FCAT2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FCAT2 .
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Billing Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'FKART'.
WA_FIELDCAT-SELTEXT_M = 'Billing Type'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'FKDAT'.
WA_FIELDCAT-SELTEXT_M = 'Billing Date'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'GJAHR'.
WA_FIELDCAT-SELTEXT_M = 'Fiscal Year'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'POPER'.
WA_FIELDCAT-SELTEXT_M = 'Posting Period'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'LAND1'.
WA_FIELDCAT-SELTEXT_M = 'Country Of Destination'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'REGIO'.
WA_FIELDCAT-SELTEXT_M = 'Region'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRK'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'Company Code'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " BUILD_FCAT2
*&---------------------------------------------------------------------*
*& Form GET_DATA2
*&--------------ઞ------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------*
FORM GET_DATA2 .
SELECT VBELV VBELN FROM VBFA INTO CORRESPONDING FIELDS OF TABLE IT_VBFA WHERE VBELV IN S_VBELN.
*BREAK-POINT.
SELECT VBELN
FKART
FKDAT
GJAHR
POPER
LAND1
REGIO
BUKRS
VKORG
SPART
VTWEG
ERDAT FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
FOR ALL ENTRIES IN IT_VBFA
WHERE VBELN = IT_VBFA-VBELN AND
VKORG = S_VKORG AND
SPART = S_SPART AND
VTWEG = S_VTWEG." AND FKDAT = S_AUDAT.
*BREAK-POINT.
*SELECT * FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK WHERE VBELN IN S_VBELN.
ENDFORM. " GET_DATA2
*&---------------------------------------------------------------------*
*& Form DISPLAY_GRID2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID2 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND2'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = TITLE_VBRK
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBRK
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_GRID2
*&--------------------------------------------------------------------*
*& Form USER_COMMAND2
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND2 USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
*WRITE:/ RS_SELFIELD-TABINDEX.
*IF RS_SELFIELD = 'VBELN'.
READ TABLE IT_VBRK INTO WA_VBRK INDEX RS_SELFIELD-TABINDEX.
*ENDIF.
PERFORM BUILD_FIELDCATLOG_VBRP.
PERFORM EVENT_CALL_VBRP.
PERFORM POPULATE_EVENT_VBRP.
PERFORM DATA_RETRIEVAL_VBRP.
PERFORM BUILD_LISTHEADER_VBRP USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_VBRP.
ENDCASE.
ENDFORM. "user_command2
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_VBRP
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_VBRP.
CLEAR I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'Billing Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'Billing Item'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VRKME'.
WA_FIELDCAT-SELTEXT_M = 'Sales Unit'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'Base Unit of Measure'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SELTEXT_M = 'Net Value'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUBEL'.
WA_FIELDCAT-SELTEXT_M = ' Sales Document'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUPOS'.
WA_FIELDCAT-SELTEXT_M = ' Sales Document Item'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = ' Material Number'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_VBRP
*&--------ઞ-----------------------------------------------------------*
*& Form event_call_VBAP
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_VBRP.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call_VBRP
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_VBRP.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*----------------------------------------------------------ઞ----------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
*retreiving values from the database table VBRK
FORM DATA_RETRIEVAL_VBRP.
SELECT VBELN
POSNR
VRKME
MEINS
NETWR
AUBEL
AUPOS
MATNR FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP WHERE VBELN = WA_VBRK-VBELN.
ENDFORM.
FORM BUILD_LISTHEADER_VBRP USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_VBRP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'BILLING SECONDARY LIST'
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBRP
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.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FCAT3.
CLEAR I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-SELTEXT_M = 'BILLING DOCUMENT'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-SELTEXT_M = 'BILLING ITEM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'VRKME'.
WA_FIELDCAT-SELTEXT_M = 'SALES UNIT'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UNIT OF MEASURE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SELTEXT_M = 'Net Value of the Sales Order in Document Currency'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUBEL'.
WA_FIELDCAT-SELTEXT_M = 'SALES DOCUMENT'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'AUPOS'.
WA_FIELDCAT-SELTEXT_M = 'SALES DOCUMENT ITEM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBRP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " BUILD_FIELDCATLOG_VBRP
*&---------------------------------------------------------------------*
*& Form EVENT_CALL_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EVENT_CALL3.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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. "event_call3
*&---------------------------------------------------------------------*
*& Form POPULATE_EVENT_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM POPULATE_EVENT_3.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT_VBRP
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE_VBRP.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA3.
SELECT VBELV VBELN FROM VBFA INTO CORRESPONDING FIELDS OF TABLE IT_VBFA WHERE VBELV IN S_VBELN.
SELECT VBELN
POSNR
VRKME
MEINS
NETWR
AUBEL
AUPOS
MATNR
VKORG_AUFT
SPART
VTWEG_AUFT
ERDAT FROM VBRP INTO TABLE IT_VBRP
FOR ALL ENTRIES IN IT_VBFA WHERE VBELN = IT_VBFA-VBELN AND
VKORG_AUFT = S_VKORG AND
SPART = S_SPART AND
VTWEG_AUFT = S_VTWEG." AND ERDAT IN S_AUDAT.
ENDFORM. " GET_DATA3
*&---------------------------------------------------------------------*
*& Form BUILD_LISTHEADER_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_LISTHEADER text
*----------------------------------------------------------------------*
FORM BUILD_LISTHEADER_3 USING P_IT_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM. " BUILD_LISTHEADER_3
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_VBRP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_GRID_VBRP .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'CONTRACT AND BILLING SECONDARY LIST'
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_VBRP
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_GRID_VBRP
No comments:
Post a Comment