Posted: Sat Oct 13, 2007 12:43 pm Post subject: Stock report with date range
Code:
*DATA: ED TYPE F.
DATA : ED(15) TYPE N .
TABLES: EKKO, EKBE, EKPO, KONH , KONV ,LFA1 ,ESLL.
TYPE-POOLS: SLIS.
DATA: val1 like konh-vakey.
Data:GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
G_REPID LIKE SY-REPID,
G_GRID_TITLE TYPE LVC_TITLE.
Data:G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
DATA:G_TABNAME TYPE SLIS_TABNAME VALUE 'ITAB1',
G_SAVE .
DATA:GS_VARIANT LIKE DISVARIANT.
DATA:LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA:GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
G_SAVE = 'A'.
DATA: BEGIN OF ITAB OCCURS 10,
EBELN LIKE EKKO-EBELN,
* LIFNR like p_vendor,
LIFNR LIKE EKKO-LIFNR,
NAME1 LIKE LFA1-NAME1,
NAME2 LIKE LFA1-NAME2,
* EBELP LIKE EKBE-EBELP,
BELNR LIKE EKBE-BELNR,
VGABE LIKE EKBE-VGABE,
GJAHR LIKE EKBE-GJAHR,
KNUMV LIKE EKKO-KNUMV,
EKORG LIKE EKKO-EKORG,
BEDAT LIKE EKKO-BEDAT,
* VAKEY LIKE KONH-VAKEY,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 10,
NAME1 LIKE LFA1-NAME1,
NAME2 LIKE LFA1-NAME2,
EBELN LIKE EKPO-EBELN,
LIFNR LIKE EKKO-LIFNR,
EBELP LIKE EKPO-EBELP,
* EBELP LIKE EKBE-EBELP,
KNUMH LIKE KONH-KNUMH,
BELNR LIKE EKBE-BELNR,
MATNR LIKE EKPO-MATNR,
TXZ01 LIKE EKPO-TXZ01,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
EXTROW LIKE ESLL-EXTROW,
SRVPOS LIKE ESLL-SRVPOS,
KTEXT1 LIKE ESLL-KTEXT1,
KOSTL LIKE EKKN-KOSTL,
NETPR LIKE EKPO-NETPR,
NETWR LIKE EKPO-NETWR,
ED1 TYPE p decimals 2,
KBETR2 LIKE KONV-KBETR,
KBETR1 LIKE KONV-KBETR,
KBETR LIKE KONV-KBETR,
* KBETR3 LIKE KONV-KBETR,
KWERT LIKE KONV-KWERT, " THIS IS FOR FREIGHT
KWERT1 LIKE KONV-KWERT, " THIS IS FOR PBXX OR PB00
KWERT2 LIKE KONV-KWERT, " THIS FOR OTHER CONDITION
MENGE LIKE EKPO-MENGE,
* TOTAL(15) type .
TOTAL TYPE p decimals 2,
VAKEY LIKE KONH-VAKEY,
WERKS LIKE EKPO-WERKS,
MWSKZ LIKE EKPO-MWSKZ,
PACKNO LIKE EKPO-PACKNO,
KNUMV LIKE KONV-KNUMV,
SUB_PACKNO LIKE ESLL-SUB_PACKNO,
GJAHR LIKE RSEG-GJAHR,
END OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 10,
EBELN LIKE EKKN-EBELN,
EBELP LIKE EKKN-EBELP,
PS_PSP_PNR LIKE EKKN-PS_PSP_PNR,
KOSTL LIKE EKKN-KOSTL,
END OF ITAB2.
data: begin of itab3 occurs 10,
KNUMH LIKE KONH-KNUMH,
KSCHL LIKE KONH-KSCHL,
end of itab3.
data: begin of itab4 occurs 10,
KBETR LIKE KONP-KBETR,
end of itab4.
data: begin of itab5 occurs 10,
KPOSN LIKE KONV-KPOSN,
KNUMV LIKE KONV-KNUMV,
KSCHL LIKE KONV-KSCHL,
KBETR LIKE KONV-KBETR,
KWERT LIKE KONV-KWERT, " THIS IS FOR FREIGHT
* KAWRT LIKE KONV-KAWRT,
end of itab5.
DATA: BEGIN OF ITAB6 OCCURS 10,
* PACKNO LIKE EKPO-PACKNO,
SUB_PACKNO LIKE ESLL-SUB_PACKNO,
END OF ITAB6.
DATA: BEGIN OF ITAB7 OCCURS 10,
BELNR LIKE RSEG-BELNR,
GJAHR LIKE RSEG-GJAHR,
END OF ITAB7.
DATA: BEGIN OF ITAB8 OCCURS 10,
SUB_PACKNO LIKE ESLL-SUB_PACKNO,
SRVPOS LIKE ESLL-SRVPOS,
EXTROW LIKE ESLL-EXTROW,
KTEXT1 LIKE ESLL-KTEXT1,
END OF ITAB8.
******************
*selection-screen
******************
*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN SKIP 2.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 25(23) text-002.
**SELECT-OPTIONS: s_lifnr FOR ekko-lifnr.
*PARAMETERS:p_lifnr LIKE ekko-lifnr obligatory.
*SELECTION-SCREEN END OF LINE.
*
*SELECTION-SCREEN END OF BLOCK b1.
*
START-OF-SELECTION.
PERFORM get_data.
* PERFORM field_catalog.
* PERFORM display_data.
END-OF-SELECTION.
**&---------------------------------------------------------------------
**
**& Form display_data
**&---------------------------------------------------------------------
**
** text
**----------------------------------------------------------------------
**
*
SELECT A~EBELN A~LIFNR A~EKORG A~KNUMV B~VGABE B~GJAHR B~BELNR
L~NAME1 L~NAME2
FROM EKKO AS A
INNER JOIN EKBE AS B ON B~EBELN = A~EBELN
INNER JOIN LFA1 AS L ON L~LIFNR = A~LIFNR
INTO CORRESPONDING
FIELDS OF TABLE ITAB.
* WHERE B~VGABE = '2'.
SELECT EKPO~EBELN EKPO~EBELP EKPO~MATNR EKPO~TXZ01 EKPO~WERKS
EKPO~NETWR EKPO~MENGE EKPO~MWSKZ EKPO~NETPR EKPO~PACKNO
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE ITAB1
FOR ALL ENTRIES IN ITAB
WHERE EKPO~EBELN = ITAB-EBELN and
EKPO~BUKRS = 'company code'.
SELECT EKKN~EBELN EKKN~EBELP EKKN~KOSTL EKKN~PS_PSP_PNR
FROM EKKN
INTO CORRESPONDING FIELDS OF TABLE ITAB2
FOR ALL ENTRIES IN ITAB1
WHERE EKKN~EBELN = ITAB1-EBELN AND
EKKN~EBELP = ITAB1-EBELP.
SELECT KONV~KNUMV KONV~KSCHL KONV~KBETR KONV~KWERT KONV~KWERT
KONV~KPOSN
FROM KONV
INTO CORRESPONDING FIELDS OF TABLE ITAB5
WHERE KONV~KNUMV = ITAB1-KNUMV AND
KONV~KPOSN = ITAB1-EBELP.
* SELECT LFA1~NAME1 LFA1~NAME2 FROM LFA1
* INTO CORRESPONDING FIELDS OF TABLE ITAB1
* WHERE LFA1~LIFNR = ITAB-LIFNR.
* SELECT ESLL~SUB_PACKNO ESLL~SRVPOS
* ESLL~EXTROW ESLL~KTEXT1 FROM ESLL
*
* INTO CORRESPONDING FIELDS OF TABLE ITAB6
* FOR ALL ENTRIES IN ITAB1
* WHERE ESLL~PACKNO = ITAB1-PACKNO .
** SELECT ESLL~SUB_PACKNO FROM ESLL
** INTO CORRESPONDING FIELDS OF TABLE ITAB6
** FOR ALL ENTRIES IN ITAB1
** WHERE ESLL~PACKNO = ITAB1-PACKNO.
*
* SELECT ESLL~SUB_PACKNO ESLL~SRVPOS
* ESLL~EXTROW ESLL~KTEXT1 FROM ESLL
* INTO CORRESPONDING FIELDS OF TABLE ITAB8
* FOR ALL ENTRIES IN ITAB6
* WHERE ESLL~PACKNO = ITAB6-SUB_PACKNO .
*
* SELECT RSEG~BELNR RSEG~GJAHR FROM RSEG
* INTO CORRESPONDING FIELDS OF TABLE ITAB7
* FOR ALL ENTRIES IN ITAB
* WHERE RSEG~BELNR = ITAB-BELNR AND
* RSEG~GJAHR = ITAB-GJAHR.
*
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.