REPORT ZSDRM001 LINE-SIZE 225 LINE-COUNT 65
NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
* Shipment list (2) add sort by material no not by customer no.
* request by Hsih Shi plant Angela #500
* add 'L2' by Lydia Liu
*----------------------------------------------------------------------*
TABLES: LIPS,
LIKP,
MAKT,
VBAK,
VBAP,
VBRK,
VBRP,
VBFA,
VBPA,
KONV,
MARA,
MARC,
ZV3RDP,
KNA1,
VBUP,
EKPO.
* Selection Criteria
SELECTION-SCREEN BEGIN OF BLOCK BLOCK WITH FRAME
TITLE TEXT-001.
SELECT-OPTIONS: KUNNR FOR VBAK-KUNNR. "Sold to party
SELECT-OPTIONS: LAND1 FOR KNA1-LAND1. "Country key
SELECT-OPTIONS: KUNNR_SH FOR VBAK-KUNNR. "Ship to party
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: AUART FOR ZV3RDP-AUART, "Sales doc. type
VKORG FOR ZV3RDP-VKORG NO-EXTENSION NO INTERVALS,
VTWEG FOR ZV3RDP-VTWEG, "Channel
SPART FOR ZV3RDP-SPART. "Division
SELECT-OPTIONS: VKGRP FOR VBAK-VKGRP. "Sales group
SELECT-OPTIONS: SALES FOR VBPA-PERNR. "Sales Employee
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: PRDHA FOR MARA-PRDHA. "Product hierarchy
SELECT-OPTIONS: MATNO FOR MARA-MATNR. "Material no.
PARAMETER: WERKS LIKE MARC-WERKS. "* Plant
PARAMETER: PLANT(10) TYPE C. "China plant
SELECTION-SCREEN END OF BLOCK BLOCK.
* Date period
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1 WITH FRAME
TITLE TEXT-002.
SELECT-OPTIONS: FKDAT FOR VBRK-FKDAT DEFAULT SY-DATUM TO SY-DATUM.
SELECTION-SCREEN END OF BLOCK BLOCK1.
SELECTION-SCREEN BEGIN OF BLOCK BLOCK2 WITH FRAME
TITLE TEXT-003.
PARAMETERS CUST RADIOBUTTON GROUP GRP.
PARAMETERS MATNR RADIOBUTTON GROUP GRP.
PARAMETERS SHIP RADIOBUTTON GROUP GRP.
PARAMETERS SUMM AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK BLOCK2.
DATA NETWR_D LIKE VBRP-NETWR.
DATA VRKME_D LIKE LIPS-VRKME.
DATA FKIMG_D LIKE VBRP-FKIMG.
DATA WAERK_D LIKE VBFA-WAERS.
DATA KUNAG_D LIKE VBRK-KUNAG.
DATA MATNR_D LIKE MARA-MATNR.
DATA VTWEG_H LIKE VBRK-VTWEG.
DATA SPART_H LIKE VBRK-SPART.
DATA VKORG_H LIKE VBRK-VKORG.
DATA TEMP(20) TYPE C.
DATA: INDEX LIKE SY-INDEX.
DATA TEXT LIKE THEAD-TDNAME.
DATA LIN TYPE P.
DATA AUART_P LIKE VBAK-AUART.
DATA PERNR LIKE VBPA-PERNR.
DATA: BEGIN OF ORDER OCCURS 10,
KUNNR LIKE VBAK-KUNNR, "sold-to party
VBELN LIKE VBAP-VBELN, "SO no.
POSNR LIKE VBAP-POSNR, "SO item no.
INVNO LIKE VBRP-VBELN, "Invoice no.
INVIT LIKE VBRP-POSNR, "Invoice item no.
FKDAT LIKE VBRK-FKDAT,
VKORG LIKE VBAK-VKORG,
VTWEG LIKE VBAK-VTWEG,
SPART LIKE VBAK-SPART,
MATNR LIKE VBRP-MATNR,
PRDHA LIKE MARA-PRDHA,
UNIPR(13) TYPE P DECIMALS 4,
NETWR LIKE VBRP-NETWR,
WAERK LIKE VBRK-WAERK,
FKIMG LIKE VBRP-FKIMG,
VRKME LIKE VBRP-VRKME,
SALES LIKE P0002-PERNR,
LAND1 LIKE KNA1-LAND1,
ZTERM LIKE VBRK-ZTERM,
* zfbdt like bseg-zfbdt,
KTGRD LIKE VBRK-KTGRD,
KTGRM LIKE VBRP-KTGRM,
PRCTR LIKE VBRP-PRCTR,
SHIP LIKE VBPA-KUNNR,
END OF ORDER.
DATA: BEGIN OF ITAB OCCURS 10,
KUNNR LIKE VBAK-KUNNR,
SHIP LIKE VBAK-KUNNR,
MATNR LIKE MARA-MATNR,
NAME1 LIKE KNA1-NAME1,
FKIMG_D LIKE VBRP-FKIMG,
VRKME_D LIKE LIPS-VRKME,
NETWR_D LIKE VBFA-RFWRT,
WAERK_D LIKE VBFA-WAERS,
END OF ITAB.
DATA: BEGIN OF MATKL OCCURS 0,
SIGN(1),
OPTION(2),
LOW LIKE MARA-MATKL,
HIGH LIKE MARA-MATKL,
END OF MATKL.
DATA: BEGIN OF INLINES OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF INLINES.
DATA: BEGIN OF LINES OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF LINES.
INITIALIZATION.
CLEAR SUMM.
CLEAR VKORG. REFRESH VKORG.
CLEAR VTWEG. REFRESH VTWEG.
CLEAR SPART. REFRESH SPART.
CLEAR KUNNR. REFRESH KUNNR.
CLEAR LAND1. REFRESH LAND1.
CLEAR VKGRP. REFRESH VKGRP.
CLEAR SALES. REFRESH SALES.
CLEAR PRDHA. REFRESH PRDHA.
CLEAR FKDAT. REFRESH VKORG.
CLEAR AUART. REFRESH AUART.
CLEAR MATKL. REFRESH MATKL.
CLEAR WERKS.
START-OF-SELECTION.
CASE WERKS.
WHEN 'PM01'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX2'.
APPEND VKORG.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'OR'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'OR'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'DR'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'DR'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'SD'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'SD'.
APPEND AUART.
WHEN 'PM02'.
DESCRIBE TABLE VKORG LINES LIN.
IF LIN EQ 0.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX1'.
APPEND VKORG.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX4'.
APPEND VKORG.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'OR'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'OR'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'DR'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'DR'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'SD'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'SD'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'Z3B'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'Z3B'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'ZBSD'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "AUArt-low = 'ZBSD'.
APPEND AUART.
WHEN 'PM05'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX3'.
APPEND VKORG.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'OR'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'OR'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'DR'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'DR'.
APPEND AUART.
CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
EXPORTING
INPUT = 'SD'
IMPORTING
OUTPUT = AUART-LOW
EXCEPTIONS
OTHERS = 1.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. "auart-low = 'SD'.
APPEND AUART.
ENDCASE.
CASE PLANT.
WHEN 'OA'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX1'.
APPEND VKORG.
SPART-SIGN = 'I'. SPART-OPTION = 'EQ'. SPART-LOW = '01'.
APPEND SPART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
WHEN 'PROJECTOR'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX1'.
APPEND VKORG.
SPART-SIGN = 'I'. SPART-OPTION = 'EQ'. SPART-LOW = '02'.
APPEND SPART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
WHEN 'SCANNER'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX2'.
APPEND VKORG.
SPART-SIGN = 'I'. SPART-OPTION = 'EQ'. SPART-LOW = '03'.
APPEND SPART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
WHEN 'MOUSE'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX3'.
APPEND VKORG.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
WHEN 'TELEPHONE'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX4'.
APPEND VKORG.
SPART-SIGN = 'I'. SPART-OPTION = 'EQ'. SPART-LOW = '07'.
APPEND SPART.
MATKL-SIGN = 'I'. MATKL-OPTION = 'EQ'. MATKL-LOW = 'TELEPHONE'.
APPEND MATKL.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
WHEN 'CELLUAR'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX4'.
APPEND VKORG.
SPART-SIGN = 'I'. SPART-OPTION = 'EQ'. SPART-LOW = '07'.
APPEND SPART.
MATKL-SIGN = 'I'. MATKL-OPTION = 'EQ'. MATKL-LOW = 'CELLUAR'.
APPEND MATKL.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
WHEN 'SURGE'.
VKORG-SIGN = 'I'. VKORG-OPTION = 'EQ'. VKORG-LOW = 'PMX4'.
APPEND VKORG.
SPART-SIGN = 'I'. SPART-OPTION = 'EQ'. SPART-LOW = '08'.
APPEND SPART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3R'.
APPEND AUART.
AUART-SIGN = 'I'. AUART-OPTION = 'EQ'. AUART-LOW = 'Z3SD'.
APPEND AUART.
ENDCASE.
IF AUART-LOW NE 'KN'.
SELECT * FROM VBRK WHERE VKORG IN VKORG
AND VTWEG IN VTWEG
AND SPART IN SPART
AND FKDAT IN FKDAT"Billing date in date period
AND FKART IN ('F1', 'F2', 'L2','ZF2')
AND FKSTO NE 'X'"Billing doc not cancel
AND KUNAG IN KUNNR "sold-to-party
ORDER BY VTWEG SPART KUNAG VBELN.
SELECT * FROM VBRP WHERE VBELN EQ VBRK-VBELN
AND MATNR IN MATNO.
*get SO no.
SELECT SINGLE AUART VKGRP INTO (VBAK-AUART, VBAK-VKGRP)
FROM VBAK WHERE VBELN EQ VBRP-AUBEL.
*get Sales employee
SELECT SINGLE PERNR FROM VBPA INTO PERNR
WHERE VBELN EQ VBRP-AUBEL
AND POSNR EQ '000000'
AND PARVW EQ 'VE'.
*get product hierarchy
SELECT SINGLE PRDHA FROM MARA INTO MARA-PRDHA
WHERE MATNR EQ VBRP-MATNR.
*get Ship-to party country key
SELECT SINGLE KUNNR FROM VBPA INTO VBPA-KUNNR
WHERE VBELN EQ VBRP-AUBEL
AND POSNR EQ '000000'
AND PARVW EQ 'WE'.
SELECT SINGLE LAND1 FROM KNA1 INTO KNA1-LAND1
WHERE KUNNR EQ VBPA-KUNNR.
IF MARA-PRDHA IN PRDHA
AND VBAK-VKGRP IN VKGRP
AND VBAK-AUART IN AUART
AND PERNR IN SALES
AND KNA1-LAND1 IN LAND1
AND MARA-MATKL IN MATKL
AND VBPA-KUNNR IN KUNNR_SH.
CLEAR ORDER.
* order-unipr = vbrp-netwr / vbrp-fkimg.
ORDER-KUNNR = VBRK-KUNAG. "sold-to party
ORDER-VBELN = VBRP-AUBEL.
ORDER-POSNR = VBRP-AUPOS.
ORDER-INVNO = VBRP-VBELN.
ORDER-INVIT = VBRP-POSNR.
ORDER-VKORG = VBRK-VKORG.
ORDER-VTWEG = VBRK-VTWEG.
ORDER-SPART = VBRK-SPART.
ORDER-FKDAT = VBRK-FKDAT.
ORDER-MATNR = VBRP-MATNR.
ORDER-PRDHA = MARA-PRDHA.
ORDER-NETWR = VBRP-NETWR.
ORDER-WAERK = VBRK-WAERK.
ORDER-FKIMG = VBRP-FKIMG.
ORDER-VRKME = VBRP-VRKME.
ORDER-SALES = VBPA-PERNR.
ORDER-LAND1 = KNA1-LAND1.
ORDER-ZTERM = VBRK-ZTERM.
ORDER-KTGRD = VBRK-KTGRD.
ORDER-KTGRM = VBRP-KTGRM.
ORDER-PRCTR = VBRP-PRCTR.
ORDER-SHIP = VBPA-KUNNR.
PERFORM CHECK_RE_ORDER.
WRITE ORDER-NETWR CURRENCY ORDER-WAERK TO TEMP.
DO.
REPLACE ',' WITH '' INTO TEMP.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
ENDDO.
CONDENSE TEMP NO-GAPS.
SHIFT TEMP RIGHT DELETING TRAILING SPACE.
ORDER-UNIPR = TEMP / ORDER-FKIMG.
* perform chk_ar_due_date.
* perform get_profit_center.
APPEND ORDER.
ENDIF.
ENDSELECT.
ENDSELECT.
ELSE.
SELECT * FROM VBAK
WHERE VKORG IN VKORG
AND VTWEG IN VTWEG
AND SPART IN SPART
AND AUART = 'KN'
AND KUNNR IN KUNNR
AND LIFSK = SPACE
AND VBTYP = 'I'.
SELECT * FROM VBAP
WHERE VBELN = VBAK-VBELN
AND ABGRU = SPACE
AND FAKSP = SPACE
AND MATNR IN MATNO.
SELECT SINGLE * FROM VBUP
WHERE VBELN = VBAK-VBELN
AND POSNR = VBAP-POSNR
AND GBSTA IN ('B','C').
CHECK SY-SUBRC = 0.
SELECT * FROM VBFA
WHERE VBELV = VBAP-VBELN
AND POSNV = VBAP-POSNR
AND VBTYP_N = 'R'
AND VBTYP_V = 'I'
AND ERDAT IN FKDAT.
* SELECT * FROM LIKP
* WHERE VBELN = VBFA-VBELN
* AND WADAT IN FKDAT
* AND KUNNR IN KUNNR_SH.
CHECK SY-SUBRC = 0.
*get Sales employee
SELECT SINGLE PERNR FROM VBPA INTO PERNR
WHERE VBELN EQ VBAK-VBELN
AND POSNR EQ '000000'
AND PARVW EQ 'VE'.
*get product hierarchy
SELECT SINGLE PRDHA FROM MARA INTO MARA-PRDHA
WHERE MATNR EQ VBAP-MATNR.
*get Ship-to party country key
SELECT SINGLE KUNNR FROM VBPA INTO VBPA-KUNNR
WHERE VBELN EQ VBAP-VBELN
AND POSNR EQ '000000'
AND PARVW EQ 'WE'.
SELECT SINGLE LAND1 FROM KNA1 INTO KNA1-LAND1
WHERE KUNNR EQ VBPA-KUNNR.
IF MARA-PRDHA IN PRDHA
AND VBAK-VKGRP IN VKGRP
AND VBAK-AUART IN AUART
AND PERNR IN SALES
AND KNA1-LAND1 IN LAND1
AND MARA-MATKL IN MATKL
AND VBPA-KUNNR IN KUNNR_SH.
CLEAR ORDER.
ORDER-KUNNR = VBAK-KUNNR. "sold-to party
ORDER-VBELN = VBAK-VBELN.
ORDER-POSNR = VBRP-POSNR.
ORDER-INVNO = VBFA-VBELN.
ORDER-INVIT = VBFA-POSNN.
ORDER-VKORG = VBAK-VKORG.
ORDER-VTWEG = VBAK-VTWEG.
ORDER-SPART = VBAK-SPART.
ORDER-FKDAT = VBFA-ERDAT.
ORDER-MATNR = VBAP-MATNR.
ORDER-PRDHA = MARA-PRDHA.
* ORDER-NETWR = VBRP-NETWR.
* ORDER-WAERK = VBRK-WAERK.
ORDER-FKIMG = VBFA-RFMNG.
ORDER-VRKME = VBAP-VRKME.
ORDER-SALES = VBPA-PERNR.
ORDER-LAND1 = KNA1-LAND1.
* ORDER-ZTERM = VBRK-ZTERM.
* ORDER-KTGRD = VBRK-KTGRD.
* ORDER-KTGRM = VBRP-KTGRM.
ORDER-PRCTR = VBAP-PRCTR.
ORDER-SHIP = VBPA-KUNNR.
APPEND ORDER.
ENDIF.
ENDSELECT.
ENDSELECT.
ENDSELECT.
* ENDSELECT.
ENDIF.
* get good issue for SD, ZBSD
PERFORM GET_GI_DATA.
IF NOT CUST IS INITIAL.
SORT ORDER BY KUNNR VBELN POSNR.
ENDIF.
IF NOT MATNR IS INITIAL.
SORT ORDER BY MATNR VBELN POSNR.
ENDIF.
IF NOT SHIP IS INITIAL.
SORT ORDER BY SHIP VBELN POSNR.
ENDIF.
LOOP AT ORDER.
* sort by customer (sold-to party)
IF NOT CUST IS INITIAL.
ON CHANGE OF ORDER-KUNNR.
SELECT SINGLE NAME1 FROM KNA1 INTO KNA1-NAME1
WHERE KUNNR EQ ORDER-KUNNR.
IF SY-TABIX NE 1.
IF SUMM IS INITIAL.
ULINE.
WRITE: /37(13) '***Subtotal'.
CLEAR INDEX.
LOOP AT ITAB WHERE KUNNR EQ KUNAG_D.
INDEX = INDEX + 1.
IF INDEX EQ 1.
WRITE: 50(20) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ELSE.
WRITE:/50(20) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ENDIF.
WRITE: 70(3) ITAB-VRKME_D,
103(21) ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124(3) ITAB-WAERK_D.
ENDLOOP.
SKIP 2.
ENDIF.
ENDIF.
IF SUMM IS INITIAL.
WRITE: /1 '***Customer:',
15(10) ORDER-KUNNR,
26(40) KNA1-NAME1.
ENDIF.
ENDON.
* matnr_d = order-matnr.
KUNAG_D = ORDER-KUNNR.
ITAB-KUNNR = ORDER-KUNNR.
* itab-matnr = order-matnr.
ITAB-FKIMG_D = ORDER-FKIMG.
ITAB-VRKME_D = ORDER-VRKME.
ITAB-NETWR_D = ORDER-NETWR.
ITAB-WAERK_D = ORDER-WAERK.
ITAB-NAME1 = KNA1-NAME1.
COLLECT ITAB.
CLEAR: FKIMG_D,
VRKME_D,
NETWR_D,
WAERK_D.
ENDIF.
* sort by material no.
IF NOT MATNR IS INITIAL.
ON CHANGE OF ORDER-MATNR.
SELECT SINGLE * FROM MAKT WHERE MATNR EQ ORDER-MATNR
AND SPRAS EQ SY-LANGU.
IF SY-TABIX NE 1.
IF SUMM IS INITIAL.
ULINE.
WRITE: /37(13) '***Subtotal'.
CLEAR INDEX.
LOOP AT ITAB WHERE MATNR EQ MATNR_D.
INDEX = INDEX + 1.
IF INDEX EQ 1.
WRITE: 50(20) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ELSE.
WRITE:/50(20) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ENDIF.
WRITE: 70(3) ITAB-VRKME_D,
103(21) ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124(3) ITAB-WAERK_D.
ENDLOOP.
SKIP 2.
ENDIF.
ENDIF.
IF SUMM IS INITIAL.
WRITE: /1 'Material:',
12(18) ORDER-MATNR,
31(40) MAKT-MAKTX.
* 70 itab-fkimg_d,
* 91(3) itab-vrkme_d.
ENDIF.
* endif.
ENDON.
MATNR_D = ORDER-MATNR.
* kunag_d = order-kunnr.
* itab-kunnr = order-kunnr.
ITAB-MATNR = ORDER-MATNR.
ITAB-FKIMG_D = ORDER-FKIMG.
ITAB-VRKME_D = ORDER-VRKME.
ITAB-NETWR_D = ORDER-NETWR.
ITAB-WAERK_D = ORDER-WAERK.
ITAB-NAME1 = KNA1-NAME1.
COLLECT ITAB.
CLEAR: FKIMG_D,
VRKME_D,
NETWR_D,
WAERK_D.
ENDIF.
* sort by ship-to party + SO no.
IF NOT SHIP IS INITIAL.
ON CHANGE OF ORDER-SHIP.
SELECT SINGLE NAME1 FROM KNA1 INTO KNA1-NAME1
WHERE KUNNR EQ ORDER-SHIP.
IF SY-TABIX NE 1.
IF SUMM IS INITIAL.
ULINE.
WRITE: /37(13) '***Subtotal'.
CLEAR INDEX.
LOOP AT ITAB WHERE SHIP EQ KUNAG_D.
INDEX = INDEX + 1.
IF INDEX EQ 1.
WRITE: 50(20) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ELSE.
WRITE:/50(20) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ENDIF.
WRITE: 70(3) ITAB-VRKME_D,
103(21) ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124(3) ITAB-WAERK_D.
ENDLOOP.
SKIP 2.
ENDIF.
ENDIF.
IF SUMM IS INITIAL.
WRITE: /1 '***Ship-to Party:',
18(10) ORDER-SHIP,
29(40) KNA1-NAME1.
ENDIF.
ENDON.
* matnr_d = order-matnr.
KUNAG_D = ORDER-SHIP.
ITAB-SHIP = ORDER-SHIP.
* itab-matnr = order-matnr.
ITAB-FKIMG_D = ORDER-FKIMG.
ITAB-VRKME_D = ORDER-VRKME.
ITAB-NETWR_D = ORDER-NETWR.
ITAB-WAERK_D = ORDER-WAERK.
ITAB-NAME1 = KNA1-NAME1.
COLLECT ITAB.
CLEAR: FKIMG_D,
VRKME_D,
NETWR_D,
WAERK_D.
ENDIF.
ON CHANGE OF VBRK-VKORG OR VBRK-VTWEG OR VBRK-SPART.
VKORG_H = ORDER-VKORG.
VTWEG_H = ORDER-VTWEG.
SPART_H = ORDER-SPART.
IF SY-TABIX NE 1.
NEW-PAGE.
ENDIF.
ENDON.
* get customer PO
SELECT SINGLE * FROM VBAK WHERE VBELN EQ ORDER-VBELN.
SELECT SINGLE * FROM VBAP WHERE VBELN EQ ORDER-VBELN
AND POSNR EQ ORDER-POSNR.
* get bill-to party
SELECT SINGLE * FROM VBPA WHERE VBELN EQ ORDER-VBELN
AND POSNR EQ '000000'
AND PARVW EQ 'RE'.
*get PO no.
CLEAR VBFA.
SELECT * FROM VBFA WHERE VBELV EQ ORDER-VBELN
AND POSNV EQ ORDER-POSNR
AND VBTYP_N EQ 'V'.
CLEAR EKPO.
SELECT SINGLE * FROM EKPO WHERE EBELN EQ VBFA-VBELN
AND EBELP EQ VBFA-POSNN.
CHECK EKPO-LOEKZ NE SPACE.
ENDSELECT.
IF SUMM IS INITIAL.
WRITE: /1(10) ORDER-VBELN, "SO no.
12(06) ORDER-POSNR, "SO item no.
* 19(20) vbak-bstnk, "Customer PO no.
19(10) ORDER-SHIP,
40(22) VBAP-KDMAT, "Customer Mater no.
53(17) ORDER-FKIMG UNIT ORDER-VRKME, "Deli. qty
70(3) ORDER-VRKME, "Sale unit
74(16) ORDER-UNIPR, " currency order-waerk, "Unit price
90(3) ORDER-WAERK, "Unit price currency
103(21) ORDER-NETWR CURRENCY ORDER-WAERK, "Amount of the item
124(3) ORDER-WAERK, "Currency
129(10) ORDER-INVNO, "Billing doc.
140(10) ORDER-FKDAT, "Billing date
151(10) EKPO-EBELN. "PO no.
IF NOT CUST IS INITIAL.
WRITE: 162(18) ORDER-MATNR. "Material no.
ELSEIF NOT MATNR IS INITIAL.
WRITE: 162(10) ORDER-KUNNR. "Sold-to party
ELSEIF NOT SHIP IS INITIAL.
WRITE: 162(18) ORDER-MATNR. "Material no.
ENDIF.
WRITE: 181(10) VBPA-KUNNR. "Invoice to party
CLEAR LINES. REFRESH LINES.
CLEAR INLINES. REFRESH INLINES.
CLEAR TEXT.
CONCATENATE ORDER-VBELN ORDER-POSNR INTO TEXT.
CALL FUNCTION 'READ_TEXT_INLINE'
EXPORTING
ID = '0011'
INLINE_COUNT = 10
LANGUAGE = SY-LANGU
NAME = TEXT
OBJECT = 'VBBP'
* importing
* header =
TABLES
INLINES = INLINES
LINES = LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
OTHERS = 7.
READ TABLE LINES INDEX 1.
IF LINES-TDLINE EQ SPACE.
WRITE: 192(10) 'Sea'.
ELSE.
WRITE: 192(10) LINES-TDLINE(10).
ENDIF.
ENDIF.
WRITE: 203(04) ORDER-ZTERM.
* write: 208(10) order-zfbdt.
WRITE: 208(10) ORDER-PRCTR.
WRITE: 219(02) ORDER-KTGRD.
WRITE: 222(02) ORDER-KTGRM.
IF NOT SHIP IS INITIAL.
KUNAG_D = ORDER-SHIP.
ELSE.
KUNAG_D = ORDER-KUNNR.
ENDIF.
MATNR_D = ORDER-MATNR.
FKIMG_D = FKIMG_D + ORDER-FKIMG.
VRKME_D = ORDER-VRKME.
NETWR_D = NETWR_D + ORDER-NETWR.
WAERK_D = ORDER-WAERK.
ENDLOOP.
IF SUMM IS INITIAL.
ULINE.
CLEAR INDEX.
WRITE: /40(13) '***Subtotal'.
IF NOT CUST IS INITIAL.
LOOP AT ITAB WHERE KUNNR EQ ORDER-KUNNR.
INDEX = INDEX + 1.
IF INDEX EQ 1.
WRITE: 53(17) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ELSE.
WRITE:/53(17) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ENDIF.
WRITE: 70(3) ITAB-VRKME_D,
103(21) ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124(3) ITAB-WAERK_D.
ENDLOOP.
ELSEIF NOT MATNR IS INITIAL.
LOOP AT ITAB WHERE MATNR EQ ORDER-MATNR.
INDEX = INDEX + 1.
IF INDEX EQ 1.
WRITE: 53(17) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ELSE.
WRITE:/53(17) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ENDIF.
WRITE: 70(3) ITAB-VRKME_D,
103(21) ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124(3) ITAB-WAERK_D.
ENDLOOP.
ELSEIF NOT SHIP IS INITIAL.
LOOP AT ITAB WHERE SHIP EQ ORDER-SHIP .
INDEX = INDEX + 1.
IF INDEX EQ 1.
WRITE: 53(17) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ELSE.
WRITE:/53(17) ITAB-FKIMG_D UNIT ITAB-VRKME_D.
ENDIF.
WRITE: 70(3) ITAB-VRKME_D,
103(21) ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124(3) ITAB-WAERK_D.
ENDLOOP.
ENDIF.
ENDIF.
IF NOT CUST IS INITIAL.
ITAB-KUNNR = ORDER-KUNNR.
ENDIF.
IF NOT MATNR IS INITIAL.
ITAB-MATNR = ORDER-MATNR.
ENDIF.
IF NOT SHIP IS INITIAL.
ITAB-SHIP = ORDER-SHIP.
ENDIF.
IF SUMM IS INITIAL.
NEW-PAGE.
CLEAR: FKIMG_D, NETWR_D, VRKME_D.
ENDIF.
LOOP AT ITAB.
IF NOT CUST IS INITIAL.
SELECT SINGLE NAME1 FROM KNA1 INTO ITAB-NAME1
WHERE KUNNR EQ ITAB-KUNNR.
WRITE: /1 ITAB-KUNNR,
19 ITAB-NAME1.
ELSEIF NOT MATNR IS INITIAL.
SELECT SINGLE MAKTX FROM MAKT INTO ITAB-NAME1
WHERE MATNR EQ ITAB-MATNR
AND SPRAS EQ SY-LANGU.
WRITE: /1 ITAB-MATNR,
19 ITAB-NAME1.
ELSEIF NOT SHIP IS INITIAL.
SELECT SINGLE NAME1 FROM KNA1 INTO ITAB-NAME1
WHERE KUNNR EQ ITAB-SHIP.
WRITE: /1 ITAB-SHIP,
19 ITAB-NAME1.
ENDIF.
WRITE: 53 ITAB-FKIMG_D UNIT ITAB-VRKME_D,
70 ITAB-VRKME_D,
103 ITAB-NETWR_D CURRENCY ITAB-WAERK_D,
124 ITAB-WAERK_D.
ENDLOOP.
SKIP.
WRITE: /1 'Total:'.
CLEAR: FKIMG_D, NETWR_D.
SORT ITAB BY WAERK_D.
LOOP AT ITAB.
ON CHANGE OF ITAB-WAERK_D.
IF SY-TABIX NE 1.
WRITE: /53 FKIMG_D UNIT VRKME_D,
70 VRKME_D,
103 NETWR_D CURRENCY WAERK_D,
124 WAERK_D.
CLEAR: FKIMG_D,
NETWR_D,
VRKME_D,
WAERK_D.
ENDIF.
ENDON.
FKIMG_D = FKIMG_D + ITAB-FKIMG_D.
VRKME_D = ITAB-VRKME_D.
NETWR_D = NETWR_D + ITAB-NETWR_D.
WAERK_D = ITAB-WAERK_D.
ENDLOOP.
WRITE: /53 FKIMG_D UNIT ITAB-VRKME_D,
70 ITAB-VRKME_D,
103 NETWR_D CURRENCY ITAB-WAERK_D,
124 ITAB-WAERK_D.
TOP-OF-PAGE.
WRITE: /100 'Shipment List'.
WRITE: /80 'Sales Org:',
94 VKORG_H,
100 'Channel:',
109 VTWEG_H,
115 'Division:',
125 SPART_H.
WRITE: /90 'Date from:',
101 FKDAT-LOW,
113 'to:',
117 FKDAT-HIGH.
WRITE: /1 'Date:', 6 SY-DATUM,
210 'Page:', 216 SY-PAGNO,
/210 'User:', 216 SY-UNAME.
SKIP.
WRITE: /1(10) 'SO No.',
12(06) 'ItemNo',
* 19(20) 'Customer PO No.',
40(22) 'Customer Mater No.',
60(10) 'Deli. Qty',
* 70(3) "Sale unit
83(10) 'Unit Price',
* 90(3) konp-konwa, "Unit price currency
* 93(1) '/',
* 94(5) konp-kpein, "by
* 99(3) konp-kmein, "by unit
120(10) 'Amount',
* 124(3) vbfa-waers, "Currency
129(10) 'BillingDoc',
140(10) 'BillingDat',
151(10) 'PO no.'.
IF NOT CUST IS INITIAL.
WRITE: 162(18) 'Material No.'.
ELSEIF NOT MATNR IS INITIAL.
WRITE: 162(18) 'Customer No.'.
ELSEIF NOT SHIP IS INITIAL.
WRITE: 162(18) 'Material No.'.
ENDIF.
WRITE: 181(10) 'InvoiceTo'.
WRITE: 192(10) 'ShipMethod'.
WRITE: 203(04) 'PayT'.
* write: 208(10) 'Due Date'.
WRITE: 208(10) 'ProfitCter'.
WRITE: 219(02) 'CA'.
WRITE: 222(02) 'MA'.
WRITE: 19(10) 'ShipToPar.'.
ULINE.
*&---------------------------------------------------------------------*
*& Form CHECK_RE_ORDER
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_RE_ORDER.
* get RE good return material doc no. only those ref. billing doc
SELECT SINGLE VBELN FROM VBFA INTO VBFA-VBELN
WHERE VBELV EQ VBRK-VBELN
AND POSNV EQ '000000'
AND POSNN EQ '000000'
AND VBTYP_N EQ 'H'. "return
IF SY-SUBRC EQ 0.
SELECT VBELN POSNN RFMNG FROM VBFA
INTO (VBFA-VBELN, VBFA-POSNN, VBFA-RFMNG)
WHERE VBELV EQ VBRK-VBELN
AND POSNV EQ '000000'
AND VBTYP_N EQ 'R'
AND BWART EQ '651'.
ORDER-FKIMG = ORDER-FKIMG - VBFA-RFMNG.
ENDSELECT.
ENDIF.
* get credit memo.
SELECT VBELN POSNN FROM VBFA INTO (VBFA-VBELN, VBFA-POSNN)
WHERE VBELV EQ VBRP-AUBEL
AND POSNV EQ VBRP-AUPOS
AND VBTYP_N EQ 'O'.
SELECT SINGLE FKSTO FKDAT INTO (VBRK-FKSTO, VBRK-FKSTO)
FROM VBRK
WHERE VBELN EQ VBFA-VBELN.
CHECK VBRK-FKSTO EQ SPACE AND VBRK-FKDAT IN FKDAT.
SELECT SINGLE NETWR FROM VBRP INTO VBRP-NETWR
WHERE VBELN EQ VBFA-VBELN
AND POSNR EQ VBFA-POSNN.
IF SY-SUBRC EQ 0.
ORDER-NETWR = ORDER-NETWR - VBRP-NETWR.
ENDIF.
ENDSELECT.
* get debit memo.
SELECT VBELN POSNN FROM VBFA INTO (VBFA-VBELN, VBFA-POSNN)
WHERE VBELV EQ VBRP-AUBEL
AND POSNV EQ VBRP-AUPOS
AND VBTYP_N EQ 'P'.
SELECT SINGLE NETWR FROM VBRP INTO VBRP-NETWR
WHERE VBELN EQ VBFA-VBELN
AND POSNR EQ VBFA-POSNN.
IF SY-SUBRC EQ 0.
ORDER-NETWR = ORDER-NETWR + VBRP-NETWR.
ENDIF.
ENDSELECT.
ENDFORM. " CHECK_RE_ORDER
*&---------------------------------------------------------------------*
*& Form GET_GI_DATA
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_GI_DATA.
ENDFORM. " GET_GI_DATA
*&---------------------------------------------------------------------*
*& Form CHK_AR_DUE_DATE
*&---------------------------------------------------------------------*
* text *
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHK_AR_DUE_DATE.
TABLES: BSEG.
* clear order-zfbdt.
IF VBRK-RFBSK EQ 'C'.
SELECT ZFBDT ZBD1T UP TO 1 ROWS FROM BSEG
INTO (BSEG-ZFBDT, BSEG-ZBD1T)
WHERE VBELN EQ VBRK-VBELN
AND BUKRS EQ VBRK-BUKRS.
ENDSELECT.
* order-zfbdt = bseg-zfbdt + bseg-zbd1t.
ENDIF.
ENDFORM. " CHK_AR_DUE_DATE