*----------------------------------------------------------------------*
* Program Name : 采购订单付款清单 *
* Purpose : *
* Project Name : *
* Created by : *
* Create on : 2010-09-16 *
* Functional Consultant :
* Description :
*
*
*----------------------------------------------------------------------*
* Modification Log *
*Date Programmer Corr. # Description *
*2010/MM/DD xxxxxxxxxx xxxxxxxxxx Initial pgm dev *
*----------------------------------------------------------------------*
REPORT ZMM018.
********************************
*TABLE DECLARE
********************************
TABLES:EKKO, "采购订单抬头
EKPO, "采购订单行项目
BSIK, "对供应商付款
BSAK. "对供应商付款(清账)
*********************************
*GLOBAL DEFINITIONS
*********************************
TYPE-POOLS: SLIS.
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
WA_FIELDCAT TYPE LVC_S_FCAT,
GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,
GD_LAYOUT TYPE LVC_S_LAYO,
GD_REPID LIKE SY-REPID.
DATA:WA_SORT TYPE LVC_S_SORT, "用于排序后汇总
IT_SORT TYPE LVC_T_SORT.
DATA:WA_EXCLUDING TYPE SLIS_EXTAB, "隐藏标准工具栏按钮
IT_EXCLUDING TYPE SLIS_T_EXTAB.
**********************************
*DATA DEFINITIONS
**********************************
TYPES:BEGIN OF TY_OUT,
LIFNR LIKE EKKO-LIFNR, "供应商
LLIEF LIKE EKKO-LLIEF, "产品供应商
EBELN LIKE EKKO-EBELN, "采购订单号
WAERS LIKE EKKO-WAERS, "货币单位
EINDT LIKE EKET-EINDT, "请求交货日期
ELIKZ LIKE EKPO-ELIKZ, "交货已完成
BRTWR LIKE EKPO-BRTWR, "采购订单金额
MWSKZ LIKE EKPO-MWSKZ, "税码
NAME1 LIKE LFA1-NAME1, "供应商名称
NAME2 LIKE LFA1-NAME2, "产品供应商名称
EBELP LIKE EKPO-EBELP, "采购订单行项目
WRBTR LIKE EKBE-WRBTR, "收货金额
BUDAT LIKE EKBE-BUDAT, "最后收货日期
XREF2 LIKE BSIK-XREF2, "合同号
NETWR LIKE BSIK-WRBTR, "付款金额
BSDAT LIKE BSIK-BUDAT, "付款日期
BELNR LIKE BSIK-BELNR, "付款凭证号
SGTXT LIKE BSIK-SGTXT, "文本
NETPR LIKE BSIK-WRBTR, "未付款金额
END OF TY_OUT.
DATA:IT_EKKO TYPE TY_OUT OCCURS 0 WITH HEADER LINE.
DATA:IT_TEMP TYPE TY_OUT OCCURS 0 WITH HEADER LINE.
DATA:IT_OUT TYPE TY_OUT OCCURS 0 WITH HEADER LINE.
DATA:IT_OUTX TYPE TY_OUT OCCURS 0 WITH HEADER LINE.
TYPES:BEGIN OF TY_EKET,
EBELN LIKE EKET-EBELN, "采购订单号
EINDT LIKE EKET-EINDT, "请求交货日期
END OF TY_EKET.
DATA:IT_EKET TYPE TY_EKET OCCURS 0 WITH HEADER LINE .
TYPES:BEGIN OF TY_LFA1,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF TY_LFA1.
DATA:IT_LFA1 TYPE TY_LFA1 OCCURS 0 WITH HEADER LINE .
TYPES:BEGIN OF TY_EKBE,
EBELN LIKE EKBE-EBELN, "采购订单号
MWSKZ LIKE EKPO-MWSKZ, "税码
BWART LIKE EKBE-BWART, "移动类型
BELNR LIKE EKBE-BELNR, "商品凭证号(用于防止for all entires of 删除相同项)
BUZEI LIKE EKBE-BUZEI, "商品凭证项目
WRBTR LIKE EKBE-WRBTR, "收货金额
END OF TY_EKBE.
DATA:IT_EKBE1 TYPE TY_EKBE OCCURS 0 WITH HEADER LINE.
DATA:IT_EKBE TYPE TY_EKBE OCCURS 0 WITH HEADER LINE.
TYPES:BEGIN OF TY_BUDAT,
EBELN LIKE EKBE-EBELN,
BUDAT LIKE EKBE-BUDAT,
END OF TY_BUDAT.
DATA:IT_BUDAT TYPE TY_BUDAT OCCURS 0 WITH HEADER LINE .
TYPES:BEGIN OF TY_BSIK,
XREF1 LIKE BSIK-XREF1, "采购订单号
BELNR LIKE BSIK-BELNR, "付款凭证号
BUDAT LIKE BSIK-BUDAT, "付款日期
XREF2 LIKE BSIK-XREF2, "合同号
SHKZG LIKE BSIK-SHKZG, "借贷标记
WRBTR LIKE BSIK-WRBTR, "付款金额
SGTXT LIKE BSIK-SGTXT, "文本
END OF TY_BSIK.
DATA:IT_BSIK TYPE TY_BSIK OCCURS 0 WITH HEADER LINE .
DATA:IT_BSK TYPE TY_BSIK OCCURS 0 WITH HEADER LINE .
*******************************************
*SELECT CONDITION
*******************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_EBELN FOR EKKO-EBELN, "采购订单号
S_LIFNR FOR EKKO-LIFNR, "供应商代码
S_AEDAT FOR EKKO-AEDAT. "采购订单创建日期
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS:
P_RAD1 RADIOBUTTON GROUP RD DEFAULT 'X', "汇总
P_RAD2 RADIOBUTTON GROUP RD. "明细
SELECTION-SCREEN END OF BLOCK B2.
*&--------------------------------------------*
*& START-OF-SELECTION
*&--------------------------------------------*
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM ASSORT_DATA.
PERFORM SORT_ALV.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_EXCLUDING.
PERFORM DISPLAY_ALV_REPORT.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
*& 取供应商名称和产品供应商名称
SELECT LIFNR NAME1 INTO TABLE IT_LFA1 FROM LFA1 ORDER BY LIFNR.
*&取采购订单(对于已经审批过并收货过的采购订单不允许修改行项目或增加新行项目 如果业务这样操作 我们将得到错误数据)
SELECT EKKO~LIFNR
EKKO~LLIEF
EKKO~EBELN
EKKO~WAERS
EKPO~BRTWR
EKPO~MWSKZ
EKPO~ELIKZ
EKPO~EBELP
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO
FROM EKKO INNER JOIN EKPO ON EKKO~EBELN = EKPO~EBELN
WHERE EKKO~EBELN IN S_EBELN AND EKKO~LIFNR IN S_LIFNR AND EKKO~AEDAT IN S_AEDAT AND EKKO~BSART = 'ZNB' AND EKKO~PROCSTAT = '05' AND EKPO~LOEKZ <> 'L'.
LOOP AT IT_EKKO . "根据税码计算得到含税金额
IF IT_EKKO-MWSKZ = 'J1'.
IT_EKKO-BRTWR = IT_EKKO-BRTWR * '1.17'.
ELSEIF IT_EKKO-MWSKZ = 'J2'.
IT_EKKO-BRTWR = IT_EKKO-BRTWR * '1.13'.
ELSEIF IT_EKKO-MWSKZ = 'J6'.
IT_EKKO-BRTWR = IT_EKKO-BRTWR * '1.03'.
ELSEIF IT_EKKO-MWSKZ = 'J0'.
IT_EKKO-BRTWR = IT_EKKO-BRTWR .
ENDIF.
MODIFY IT_EKKO.
ENDLOOP.
APPEND LINES OF IT_EKKO TO IT_TEMP.
SORT IT_TEMP BY LIFNR LLIEF EBELN WAERS.
LOOP AT IT_TEMP. "处理内表,得到采购订单的有效总金额
IT_OUT-LIFNR = IT_TEMP-LIFNR.
IT_OUT-LLIEF = IT_TEMP-LLIEF.
IT_OUT-EBELN = IT_TEMP-EBELN.
IT_OUT-WAERS = IT_TEMP-WAERS.
AT END OF WAERS.
SUM.
IT_OUT-BRTWR = IT_TEMP-BRTWR.
APPEND IT_OUT.
CLEAR IT_OUT.
ENDAT.
ENDLOOP.
*& 取收货金额
SORT IT_EKKO BY EBELN EBELP.
DELETE ADJACENT DUPLICATES FROM IT_EKKO COMPARING EBELN EBELP.
IF IT_EKKO[] IS NOT INITIAL.
SELECT EKBE~EBELN EKPO~MWSKZ EKBE~BWART EKBE~BELNR EKBE~BUZEI EKBE~WRBTR INTO TABLE IT_EKBE1 "为防止for all entries 删除所有字段值相同项增加关键字
FROM EKBE INNER JOIN EKPO ON EKPO~EBELN = EKBE~EBELN AND EKPO~EBELP = EKBE~EBELP
FOR ALL ENTRIES IN IT_EKKO WHERE EKBE~EBELN = IT_EKKO-EBELN AND EKBE~EBELP = IT_EKKO-EBELP AND EKBE~BWART IN ('101','105','102','106').
ENDIF.
LOOP AT IT_EKBE1.
IF IT_EKBE1-BWART = '102' OR IT_EKBE1-BWART = '106'.
IT_EKBE1-WRBTR = IT_EKBE1-WRBTR * -1.
ENDIF.
IF IT_EKBE1-MWSKZ = 'J1'.
IT_EKBE1-WRBTR = IT_EKBE1-WRBTR * '1.17'.
ELSEIF IT_EKBE1-MWSKZ = 'J2'.
IT_EKBE1-WRBTR = IT_EKBE1-WRBTR * '1.13'.
ELSEIF IT_EKBE1-MWSKZ = 'J6'.
IT_EKBE1-WRBTR = IT_EKBE1-WRBTR * '1.03'.
ELSEIF IT_EKBE1-MWSKZ = 'J0'.
IT_EKBE1-WRBTR = IT_EKBE1-WRBTR .
ENDIF.
MODIFY IT_EKBE1.
ENDLOOP.
SORT IT_EKBE1 BY EBELN.
LOOP AT IT_EKBE1.
IT_EKBE-EBELN = IT_EKBE1-EBELN.
AT END OF EBELN.
SUM.
IT_EKBE-WRBTR = IT_EKBE1-WRBTR.
APPEND IT_EKBE.
CLEAR IT_EKBE.
ENDAT.
ENDLOOP.
SORT IT_EKBE BY EBELN.
*& 取付款情况
SELECT XREF1 BELNR BUDAT XREF2 SHKZG WRBTR SGTXT INTO TABLE IT_BSIK FROM BSIK
WHERE XREF1 IN S_EBELN AND XREF1 <> ''.
SELECT XREF1 BELNR BUDAT XREF2 SHKZG WRBTR SGTXT APPENDING TABLE IT_BSIK FROM BSAK
WHERE XREF1 IN S_EBELN AND XREF1 <> ''.
LOOP AT IT_BSIK WHERE SHKZG = 'H'.
IT_BSIK-WRBTR = IT_BSIK-WRBTR * -1.
MODIFY IT_BSIK.
ENDLOOP.
SORT IT_BSIK BY XREF1.
LOOP AT IT_BSIK.
IT_BSK-XREF1 = IT_BSIK-XREF1.
IT_BSK-XREF2 = IT_BSIK-XREF2.
AT END OF XREF1.
SUM.
IT_BSK-WRBTR = IT_BSIK-WRBTR.
APPEND IT_BSK.
CLEAR IT_BSK.
ENDAT.
ENDLOOP.
SORT IT_BSK BY XREF1.
*& 取最后收货日期
SELECT EBELN MAX( BUDAT ) AS BUDAT INTO TABLE IT_BUDAT FROM EKBE WHERE EBELN IN S_EBELN
AND EKBE~BWART IN ('101','105','102','106') GROUP BY EBELN ORDER BY EBELN.
*& 取采购订单请求交货日期
SELECT EKET~EBELN MAX( EINDT ) AS EINDT INTO TABLE IT_EKET FROM EKET INNER JOIN EKPO ON EKET~EBELN = EKPO~EBELN AND EKET~EBELP = EKPO~EBELP
WHERE EKET~EBELN IN S_EBELN AND EKPO~LOEKZ <> 'L' GROUP BY EKET~EBELN ORDER BY EKET~EBELN.
SORT IT_TEMP BY EBELN ELIKZ.
DELETE ADJACENT DUPLICATES FROM IT_TEMP COMPARING EBELN ELIKZ."根据采购订单号和交货已完成分类删除相同项
SORT IT_TEMP BY EBELN.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCATALOG .
DATA:COL_POS TYPE I.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-SCRTEXT_M = '供应商代码'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 8.
WA_FIELDCAT-EMPHASIZE = 'X'.
WA_FIELDCAT-KEY = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'NAME1'.
WA_FIELDCAT-SCRTEXT_M = '供应商名称'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 20.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'LLIEF'.
WA_FIELDCAT-SCRTEXT_M = '产品供应商'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 8.
WA_FIELDCAT-EMPHASIZE = 'X'.
WA_FIELDCAT-KEY = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'NAME2'.
WA_FIELDCAT-SCRTEXT_M = '产品供应商名称'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 20.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'XREF2'.
WA_FIELDCAT-SCRTEXT_M = '合同号'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SCRTEXT_M = '采购订单号'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 10.
WA_FIELDCAT-EMPHASIZE = 'X'.
WA_FIELDCAT-KEY = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'EINDT'.
WA_FIELDCAT-SCRTEXT_M = '要求收货日期'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'BUDAT'.
WA_FIELDCAT-SCRTEXT_M = '最后收货日期'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'ELIKZ'.
WA_FIELDCAT-SCRTEXT_M = '完结标识'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 5.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'WAERS'.
WA_FIELDCAT-SCRTEXT_M = '货币单位'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 4.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
IF P_RAD1 = 'X'.
WA_FIELDCAT-FIELDNAME = 'BRTWR'.
WA_FIELDCAT-SCRTEXT_M = '订单有效金额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'WRBTR'.
WA_FIELDCAT-SCRTEXT_M = '已收货总额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SCRTEXT_M = '付款总额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SCRTEXT_M = '未付款总额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ELSEIF P_RAD2 = 'X'.
WA_FIELDCAT-FIELDNAME = 'BRTWR'.
WA_FIELDCAT-SCRTEXT_M = '订单有效金额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'WRBTR'.
WA_FIELDCAT-SCRTEXT_M = '已收货总额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'BELNR'.
WA_FIELDCAT-SCRTEXT_M = '付款凭证号'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'BSDAT'.
WA_FIELDCAT-SCRTEXT_M = '付款日期'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 10.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'NETWR'.
WA_FIELDCAT-SCRTEXT_M = '付款金额'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 15.
WA_FIELDCAT-DO_SUM = 'X'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'SGTXT'.
WA_FIELDCAT-SCRTEXT_M = '文本'.
COL_POS = COL_POS + 1 .
WA_FIELDCAT-COL_POS = COL_POS.
WA_FIELDCAT-OUTPUTLEN = 30.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDIF.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_LAYOUT .
* Set layout field for field attributes(i.e. input/output)
GD_LAYOUT-ZEBRA = 'X'.
GD_LAYOUT-NO_TOTLINE = 'X'."用于控制不显示总计项
GD_LAYOUT-CWIDTH_OPT = 'X'."优化列宽
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT .
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
I_CALLBACK_HTML_TOP_OF_PAGE = 'ALV_TOP_OF_PAGE'
IS_LAYOUT_LVC = GD_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
IT_EXCLUDING = IT_EXCLUDING
IT_SORT_LVC = IT_SORT
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_OUT
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_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form SORT_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SORT_ALV .
WA_SORT-SPOS = '01'.
WA_SORT-FIELDNAME = 'WAERS'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
ENDFORM. " SORT_ALV
*&---------------------------------------------------------------------*
*& Form ASSORT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ASSORT_DATA .
IF P_RAD1 = 'X'.
LOOP AT IT_OUT.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_OUT-LIFNR BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-NAME1 = IT_LFA1-NAME1.
ENDIF.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_OUT-LLIEF BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-NAME2 = IT_LFA1-NAME1.
ENDIF.
READ TABLE IT_EKET WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-EINDT = IT_EKET-EINDT.
ENDIF.
READ TABLE IT_EKBE WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-WRBTR = IT_EKBE-WRBTR.
ENDIF.
READ TABLE IT_BUDAT WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-BUDAT = IT_BUDAT-BUDAT.
ENDIF.
READ TABLE IT_BSK WITH KEY XREF1 = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-XREF2 = IT_BSK-XREF2.
IT_OUT-NETWR = IT_BSK-WRBTR.
ENDIF.
READ TABLE IT_TEMP WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-ELIKZ = IT_TEMP-ELIKZ.
ENDIF.
IF IT_OUT-ELIKZ = 'X'.
IT_OUT-ELIKZ = '是'.
IT_OUT-NETPR = IT_OUT-WRBTR - IT_OUT-NETWR.
ELSE.
IT_OUT-ELIKZ = '否'.
IT_OUT-NETPR = IT_OUT-BRTWR - IT_OUT-NETWR.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = IT_OUT-LIFNR
IMPORTING
OUTPUT = IT_OUT-LIFNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = IT_OUT-LLIEF
IMPORTING
OUTPUT = IT_OUT-LLIEF.
MODIFY IT_OUT.
ENDLOOP .
* DELETE IT_OUT WHERE NETWR = 0.
CLEAR:IT_TEMP,IT_TEMP[].
ELSEIF P_RAD2 = 'X'.
LOOP AT IT_OUT.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_OUT-LIFNR BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-NAME1 = IT_LFA1-NAME1.
ENDIF.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_OUT-LLIEF BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-NAME2 = IT_LFA1-NAME1.
ENDIF.
READ TABLE IT_EKET WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-EINDT = IT_EKET-EINDT.
ENDIF.
READ TABLE IT_EKBE WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-WRBTR = IT_EKBE-WRBTR.
ENDIF.
READ TABLE IT_BUDAT WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-BUDAT = IT_BUDAT-BUDAT.
ENDIF.
READ TABLE IT_TEMP WITH KEY EBELN = IT_OUT-EBELN BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUT-ELIKZ = IT_TEMP-ELIKZ.
ENDIF.
IF IT_OUT-ELIKZ = 'X'.
IT_OUT-ELIKZ = '是'.
ELSE.
IT_OUT-ELIKZ = '否'.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = IT_OUT-LIFNR
IMPORTING
OUTPUT = IT_OUT-LIFNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = IT_OUT-LLIEF
IMPORTING
OUTPUT = IT_OUT-LLIEF.
MODIFY IT_OUT.
ENDLOOP .
CLEAR:IT_TEMP,IT_TEMP[].
SORT IT_OUT BY EBELN.
LOOP AT IT_BSIK.
READ TABLE IT_OUT WITH KEY EBELN = IT_BSIK-XREF1 BINARY SEARCH.
IF SY-SUBRC = 0.
IT_OUTX = IT_OUT.
IT_OUTX-XREF2 = IT_BSIK-XREF2.
IT_OUTX-NETWR = IT_BSIK-WRBTR.
IT_OUTX-BSDAT = IT_BSIK-BUDAT.
IT_OUTX-BELNR = IT_BSIK-BELNR.
IT_OUTX-SGTXT = IT_BSIK-SGTXT.
APPEND IT_OUTX.
CLEAR IT_OUTX.
ENDIF.
ENDLOOP.
CLEAR:IT_OUT,IT_OUT[].
DATA:L_EBELN LIKE EKKO-EBELN.
CLEAR L_EBELN.
LOOP AT IT_OUTX.
IF L_EBELN = IT_OUTX-EBELN.
IT_OUTX-BRTWR = 0.
IT_OUTX-WRBTR = 0.
MODIFY IT_OUTX.
ENDIF.
L_EBELN = IT_OUTX-EBELN.
ENDLOOP.
APPEND LINES OF IT_OUTX TO IT_OUT.
ENDIF.
ENDFORM. " ASSORT_DATA
*&---------------------------------------------------------------------*
*& Form alv_top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CL_DD text
*----------------------------------------------------------------------*
FORM ALV_TOP_OF_PAGE USING CL_DD TYPE REF TO CL_DD_DOCUMENT.
DATA: M_P TYPE I.
DATA: M_BUFF TYPE STRING.
M_BUFF = ''.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = M_BUFF
CHANGING
POSITION = M_P.
M_BUFF = '采购订单付款清单
'.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = M_BUFF
CHANGING
POSITION = M_P.
* CALL METHOD CL_DD->ADD_GAP
* EXPORTING
* WIDTH = 210.
*
* CALL METHOD CL_DD->ADD_PICTURE
* EXPORTING
* PICTURE_ID = 'ENJOYSAP_LOGO'.
M_BUFF = ''.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = M_BUFF
CHANGING
POSITION = M_P.
CONCATENATE 'PRINT DATE:' SY-DATUM+0(4)'-'SY-DATUM+4(2)'-'SY-DATUM+6(2) ' USER:' SY-UNAME '
' INTO M_BUFF.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = M_BUFF
CHANGING
POSITION = M_P.
M_BUFF = ''.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = M_BUFF
CHANGING
POSITION = M_P.
M_BUFF = ''.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = M_BUFF
CHANGING
POSITION = M_P.
ENDFORM. "alv_top_of_page
*&---------------------------------------------------------------------*
*& Form BUILD_EXCLUDING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_EXCLUDING .
WA_EXCLUDING-FCODE = '&UMC'. "隐藏合计
APPEND WA_EXCLUDING TO IT_EXCLUDING.
WA_EXCLUDING-FCODE = '&SUM'. "隐藏小计
APPEND WA_EXCLUDING TO IT_EXCLUDING.
ENDFORM. " BUILD_EXCLUDING
阅读(5808) | 评论(0) | 转发(0) |