SAP-PP 生产工单更改(CO02)记录详细教程

求:SAP在更改生产工单时并没有提供详细的更改记录,查看SAP的Notes,如果强行开启FLG_DOC(控制往更改记录CDHDR,CDPOS里写数据)标记,在批量处理组件过多的生产工单时会导致程序运行出错,SAP建议不开启。User要求对保护字段进行更改记录,无奈只有使用SAP提供的增强功能,东西经过测试初步完成,发出来共享一下,如果大家有更好的方法,发出来讨论讨论,步骤如下:

1.CMOD新增一项目ZCO02,增加增强PPCO0001。
2.查看、Debug SAP源代码,了解数据流向,主要了解在变更工单组件和表头未保存前这些数据存放在哪里?最后查到这两数据放在调用出口函数参数表:component_table,header_table。
3.设计数据表结构:ZPCO02,记录更改,结构如下:
MANDT MANDT CLNT 3
AUFNR AUFNR CHAR 12
MATNR MATNR CHAR 18
FILED FIELDNAME CHAR 30
AENAM AENAM CHAR 12
LAEDA LAEDA DATS 8
TCODE TCODE CHAR 20
CHNID CDCHNGIND CHAR 1
HOSTIP CHAR20 CHAR 20
HOST MSHOST2 CHAR 32
VALUE_OLD CHAR20 CHAR 20
VALUE_NEW CHAR20 CHAR 20
TIMES CDUZEIT TIMS 6
4.在EXIT_SAPLCOBT_001的ZXCO1U01写入代码,component_table中的数据跟RESB中的相应保护字段值对比,得出组件更改记录,表头更改记录由header_table与视图CAUFV对比而来。对于因工单总数更改导至组件数量更改的记录可以写一程序从ZPCO02里分开,开放给用户使用,其他一些更改情况请自行研究。代码如下:

-----------------------------------------------------------------------------------------------------------------
代码通过了User测试更正已传至生产系统,改善了保存时的速度,不用拿更改后的工单组件与RESB里的一个个对比了。
*&---------------------------------------------------------------------*
*& 包括 ZXCO1U01 *
*&---------------------------------------------------------------------*
TABLES:caufv,resb.
DATA: BEGIN OF old_resb OCCURS 0, "更改后未保存之RESB.
aufnr LIKE resb-aufnr,
posnr LIKE resb-posnr,
matnr LIKE resb-matnr,
rsnum LIKE resb-rsnum,
rspos LIKE resb-rspos,
xloek LIKE resb-xloek,
bdmng LIKE resb-bdmng,
objnr LIKE resb-objnr,
END OF old_resb.

DATA: BEGIN OF new_resb OCCURS 0. "数据库中的RESB.
INCLUDE STRUCTURE old_resb.
DATA: END OF new_resb.
DATA: BEGIN OF obj_resb OCCURS 0. "插入的RESB
INCLUDE STRUCTURE old_resb.
DATA: END OF obj_resb.

DATA: i_zpco02 LIKE zpco02 OCCURS 0 WITH HEADER LINE.
DATA: i_temp LIKE zpco02 OCCURS 0 WITH HEADER LINE.

DATA: iporg LIKE msxxlist-hostadr,
ipdec(16) TYPE c,
host(18) TYPE c.
DATA: char1(20) TYPE c,
char2(20) TYPE c.

DATA: inst_flg TYPE c VALUE 'N',
chan_had TYPE c VALUE 'N'.
* teco_flg TYPE c VALUE 'N',
* read_flg TYPE c .

*BREAK-POINT.

CHECK sy-tcode EQ 'CO02'.
** Get user IP,hostname
CALL FUNCTION 'TH_USER_INFO' " Get user IP,hostname
EXPORTING
client = sy-mandt
user = sy-uname
IMPORTING
hostaddr = iporg
terminal = host
EXCEPTIONS
OTHERS = 1.
**"Conv.IP addr to format 'xxx.xxx.xxx.xxx'
CALL FUNCTION 'GWY_IPADR2STRING' "Conv.IP addr
EXPORTING
ipadr = iporg
IMPORTING
string = ipdec.
***Common var.
MOVE: sy-mandt TO i_temp-mandt,
sy-uname TO i_temp-aenam,
sy-datum TO i_temp-laeda,
sy-uzeit TO i_temp-times,
sy-tcode TO i_temp-tcode,
ipdec TO i_temp-hostip,
host TO i_temp-host,
header_table-aufnr TO i_temp-aufnr.
***Check M/O header
**check if status eq 'TECO'.
*LOOP AT status_table WHERE objnr EQ header_table-objnr
* AND stat EQ 'I0045'.
*
* MOVE: 'Y' TO teco_flg.
*ENDLOOP.

*CHECK teco_flg NE 'Y'.
*CHECK read_flg NE 'Y'.

SELECT SINGLE gamng gltrp INTO (caufv-gamng, caufv-gltrp)
FROM caufv WHERE aufnr EQ header_table-aufnr.
**qty
IF header_table-gamng NE caufv-gamng.
MOVE: caufv-gamng TO char1, header_table-gamng TO char2.
MOVE-CORRESPONDING i_temp TO i_zpco02.
MOVE: '更改工单总数' TO i_zpco02-filed,
'U' TO i_zpco02-chnid,
char1 TO i_zpco02-value_old,
char2 TO i_zpco02-value_new.
APPEND i_zpco02.
inst_flg = 'Y'.
chan_had = 'Y'.
ENDIF.
**date
IF header_table-gltrp NE caufv-gltrp.
MOVE-CORRESPONDING i_temp TO i_zpco02.
MOVE: '更改完成时间' TO i_zpco02-filed,
'U' TO i_zpco02-chnid,
caufv-gltrp TO i_zpco02-value_old,
header_table-gltrp TO i_zpco02-value_new.
APPEND i_zpco02.
inst_flg = 'Y'.
ENDIF.

