TABLES:EKKO,"PURCHASE DOCUMENT HEADER
EKPO,"PURCHASE DOCUMENT ITEM
EKBE."PURCHASE DOCUMENT HISTORY
**************************************END OF TABLES DECLARATION*****************************************************
*******************************************TYPES DECLARATION*****************************************************
"TYPES DECLARATION FOR THE PURCHASE DOCUMENT HEADER
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EBELN,"PURCHASE ORDER NO
AEDAT TYPE ERDAT,"PURCHASE ORDER DATE
END OF TY_EKKO.
"TYPES DECLARATION OF THE PURCHASE DOCUMENT HISTORY
TYPES: BEGIN OF TY_EKBE,
EBELN TYPE EBELN,"PURCHASE ORDER NO
WESBS TYPE WESBS,"GOODS RECEIPT
BWART TYPE BWART,"MOVEMENT TYPE
BELNR TYPE MBLNR,"MATERIAL DOC NUMBER
BUDAT TYPE BUDAT,"POSTING DATE
MENGE TYPE MENGE_D,"QUANTITY
LSMNG TYPE LSMNG,"BASIC UNIT OF MEASURE
EBELP TYPE EBELP,
END OF TY_EKBE.
"TYPES DECLARATION OF THE PURCHASE DOCUMENT ITEM
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EBELN, " Purchasing Document Number
EBELP TYPE EBELP, " Item Number of Purchasing Document
MENGE TYPE BSTMG, " Purchase Order Quantity
WESBS TYPE WESBS,"GOODS RECEIPT
BWART TYPE BWART,"MOVEMENT TYPE
BELNR TYPE MBLNR,"MATERIAL DOC NUMBER
BUDAT TYPE BUDAT,"POSTING DATE
LSMNG TYPE LSMNG,"BASIC UNIT OF MEASURE
END OF TY_EKPO.
****************************************end of types declaration***********************************************
*******************************************STRUCUTURE DECLARATION*************************************************
DATA:IS_EKPO TYPE TY_EKPO."STRUCURE DECLARATION FOR PURCHASE ORDER HEADER
DATA:IS_EKKO TYPE TY_EKKO."STRUCURE DECLARATION FOR PURCHASE ORDER ITEM
DATA:IS_EKBE TYPE TY_EKBE."STRUCURE DECLARATION FOR PURCHASE ORDER HISTORY
****************************************END OF STRUCUTRE DECLARATION***********************************************
***************************************INTERNAL TABLE DECLARATION***************************************************
DATA: IT_EKPO TYPE STANDARD TABLE OF TY_EKPO.
DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO.
DATA: IT_EKBE TYPE STANDARD TABLE OF TY_EKBE.
*************************************END OF INTERNAL TABLE DECLARATION*******************************************
*************************************SELECTION SCREEN DECLARATION**********************************************
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN,
S_BEDAT FOR EKKO-BEDAT .
SELECTION-SCREEN: END OF BLOCK B1.
START-OF-SELECTION.
PERFORM F_FETCH_DATA.
*PERFORM f_DISPLAY_DATA.
*&---------------------------------------------------------------------*
*& Form F_FETCH_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form F_FETCH_DATA .
SELECT EBELN FROM EKKO INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN AND
BEDAT IN S_BEDAT.
IF IT_EKKO[] IS NOT INITIAL.
SELECT EBELN EBELP MENGE FROM EKPO INTO TABLE
IT_EKPO
FOR ALL ENTRIES IN IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
ENDIF.
LOOP AT IT_EKPO INTO IS_EKPO.
SELECT SINGLE EBELN WESBS BWART BELNR BUDAT MENGE LSMNG FROM EKBE
INTO (IS_EKPO-EBELN,IS_EKPO-WESBS,IS_EKPO-BWART,IS_EKPO-BELNR,
IS_EKPO-BUDAT,IS_EKPO-MENGE,IS_EKPO-LSMNG)
WHERE EBELN = IS_EKPO-EBELN AND
EBELP = IS_EKPO-EBELP.
MODIFY IT_EKPO INDEX SY-TABIX FROM IS_EKPO
TRANSPORTING EBELN WESBS BWART BELNR BUDAT MENGE LSMNG.
ENDLOOP.