DATA
: lt_return
TYPE
TABLE
OF bapiret2
WITH
HEADER
LINE
.
" 获取采购订单抬头
CLEAR : gw_ekpo ,gt_ekpo ,gw_ekko ,gt_ekko .
SELECT * FROM ekko
INTO CORRESPONDING FIELDS OF TABLE gt_ekko
WHERE ebeln EQ g_ebeln .
" 获取采购订单行项目
SELECT * FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE gt_ekpo
WHERE ebeln EQ g_ebeln .
IF sy -subrc <> 0 .
CONCATENATE '结算单' g_jsd '没有生成采购订单,无法过账冲销!' INTO str .
MESSAGE str TYPE 'E' .
ENDIF .
"循环冲销
LOOP AT gt_ekpo INTO gw_ekpo .
***过账函数
CLEAR g_lblni .
SELECT SINGLE lblni
INTO g_lblni FROM essr
WHERE ebeln = gw_ekpo -ebeln AND ebelp = gw_ekpo -ebelp AND loekz = '' .
CHECK sy -subrc = 0 .
CALL FUNCTION 'BBP_ENTRYSHEET_CANCEL'
EXPORTING
entrysheet = g_lblni
posting_date_fi = g_posting_dat
TABLES
return = lt_return[] .
READ TABLE lt_return WITH KEY type = 'E' .
IF sy -subrc EQ 0 .
l_err_flag = '' .
CONCATENATE '结算单' g_jsd1 '过账冲销失败!' lt_return - message INTO l_string .
MESSAGE l_string TYPE 'E' .
ELSE .
WAIT UP TO 1 SECONDS . "等待1秒, 在进行下一次过账冲销
ENDIF .
IF l_err_flag NE 'X' .
RETURN .
ENDIF .
DATA: l_err_flag TYPE c VALUE ''. "确认操作符
DATA: g_lblni TYPE lblni. " 服务输入单条目表号
DATA: g_posting_dat TYPE sy-datum. "记账日期
" 获取采购订单抬头
CLEAR : gw_ekpo ,gt_ekpo ,gw_ekko ,gt_ekko .
SELECT * FROM ekko
INTO CORRESPONDING FIELDS OF TABLE gt_ekko
WHERE ebeln EQ g_ebeln .
" 获取采购订单行项目
SELECT * FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE gt_ekpo
WHERE ebeln EQ g_ebeln .
IF sy -subrc <> 0 .
CONCATENATE '结算单' g_jsd '没有生成采购订单,无法过账冲销!' INTO str .
MESSAGE str TYPE 'E' .
ENDIF .
"循环冲销
LOOP AT gt_ekpo INTO gw_ekpo .
***过账函数
CLEAR g_lblni .
SELECT SINGLE lblni
INTO g_lblni FROM essr
WHERE ebeln = gw_ekpo -ebeln AND ebelp = gw_ekpo -ebelp AND loekz = '' .
CHECK sy -subrc = 0 .
CALL FUNCTION 'BBP_ENTRYSHEET_CANCEL'
EXPORTING
entrysheet = g_lblni
posting_date_fi = g_posting_dat
TABLES
return = lt_return[] .
READ TABLE lt_return WITH KEY type = 'E' .
IF sy -subrc EQ 0 .
l_err_flag = '' .
CONCATENATE '结算单' g_jsd1 '过账冲销失败!' lt_return - message INTO l_string .
MESSAGE l_string TYPE 'E' .
ELSE .
WAIT UP TO 1 SECONDS . "等待1秒, 在进行下一次过账冲销
ENDIF .
IF l_err_flag NE 'X' .
RETURN .
ENDIF .
ENDLOOP.
CONCATENATE '结算单' g_jsd1 '过账冲销成功! 条目:' g_lblni INTO l_string.
MESSAGE l_string TYPE 'S'.