IF inst_flg = 'Y'.
INSERT zpco02 FROM TABLE i_zpco02 ACCEPTING DUPLICATE KEYS.
inst_flg = 'N'.
ENDIF.
*DELETE component_table WHERE vbkz EQ 'I'.
LOOP AT component_table WHERE vbkz EQ 'U'
OR vbkz EQ 'I'
OR vbkz EQ 'D'.
CASE component_table-vbkz.
WHEN 'I'.
MOVE-CORRESPONDING i_temp TO i_zpco02.
MOVE: '新增组件' TO i_zpco02-filed,
'I' TO i_zpco02-chnid,
'' TO i_zpco02-value_old, "old_resb-matnr
component_table-matnr TO i_zpco02-value_new,
'新增的组件' TO i_zpco02-matnr,
* read_flg TO i_zpco02-readf,
component_table-alpos TO i_zpco02-alpos,
sy-tabix TO i_zpco02-loopid.
APPEND i_zpco02.
inst_flg = 'Y'.

WHEN 'D'.
MOVE-CORRESPONDING i_temp TO i_zpco02.
MOVE: '删除组件' TO i_zpco02-filed,
'D' TO i_zpco02-chnid,
resb-xloek TO i_zpco02-value_old,
component_table-xloek TO i_zpco02-value_new,
component_table-matnr TO i_zpco02-matnr,
* read_flg TO i_zpco02-readf,
component_table-alpos TO i_zpco02-alpos,
sy-tabix TO i_zpco02-loopid.
APPEND i_zpco02.
inst_flg = 'Y'.
WHEN 'U'.
SELECT SINGLE matnr bdmng INTO (resb-matnr, resb-bdmng)
FROM resb WHERE aufnr EQ component_table-aufnr
AND posnr EQ component_table-posnr
AND matnr EQ component_table-matnr
AND rsnum EQ component_table-rsnum
AND rspos EQ component_table-rspos.
IF component_table-matnr NE resb-matnr.
MOVE-CORRESPONDING i_temp TO i_zpco02.
MOVE: '更改组件' TO i_zpco02-filed,
'U' TO i_zpco02-chnid,
resb-matnr TO i_zpco02-value_old,
component_table-matnr TO i_zpco02-value_new,
'更改的工单组件' TO i_zpco02-matnr,
* read_flg TO i_zpco02-readf,
component_table-alpos TO i_zpco02-alpos,
sy-tabix TO i_zpco02-loopid.
APPEND i_zpco02.
inst_flg = 'Y'.

ELSEIF component_table-bdmng NE resb-bdmng.
CHECK chan_had NE 'Y'.
MOVE: component_table-bdmng TO char1, resb-bdmng TO char2.
MOVE-CORRESPONDING i_temp TO i_zpco02.
MOVE: '需求数量' TO i_zpco02-filed,
'U' TO i_zpco02-chnid,
char2 TO i_zpco02-value_old,
char1 TO i_zpco02-value_new,
component_table-matnr TO i_zpco02-matnr,
* read_flg TO i_zpco02-readf,
component_table-alpos TO i_zpco02-alpos,
sy-tabix TO i_zpco02-loopid.
APPEND i_zpco02.
inst_flg = 'Y'.
ENDIF.

ENDCASE.
ENDLOOP.

IF inst_flg = 'Y'.
INSERT zpco02 FROM TABLE i_zpco02 ACCEPTING DUPLICATE KEYS.
IF sy-subrc EQ 0.
inst_flg = 'N'.
chan_had = 'N'.
* MESSAGE ID 'ZX' TYPE 'W'
* NUMBER '000' WITH 'SAP系统已记录您的更改!'.
ENDIF.
ENDIF.

--------------------------------------------------------------------------------------------------------
5.更改记录:
集团 400
订单 400000063
物料 5017000533A
字段名 删除标记
更改者 SAP003
上一次修改 2005.09.12
事务代码 CO02
修改标识符 D
字符20 (HOSTIP) 192.168.4.95
Host Name SAP-8
字符20 (VALUE OLD)
字符20 (VALUE NEW) X

时间 14:53:27

其他的关于生产订单的增强在IMG->SFC->系统修正那都可以找得到,如PPCO0007 保存生产订单时,PPCO0008 在增加和改变组件时的增强(这里就写数据到ZPCO02一但用户没保存.....所以只有放在PPCO0001里了),大家多研究研究.

SAP Notes 390635

Symptom
You cannot activate the creation of change documents for production orders
and process orders.
Customizing table T399X (parameters dependent on order type) contains field
FLG_DOC but you cannot maintain it using the Customizing transactions for
production or process orders.

Cause and Prerequisites
It is not intended to use the SAP standard tool for the creation of change
documents for production or process orders in the SAP standard system. The
indicator in table T399X is only interpreted by maintenance orders and
networks.
The reason for this is that the tool cannot determine dependencies of
changes and thus would log too many changes that would have a negative
effect on the runtime.

Solution
Use the SAP enhancement PPCO0007 that is processed when you save order
changes. You can find the SAP enhancement in Customizing under the menu
path "Shop Floor Control or Production Planning for Process Industries ->
Process Order -> System Modifications -> Enhancements for Order Maintenance
-> Enhancement when Saving an Order (Header Fields)".
Here you can define additional logic to decide whether or not the system
creates change documents.
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雁初飞~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值