朋友公司裁员了。直接干掉了35%的业务和50%的SAP ABAP。
感觉有点突然。虽然项目还有1个月才结束,不过感觉更新了简历后,没啥电话了。
管他大爷的。BAPI_PRODORDCONF_CREATE_TT一般是属于PP模块的生产订单完工确认,对应的前台事务代码是CO11和CO11N.
今天,我们温习一下他的使用。人生短短几个秋,我又算个球。。
导入参数:
参数名称 | 关联类型 | 可选的 | 缺省值 | 说明 |
POST_WRONG_ENTRIES | BAPI_CORU_PARAM-INS_ERR | 可选 | ‘0’ | 插入确认有错误 |
TESTRUN | BAPI_CORU_PARAM-TESTRUN | 可选 | 切换到编写 BAPI 的模拟会话,值为 X,则为试运行 不提交至系统 |
表参数:
参数名称 | 关联类型 | 可选的 | 说明 |
TIMETICKETS | BAPI_PP_TIMETICKET | 必选 | PP 确认计工单 |
GOODSMOVEMENTS | BAPI2017_GM_ITEM_CREATE | 可选 | 创建物料凭证的行项目 |
LINK_CONF_GOODSMOV | BAPI_LINK_CONF_GOODSMOV | 可选 | 确认货物移动 |
DETAIL_RETURN | BAPI_CORU_RETURN | 可选 | 返回信息 |
TIMETICKETS常用输入参数字段
组件 | 类型 | 简短描述 |
ORDERID | AUFNR | 订单号 |
SEQUENCE | PLNFOLGE | 序列 |
OPERATION | VORNR | 操作/活动编号 |
YIELD | RU_LMNGA | 待确认的产量 |
GOODSMOVEMENTS常用输入参数字段:
组件 | 类型 | 简短描述 |
ORDERID | AUFNR | 订单号 |
ORDER_ITNO | CO_POSNR | 订单项目号 |
如下是demo代码,作为HOT583.com的码农,多年前也是SAP ABAP beginners ,最开始学习会有些难度,
到处去找Tutorial for Constant。如下是详细代码:
* 定义数据内表
DATA: gt_afko TYPE STANDARD TABLE OF afko.
* Work Area 定义
DATA: gw_afko TYPE afko,
gw_afpo TYPE afpo,
gw_afvc TYPE afvc,
gw_afvv TYPE afvv.
DATA: gv_index TYPE sy-tabix,
gv_result TYPE c.
DATA:
*BAPI相关定义
propose LIKE bapi_pp_conf_prop,
timetickets LIKE bapi_pp_timeticket OCCURS 0 WITH HEADER LINE,
goodsmovements LIKE bapi2017_gm_item_create OCCURS 0 WITH HEADER LINE,
link_conf_goodsmov LIKE bapi_link_conf_goodsmov OCCURS 0 WITH HEADER LINE,
return_detail LIKE bapi_coru_return OCCURS 0 WITH HEADER LINE,
return LIKE bapiret1 OCCURS 0 WITH HEADER LINE.
CONSTANTS:cn_flagx TYPE c VALUE ‘X’.
* Get Data…
* Header
CLEAR gt_afko[].
SELECT aufnr rsnum aufpl
INTO CORRESPONDING FIELDS OF TABLE gt_afko
FROM afko
WHERE aufnr IN so_aufnr . “生产工单号
* Data Proccess…
CLEAR gw_afko.
LOOP AT gt_afko INTO gw_afko.
IF sy-subrc = 0.
CLEAR gw_afvc.
SELECT SINGLE
aufpl “订单工序的工艺路线号
aplzl “订单的通用计数器
vornr “工序
plnfl “顺序
arbid
aplfl “序列(新) 有值
INTO CORRESPONDING FIELDS OF gw_afvc
FROM afvc
WHERE aufpl = gw_afko-aufpl.
IF sy-subrc = 0.
* 1.需要更新的数据设置
CLEAR propose.
propose-quantity = cn_flagx. “更新数量
propose-date_and_time = cn_flagx. “更新作业时间
propose-goodsmovement = cn_flagx. “更新货物移动
* 2.作业时间
CLEAR: timetickets,timetickets[].
timetickets-orderid = gw_print-aufnr. “工单号
timetickets-operation = gw_afvc-vornr. “工序号
timetickets-yield = gw_print-lmnga. “工单生产数量
timetickets-sequence = gw_afvc-aplfl. “
APPEND timetickets.
CLEAR timetickets.
* 3.货物移动属性
* 第一次赋值,用于获取相关默认属性值
CLEAR: goodsmovements,goodsmovements[].
goodsmovements-orderid = gw_print-aufnr. “生产订单号
goodsmovements-order_itno = gw_afvc-vornr. “工序号
APPEND goodsmovements.
CLEAR goodsmovements.
* 4.调用BAPI,获取默认属性值
CALL FUNCTION ‘BAPI_PRODORDCONF_GET_TT_PROP’
EXPORTING
propose = propose
IMPORTING
return = return
TABLES
timetickets = timetickets
goodsmovements = goodsmovements
link_conf_goodsmov = link_conf_goodsmov
detail_return = return_detail.
* 5.输出异常信息
IF return-type = ‘E’ OR return-type = ‘A’.
CONCATENATE ‘错误:’ return-message INTO return-message.
gv_result = cn_flagx.
ENDIF.
LOOP AT return_detail WHERE type IS NOT INITIAL.
IF return_detail-type = ‘E’ OR return_detail-type = ‘A’.
CONCATENATE ‘错误:’ return_detail-message INTO return-message.
gv_result = cn_flagx.
ENDIF.
ENDLOOP.
* 6. 如若需要更新相关信息,可在此修改
* — 这里修改作业时间 —
IF gv_result NE cn_flagx.
CLEAR gv_index.
LOOP AT timetickets.
gv_index = sy-tabix. “索引
CLEAR gw_afvv.
SELECT SINGLE * FROM afvv
INTO CORRESPONDING FIELDS OF gw_afvv
WHERE aufpl = gw_afvc-aufpl
AND aplzl = gw_afvc-aplzl.
IF sy-subrc = 0.
IF NOT gw_afvv-bmsch = 0.
IF timetickets-conf_acti_unit1 NE ‘S’.
timetickets-conf_activity1 = timetickets-yield * gw_afvv-vgw01 / gw_afvv-bmsch.
ELSE.
timetickets-conf_activity1 = timetickets-yield * gw_afvv-vgw01 DIV gw_afvv-bmsch.
ENDIF.
IF timetickets-conf_acti_unit2 NE ‘S’.
timetickets-conf_activity2 = timetickets-yield * gw_afvv-vgw02 / gw_afvv-bmsch.
ELSE.
timetickets-conf_activity2 = timetickets-yield * gw_afvv-vgw02 DIV gw_afvv-bmsch.
ENDIF.
IF timetickets-conf_acti_unit3 NE ‘S’.
timetickets-conf_activity3 = timetickets-yield * gw_afvv-vgw03 / gw_afvv-bmsch.
ELSE.
timetickets-conf_activity3 = timetickets-yield * gw_afvv-vgw03 DIV gw_afvv-bmsch.
ENDIF.
IF timetickets-conf_acti_unit4 NE ‘S’.
timetickets-conf_activity4 = timetickets-yield * gw_afvv-vgw04 / gw_afvv-bmsch.
ELSE.
timetickets-conf_activity4 = timetickets-yield * gw_afvv-vgw04 DIV gw_afvv-bmsch.
ENDIF.
IF timetickets-conf_acti_unit5 NE ‘S’.
timetickets-conf_activity5 = timetickets-yield * gw_afvv-vgw05 / gw_afvv-bmsch.
ELSE.
timetickets-conf_activity5 = timetickets-yield * gw_afvv-vgw05 DIV gw_afvv-bmsch.
ENDIF.
IF timetickets-conf_acti_unit6 NE ‘S’.
timetickets-conf_activity6 = timetickets-yield * gw_afvv-vgw06 / gw_afvv-bmsch.
ELSE.
timetickets-conf_activity6 = timetickets-yield * gw_afvv-vgw06 DIV gw_afvv-bmsch.
ENDIF.
ENDIF.
ENDIF.
timetickets-yield = 200. “待确认的产量(用户输入确认值)
IF gw_afvv IS NOT INITIAL.
MODIFY timetickets INDEX gv_index TRANSPORTING yield
conf_activity1 conf_acti_unit1 conf_activity2 conf_acti_unit2
conf_activity3 conf_acti_unit3 conf_activity4 conf_acti_unit4
conf_activity5 conf_acti_unit5 conf_activity6 conf_acti_unit6.
ELSE.
MODIFY timetickets INDEX gv_index TRANSPORTING yield.
ENDIF.
CLEAR timetickets.
ENDLOOP.
CLEAR gw_afvv.
ENDIF.
* 7. 调用BAPI,报工确认
CLEAR: return, return[].
CLEAR: return_detail, return_detail[].
CALL FUNCTION ‘BAPI_PRODORDCONF_CREATE_TT’
EXPORTING
post_wrong_entries = ‘1’
testrun = ” “标识为 X,则为试运行 不提交至系统
IMPORTING
return = return
TABLES
timetickets = timetickets
goodsmovements = goodsmovements
link_conf_goodsmov = link_conf_goodsmov
detail_return = return_detail.
CLEAR gv_result.
READ TABLE return WITH KEY type = ‘E’.
IF sy-subrc = 0.
CONCATENATE ‘错误:’ return-message INTO return-message.
gv_result = cn_flagx.
ENDIF.
LOOP AT return_detail WHERE type IS NOT INITIAL.
IF return_detail-type = ‘E’ OR return_detail-type = ‘A’.
CONCATENATE ‘错误:’ return_detail-message INTO return-message.
gv_result = cn_flagx.
ENDIF.
ENDLOOP.
IF gv_result NE cn_flagx.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = cn_flagx.
ENDIF.
ENDIF.
ENDIF.
CLEAR gw_afko.
ENDLOOP.
注意事项
在报工时,当涉及到 倒冲料扣料 的操作时,则需要 Call 两个BAPI来操作:
BAPI_PRODORDCONF_GET_TT_PROP 获取生产订单相关属性
BAPI_PRODORDCONF_CREATE_TT 报工确认
您学废了吗?
本文链接 :http://www.hot583.com/2022/05/20/mb_cancel_goods_movement/
本文为作者原创,如果这篇文章对您有用,欢迎转载,
转载请务必注明来源《今日热点在看》http://www.hot583.com/
我的微信公众号【 hot583 】 或者在这个链接联系我
微信原文《全文完》