sap_zhiwen 发表时间:2008-04-12 22:11:40 |
|
老白我想问一个问题:用BDC修改物料主数据T-CODE:MM02的时候在选择视图那里,我想选择MRP3视图的,而MRP3视图在第5行的话代码如下 PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=ENTR'. PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(05)' 'X'. 我们系统不是所有的物料的MRP3视图都在第五行,有一些在第七行或是第八行,问题就出现了我如何定位正确的进入MRP3视图进行修改。 |
可能是物料的维护视图维护的不一样吧,具体看一看MARA的PSTAT字段,其代表的意义为:
A 工作计划
B 会计
C 分类
D 物料需求计划
E 采购
F 生产资源/工具
G 成本核算
K 基本数据
L 存储
P 预测
Q 质量管理
S 仓库管理
V 销售
X 工厂库存
Z 存储位置库存
如果能根据简单的方法得出你所需要的行在物料维特视图的行就比较容易,如果不能,则要自己写程序来判断所在的行。具体方法可以参考程序SAPLMGMM的0070屏幕的PBO。
得出后把PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(05)' 'X'.
改为动态的数值。
2008年4月15日添加FM:MATERIAL_BTCI_SELECTION_NEW使用的例子:
REPORT z_barry_mm02_bdc NO STANDARD PAGE HEADING .
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: bdcdata2 LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF messtab OCCURS 0.
INCLUDE STRUCTURE bdcmsgcoll.
DATA: END OF messtab.
DATA: BEGIN OF itab_log OCCURS 0,
message(132) TYPE c,
END OF itab_log.
START-OF-SELECTION.
PERFORM bdc.
*---------------------------------------------------------------------*
* FORM bdc *
*---------------------------------------------------------------------*
FORM bdc .
REFRESH bdcdata .
CLEAR bdcdata .
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_OKCODE' '=AUSW'.
PERFORM bdc_field USING 'RMMG1-MATNR' '4445678'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTR'.
CALL FUNCTION 'MATERIAL_BTCI_SELECTION_NEW'
EXPORTING
material = '4445678'
selection = 'D'
tcode = 'MM02'
TABLES
btci_d0070 = bdcdata2.
LOOP AT bdcdata2 WHERE fval = 'X'.
APPEND bdcdata2 TO bdcdata.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0080'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTR'.
PERFORM bdc_field USING 'RMMG1-WERKS' '0001'.
PERFORM bdc_field USING 'RMMG1-LGORT' '0001'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4000'.
PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.
PERFORM bdc_field USING 'MAKT-MAKTX' 'Barry Test For MRP'.
CALL TRANSACTION 'MM02' USING bdcdata MODE 'A' UPDATE 'S'
MESSAGES INTO messtab.
LOOP AT messtab.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = messtab-msgid
msgnr = messtab-msgnr
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
IMPORTING
message_text_output = itab_log-message.
APPEND itab_log.
CLEAR itab_log.
ENDLOOP.
LOOP AT itab_log.
WRITE / itab_log.
ENDLOOP.
ENDFORM. " bdc
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
CONDENSE bdcdata-fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
阅读(9381) | 评论(16) | 转发(0) |