写入表更改记录下篇
发布日期:2024/07/11
继上一篇的内容,用户测试的过程中发现,还是查不到写入记录。最后发现,我使用的系统环境,更改表equp时,对象类是QUOTEN2。基于此,当一个通过表TCDOB能查出多个对象类时,我们最好通过标准功能更改任意一条目标表的数据。再去查表CDHDR确定对象类和对象ID的格式。
下图中,我通过事务码MEQ3修改了一条配额,可以确定对象类(QUOTEN2)和对象ID(物料+工厂)。
因此我调整了代码:
*&---------------------------------------------------------------------*
*& Report ZMM_RPT_538_WU
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmm_rpt_538_wu.
DATA: lv_objectid TYPE cdobjectv,
lt_xequk TYPE STANDARD TABLE OF equku,
lt_xequp TYPE STANDARD TABLE OF uequp,
lt_yequk TYPE STANDARD TABLE OF equku,
lt_yequp TYPE STANDARD TABLE OF uequp.
DATA :lv_matnr TYPE char40 VALUE '000000000001000473',
lv_werks TYPE char4 VALUE '3121'.
*物料去掉前导0,与工厂拼接时保留了空格占位
lv_matnr = |{ lv_matnr ALPHA = OUT }|.
CONCATENATE lv_matnr lv_werks INTO lv_objectid RESPECTING BLANKS.
SELECT * FROM equp AS a
WHERE a~qunum = '0000001381'
AND a~qupos ='002'
INTO TABLE @DATA(lt_del).
MOVE-CORRESPONDING lt_del TO lt_yequp.
CALL FUNCTION 'ME_UPDATE_QUOTA'
TABLES
xequk = lt_xequk
xequp = lt_xequp "new
yequk = lt_yequk
yequp = lt_yequp. "old
CALL FUNCTION 'QUOTEN2_WRITE_DOCUMENT'
EXPORTING
objectid = lv_objectid
tcode = sy-tcode
utime = sy-uzeit
udate = sy-datum
username = sy-uname
* PLANNED_CHANGE_NUMBER = ' '
object_change_indicator = 'D'
* PLANNED_OR_REAL_CHANGES = ' '
* NO_CHANGE_POINTERS = ' '
* UPD_EQUKC = ' '
upd_equp = 'D'
TABLES
* XEQUKC =
* YEQUKC =
xequp = lt_xequp
yequp = lt_yequp.
1.删除前的配额记录
2.配额项目删除后,确认删除记录。记录成功啦!