*&---------------------------------------------------------------------*
*& Report ZCHEN_TEST9001
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZCHEN_TEST9001.
PARAMETERS: P_AUFNR TYPE AFPO-AUFNR OBLIGATORY.
START-OF-SELECTION.
DATA: WA_COBRB_UPDATE TYPE COBRB,
IT_COBRB_UPDATE LIKE STANDARD TABLE OF WA_COBRB_UPDATE.
SELECT *
FROM COBRB AS A
INTO CORRESPONDING FIELDS OF TABLE IT_COBRB_UPDATE
WHERE A~AUFNR EQ P_AUFNR.
IF SY-SUBRC = 0.
SELECT A~AUFNR,
A~POSNR,
A~WEMNG
FROM AFPO AS A
INTO TABLE @DATA(IT_AFPO)
WHERE A~AUFNR EQ @P_AUFNR.
LOOP AT IT_COBRB_UPDATE ASSIGNING FIELD-SYMBOL(<FS_COBRB>).
READ TABLE IT_AFPO WITH KEY AUFNR = <FS_COBRB>-AUFNR
POSNR = <FS_COBRB>-POSNR
INTO DATA(WA_AFPO).
IF SY-SUBRC = 0.
<FS_COBRB>-AQZIF = WA_AFPO-WEMNG.
ENDIF.
ENDLOOP.
CALL FUNCTION 'K_SRULE_SAVE_UTASK'
TABLES
* T_COBRA_INSERT =
* T_COBRA_UPDATE =
* T_COBRA_DELETE =
* T_COBRB_INSERT =
T_COBRB_UPDATE = IT_COBRB_UPDATE
* T_COBRB_DELETE =
EXCEPTIONS
SRULE_UTASK_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ROLLBACK WORK.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
COMMIT WORK AND WAIT.
MESSAGE S001(00) WITH '结算规则更新完成'.
ENDIF.
ENDIF.
根据生产订单联产品的入库数量更新结算规则中的分摊权数 - K_SRULE_SAVE_UTASK
于 2023-06-28 09:31:51 首次发布
该程序主要执行名为ZCHEN_TEST9001的报告,从COBRB表中选择数据,并基于参数P_AUFNRTYPE和AFPO表进行过滤和更新。它循环遍历结果集,读取AFPO表中的相应条目以更新COBRB表中的字段。之后,调用函数K_SRULE_SAVE_UTASK来保存更新的任务。如果出现错误,程序将回滚工作并显示错误消息;否则,提交更改并显示成功消息。
摘要由CSDN通过智能技术生成