*&---------------------------------------------------------------------*
*& Report ZPPR013A *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZPPR013A NO STANDARD PAGE HEADING..
TABLES: LIKP, "SD Document: Delivery Header Data
LIPS, "SD document: Delivery: Item data
VBAK,
VBAP,
VBKD,
VBUK, "Sales Document: Header Status and Administrative Data
T001W,
KONH,
KONP,
KONV.
DATA: BEGIN OF ST_DN OCCURS 0,
VBELN LIKE LIKP-VBELN,
LFDAT LIKE LIKP-LFDAT,
DNMON(6) TYPE C,
KUNNR LIKE LIKP-KUNNR,
KUNAG LIKE LIKP-KUNAG,
WERKS LIKE LIPS-WERKS,
LGORT LIKE LIPS-LGORT,
POSNR LIKE LIPS-POSNR,
MATNR LIKE LIPS-MATNR,
MAKTX LIKE MAKT-MAKTX,
VFLAG(1) TYPE C,
LFIMG LIKE LIPS-LFIMG,
VRKME LIKE LIPS-VRKME,
VFACT TYPE P DECIMALS 2,
BUQTY LIKE LIPS-LFIMG,
MEINS LIKE LIPS-MEINS,
CHARG LIKE LIPS-CHARG,
NTGEW LIKE LIPS-NTGEW,
BRGEW LIKE LIPS-BRGEW,
VGBEL LIKE LIPS-VGBEL,
VGPOS LIKE LIPS-VGPOS,
NTPRI TYPE P DECIMALS 4,
WAERK LIKE VBAP-WAERK,
NTAMT LIKE VBAP-NETWR,
NTPR2 TYPE P DECIMALS 4, "SO PRICE USD
NTAM2 LIKE VBAP-NETWR, "SO AMOUNT USD
NTAM3 LIKE VBAP-NETWR, "SHIP AMOUNT USD
BSTKD LIKE VBKD-BSTKD,
WBSTK LIKE VBUK-WBSTK,
FKSTK LIKE VBUK-FKSTK,
INVNO LIKE VBRP-VBELN,
INMON(6) TYPE C,
FKDAT LIKE VBRK-FKDAT,
NETWR LIKE VBRP-NETWR,
END OF ST_DN.
DATA IT_DN LIKE ST_DN OCCURS 0 WITH HEADER LINE.
type-pools: slis.
data: i_fieldcat type slis_t_fieldcat_alv,
l_fieldcat type slis_fieldcat_alv,
xevents type slis_t_event,
is_event type slis_alv_event,
slis_ev_top type slis_formname value 'TOP-OF-PAGE',
v_repid type sy-repid,
gs_tab_head type slis_tabname.
SELECTION-SCREEN BEGIN OF BLOCK VEN WITH FRAME TITLE TEXT-100.
SELECT-OPTIONS:
WBS FOR LIPS-PS_PSP_PNR,
DNNO FOR LIKP-VBELN,
PDATE FOR LIKP-WADAT_IST,
MATNO FOR LIPS-MATNR,
PLANT FOR LIPS-WERKS,
LOCAT FOR LIPS-LGORT,
CUSTO FOR LIKP-KUNNR,
SALTO FOR LIKP-KUNAG,
SOTYP FOR VBAK-AUART,
SONO FOR LIPS-VGBEL,
GSTAT FOR VBUK-WBSTK,
BSTAT FOR VBUK-FKSTK.
* ISTAT FOR VBUK-FKIVK.
SELECTION-SCREEN SKIP.
PARAMETERS: BATCH TYPE C AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK VEN.
START-OF-SELECTION.
PERFORM GET_DATA.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = xevents
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.
read table xevents with key name = slis_ev_top into is_event.
if sy-subrc = 0.
move slis_ev_top to is_event-form.
append is_event to xevents.
endif.
gs_tab_head = 'ST_DN'.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = gs_tab_head
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = v_repid
CHANGING
CT_FIELDCAT = i_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM BUILD_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-HEAD'
i_callback_user_command = 'USER_COMMAND'
IT_FIELDCAT = i_fieldcat
I_SAVE = 'A'
IT_EVENTS = xevents
TABLES
T_OUTTAB = it_dn
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.
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF rs_selfield-fieldname EQ 'VBELN'.
READ TABLE IT_DN INDEX rs_selfield-tabindex.
SET PARAMETER ID: 'VL' FIELD IT_DN-VBELN.
CASE r_ucomm.
WHEN '&IC1'.
CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
ENDCASE.
ENDIF.
IF rs_selfield-fieldname EQ 'MATNR'.
SET PARAMETER ID 'MXX' FIELD 'K'.
READ TABLE IT_DN INDEX rs_selfield-tabindex.
SET PARAMETER ID: 'MAT' FIELD IT_DN-MATNR.
CASE r_ucomm.
WHEN '&IC1'.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDIF.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT.
loop at i_fieldcat into l_fieldcat.
if sy-langu = 'E'.
case l_fieldcat-fieldname.
when 'VBELN'.
l_fieldcat-hotspot = 'X'.
when 'DNMON'.
l_fieldcat-seltext_s = 'Month'.
l_fieldcat-seltext_m = 'DN Month'.
l_fieldcat-seltext_l = 'DN Month'.
when 'VFLAG'.
l_fieldcat-seltext_s = '+/-'.
when 'VFACT'.
l_fieldcat-seltext_s = 'Conversion'.
l_fieldcat-seltext_m = 'Conversion'.
l_fieldcat-seltext_l = 'Conversion Factor'.
when 'NTPRI'.
l_fieldcat-seltext_s = 'Price'.
l_fieldcat-seltext_m = 'Sales Price'.
l_fieldcat-seltext_l = 'Sales Price'.
when 'INMON'.
l_fieldcat-seltext_s = 'Month'.
l_fieldcat-seltext_m = 'Bill.Month'.
l_fieldcat-seltext_l = 'Billing Month'.
when 'NTGEW'.
l_fieldcat-seltext_s = 'Net(KG)'.
l_fieldcat-seltext_m = 'Net weight(KG)'.
l_fieldcat-seltext_l = 'Net weight(KG)'.
when 'BRGEW'.
l_fieldcat-seltext_s = 'Gross(KG)'.
l_fieldcat-seltext_m = 'Gross weight(KG)'.
l_fieldcat-seltext_l = 'Gross weight(KG)'.
when 'NTPR2'.
l_fieldcat-seltext_s = 'Price(USD)'.
l_fieldcat-seltext_m = 'Sales Price(USD)'.
l_fieldcat-seltext_l = 'Sales Price(USD)'.
when 'NTAM2'.
l_fieldcat-seltext_s = 'Amount(USD)'.
l_fieldcat-seltext_m = 'Sales Amount(USD)'.
l_fieldcat-seltext_l = 'Sales Amount(USD)'.
when 'NTAM3'.
l_fieldcat-seltext_s = 'Amount(USD)'.
l_fieldcat-seltext_m = 'Shipped Amount(USD)'.
l_fieldcat-seltext_l = 'Shipped Amount(USD)'.
endcase.
else.
case l_fieldcat-fieldname.
when 'DNMON'.
l_fieldcat-seltext_s = '月'.
l_fieldcat-seltext_m = '交货月'.
l_fieldcat-seltext_l = '交货月'.
when 'VFLAG'.
l_fieldcat-seltext_s = '+/-'.
when 'VFACT'.
l_fieldcat-seltext_s = '比率'.
l_fieldcat-seltext_m = '比率'.
l_fieldcat-seltext_l = '比率'.
when 'NTPRI'.
l_fieldcat-seltext_s = '价格'.
l_fieldcat-seltext_m = '销售价格'.
l_fieldcat-seltext_l = '销售价格'.
when 'INMON'.
l_fieldcat-seltext_s = '月'.
l_fieldcat-seltext_m = '发票月'.
l_fieldcat-seltext_l = '发票月'.
when 'NTGEW'.
l_fieldcat-seltext_s = '净重(KG)'.
l_fieldcat-seltext_m = '净重(KG)'.
l_fieldcat-seltext_l = '净重(KG)'.
when 'BRGEW'.
l_fieldcat-seltext_s = '毛重(KG)'.
l_fieldcat-seltext_m = '毛重(KG)'.
l_fieldcat-seltext_l = '毛重(KG)'.
when 'NTPR2'.
l_fieldcat-seltext_s = '价格(USD)'.
l_fieldcat-seltext_m = '销售价格(USD)'.
l_fieldcat-seltext_l = '销售价格(USD)'.
when 'NTAM2'.
l_fieldcat-seltext_s = '总价值(USD)'.
l_fieldcat-seltext_m = '总价值(USD)'.
l_fieldcat-seltext_l = '总价值(USD)'.
when 'NTAM3'.
l_fieldcat-seltext_s = '走货价值(USD)'.
l_fieldcat-seltext_m = '走货价值(USD)'.
l_fieldcat-seltext_l = '走货价值(USD)'.
endcase.
endif.
modify i_fieldcat from l_fieldcat.
endloop.
ENDFORM. "BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form top-of-head
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form top-of-head.
data: t_header type slis_t_listheader,
wa_header type slis_listheader.
data v_value1(18) type c.
data v_value2(18) type c.
data v_info(60) type c.
if wbs is not initial.
v_value1 = wbs-low.
v_value2 = wbs-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = 'WBS 项目 '.
else.
wa_header-key = 'WBS Element '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if dnno is not initial.
v_value1 = dnno-low.
v_value2 = dnno-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '交货单号 '.
else.
wa_header-key = 'DN Number '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if pdate is not initial.
v_value1 = pdate-low.
v_value2 = pdate-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '实际发货日期 '.
else.
wa_header-key = 'Posting Date '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if matno is not initial.
v_value1 = matno-low.
v_value2 = matno-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '物料编号 '.
else.
wa_header-key = 'Material '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if plant is not initial.
v_value1 = plant-low.
v_value2 = plant-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '工厂 ' .
else.
wa_header-key = 'Plant '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if locat is not initial.
v_value1 = locat-low.
v_value2 = locat-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '仓位 '.
else.
wa_header-key = 'Location '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if custo is not initial.
v_value1 = custo-low.
v_value2 = custo-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '送达方 '.
else.
wa_header-key = 'Ship-to Party '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if salto is not initial.
v_value1 = salto-low.
v_value2 = salto-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '售达方 '.
else.
wa_header-key = 'Sold-to Party '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if sotyp is not initial.
v_value1 = sotyp-low.
v_value2 = sotyp-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '订单类型 '.
else.
wa_header-key = 'SO Type '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if sono is not initial.
v_value1 = sono-low.
v_value2 = sono-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '销售订单 '.
else.
wa_header-key = 'SO. Number '.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if gstat is not initial.
v_value1 = gstat-low.
v_value2 = gstat-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '发货状态 '.
else.
wa_header-key = 'GoodsIss Status'.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
if bstat is not initial.
v_value1 = bstat-low.
v_value2 = bstat-high.
concatenate v_value1 ' To ' v_value2 into v_info separated by space.
clear wa_header.
wa_header-typ = 'S'.
if sy-langu = '1'.
wa_header-key = '开票凭证状态 '.
else.
wa_header-key = 'Bill Doc.Status'.
endif.
wa_header-info = v_info.
append wa_header to t_header.
endif.
*-----------------------------------------------------------
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
endform. "top-of-head
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_DATA.
DATA WA_LIKP LIKE LIKP OCCURS 10 WITH HEADER LINE.
DATA WA_LIPS LIKE LIPS OCCURS 10 WITH HEADER LINE.
DATA WA_VBAP TYPE VBAP.
DATA WA_VBRK TYPE VBRK.
DATA WA_VBRP TYPE VBRP.
DATA WA_VBKD TYPE VBKD.
DATA WA_VBAK TYPE VBAK.
DATA VA_KONV TYPE KONV.
DATA V_FLAG(2) TYPE C.
DATA V_NTPR TYPE P DECIMALS 4.
DATA V_NTPR2 TYPE P DECIMALS 4.
DATA V_NTAM2 TYPE VBAP-NETWR.
DATA V_NTAM3 TYPE VBAP-NETWR.
DATA V_PRSDT TYPE VBKD-PRSDT.
DATA: BEGIN OF WA_VBUK OCCURS 10,
WBSTK TYPE VBUK-WBSTK,
FKSTK TYPE VBUK-FKSTK,
FKIVK TYPE VBUK-FKIVK,
END OF WA_VBUK.
DATA V_POSDAT TYPE LIKP-WADAT.
DATA V_INVQTY TYPE LIPS-LFIMG.
DATA V_NETWGT TYPE LIPS-NTGEW.
DATA V_GROWGT TYPE LIPS-BRGEW.
DATA V_AUART TYPE VBAK-AUART.
DATA V_FACTOR TYPE P DECIMALS 2.
DATA DN_MONTH(6) TYPE C.
DATA IN_MONTH(6) TYPE C.
DATA V_FKDAT TYPE VBRK-FKDAT.
DATA V_MAKTX TYPE MAKT-MAKTX.
DATA V_NUMBER TYPE KONV-KNUMV.
DATA WA_KONV TYPE KONV.
DATA V_NUMBER1 TYPE KONV-KNUMV.
DATA V_NETWR1 TYPE VBRP-NETWR.
CLEAR IT_DN.
REFRESH IT_DN.
*-----------------------------------------------------------------------
CLEAR WA_LIKP.
REFRESH WA_LIKP.
SELECT VBELN KUNNR WADAT WADAT_IST BOLNR KUNAG
INTO CORRESPONDING FIELDS OF TABLE WA_LIKP
FROM LIKP
WHERE VBELN IN DNNO AND KUNNR IN CUSTO
AND KUNAG IN SALTO
AND ( WADAT_IST IN PDATE OR
( WADAT_IST EQ SPACE AND WADAT IN PDATE ) ) AND
VBELN IN ( SELECT VBELN FROM VBUK WHERE WBSTK IN GSTAT AND
FKSTK IN BSTAT ) AND
VBELN IN ( SELECT VBELN FROM LIPS WHERE MATNR IN MATNO AND
WERKS IN PLANT AND LGORT IN LOCAT AND
PS_PSP_PNR IN WBS AND
VGBEL IN SONO AND
VGBEL IN ( SELECT VBELN FROM VBAK WHERE
AUART IN SOTYP ) )
ORDER BY VBELN.
LOOP AT WA_LIKP.
* Get the Posting Date
CLEAR V_POSDAT.
IF WA_LIKP-WADAT_IST EQ SPACE OR WA_LIKP-WADAT_IST EQ '00000000'.
V_POSDAT = WA_LIKP-WADAT.
ELSE.
V_POSDAT = WA_LIKP-WADAT_IST.
ENDIF.
CLEAR DN_MONTH.
DN_MONTH = V_POSDAT+0(6).
* GET DN Overall Status
CLEAR WA_VBUK.
SELECT WBSTK FKSTK FKIVK
FROM VBUK
INTO WA_VBUK
WHERE VBELN = WA_LIKP-VBELN.
APPEND WA_VBUK.
ENDSELECT.
CLEAR WA_LIPS.
REFRESH WA_LIPS.
IF BATCH EQ SPACE.
SELECT WERKS LGORT&nb
0 件のコメント:
コメントを投稿