1, MM03查看物料
物料的净重可以通过Tcode MM03查看,如下图:
2, 代码
物料的相关数据通过bapi BAPI_MATERIAL_SAVEDATA来修改,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
REPORT Z_CHANGE_NETWEIGHT.
TABLES:MARA.
* 数据声明
DATA: CLIDAINP LIKE BAPI_MARA_GA, "客户端层次物料数据
CLIDAOUT LIKE BAPI_MARA, "客户端层次物料数据
CLIDAOUTX LIKE BAPI_MARAX, "BAPI_MARA 的复选框结构
HEADDATA LIKE BAPIMATHEAD, "带有控制信息的表头段
RETURN LIKE BAPIRET2, "返回参数
RETURNMES LIKE BAPI_MATRETURN2 OCCURS 0 WITH HEADER LINE.
* 取出要处理的物料编号
PARAMETERS: MATERIAL LIKE BAPI_MARA_GA-MATERIAL,
S_NTGEW LIKE MARA-NTGEW, "净重
S_GEWEI LIKE MARA-GEWEI. "单位
* 读取物料数据
CALL FUNCTION ‘BAPI_MATERIAL_GET_ALL‘
EXPORTING
MATERIAL = MATERIAL
IMPORTING
CLIENTDATA = CLIDAINP
TABLES
RETURN = RETURNMES.
* 抬头数据 ,物料和视图维护
HEADDATA-MATERIAL = MATERIAL.
HEADDATA-BASIC_VIEW = ‘X‘.
CLIDAOUT-NET_WEIGHT = S_NTGEW. "净重
CLIDAOUT-UNIT_OF_WT = S_GEWEI. "单位
* Detail Data: Field Value, and ‘X‘-Structure to mark the field for maintenance
CLIDAOUTX-NET_WEIGHT = ‘X‘.
CLIDAOUT-UNIT_OF_WT = ‘X‘.
* CallBAPI
CALL FUNCTION ‘BAPI_MATERIAL_SAVEDATA‘
EXPORTING
HEADDATA = HEADDATA
CLIENTDATA = CLIDAOUT
CLIENTDATAX = CLIDAOUTX
IMPORTING
RETURN = RETURN
TABLES
RETURNMESSAGES = RETURNMES.
* Commit to release the locks
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘.
* RETURN-TYPE is ‘E‘ in case of error, else ‘S‘.
IF RETURN-TYPE = ‘E‘.
LOOP AT RETURNMES.
WRITE: / RETURNMES-MESSAGE.
ENDLOOP.
ELSEIF RETURN-TYPE = ‘S‘..
WRITE: / ‘修改成功 ‘, MATERIAL, ‘OK‘.
ENDIF.
|
3, 测试
选择画面输入物料号和净重还有单位
运行结果:
MM03查看净重,
以上。