SAP创建不同基本单位的信息记录
1、前台维护MM01
2、ME11维护信息记录
3、通过BAPI+BDC实现:ME_INFORECORD_MAINTAIN_MULTI+MEK1录屏
因为单独使用ME_INFORECORD_MAINTAIN_MULTI创建信息记录无法创建双单位,创建第一个单位时可以,第二个就会报错!
因此使用BAPI+BDC录屏实现,在录屏时选择了MEK1 [其实最初本来想用MEK1,直接创建信息记录,更加想偷懒哈哈ME11录屏太复杂,发现MEK1只能更新条件记录在A067表中,无法创建信息记录号ME13无法查看],后面经过多次测试,发现用MEK1创建时候,必须要有信息记录存在(不管先存在哪个单位信息记录都行,反正要有)
因为这个是原来个接口程序,因此为了保证原来逻辑不改动(指的:只有单一单位创建逻辑),因此区分当只有一个单位时候,走BAPI。有多单位并且不存在信息记录也走BAPI,先创建信息记录,下次再进来创建其他单位要创建信息记录走BDC
BDC录屏如下:
ELSE."MEK1新增信息记录BDC
PERFORM bdc_dynpro TABLES bdcdata[] USING 'SAPMV13A' '0100'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_CURSOR'
'RV13A-KSCHL'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field TABLES bdcdata[] USING 'RV13A-KSCHL'
'PB00'.
PERFORM bdc_dynpro TABLES bdcdata[] USING 'SAPLV14A' '0100'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_CURSOR'
'RV130-SELKZ(06)'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_OKCODE'
'=WEIT'.
PERFORM bdc_field TABLES bdcdata[] USING 'RV130-SELKZ(01)'
''.
PERFORM bdc_field TABLES bdcdata[] USING 'RV130-SELKZ(06)'
'X'.
PERFORM bdc_dynpro TABLES bdcdata[] USING 'SAPMV13A' '1067'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_CURSOR'
'RV13A-DATBI(01)'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field TABLES bdcdata[] USING 'KOMG-LIFNR'
is_data-lifnr.
PERFORM bdc_field TABLES bdcdata[] USING 'KOMG-MATNR'
is_data-matnr.
PERFORM bdc_field TABLES bdcdata[] USING 'KOMG-EKORG'
is_data-ekorg.
PERFORM bdc_field TABLES bdcdata[] USING 'KOMG-ESOKZ'
is_data-esokz.
PERFORM bdc_field TABLES bdcdata[] USING 'KOMG-WERKS(01)'
is_data-werks.
PERFORM bdc_field TABLES bdcdata[] USING 'KOMG-BSTME(01)'
is_data-lmein.
jj = is_data-netpr.
CONDENSE jj NO-GAPS.
PERFORM bdc_field TABLES bdcdata[] USING 'KONP-KBETR(01)'
jj.
dw = is_data-peinh.
CONDENSE dw NO-GAPS.
PERFORM bdc_field TABLES bdcdata[] USING 'KONP-KPEIN(01)'
dw.
PERFORM bdc_field TABLES bdcdata[] USING 'RV13A-DATAB(01)'
is_data-datab.
PERFORM bdc_field TABLES bdcdata[] USING 'RV13A-DATBI(01)'
is_data-datbi.
PERFORM bdc_dynpro TABLES bdcdata[] USING 'SAPMV13A' '1067'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_CURSOR'
'KOMG-WERKS(01)'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro TABLES bdcdata[] USING 'SAPMV13A' '1067'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_CURSOR'
'KOMG-WERKS(01)'.
PERFORM bdc_field TABLES bdcdata[] USING 'BDC_OKCODE'
'=SICH'.
ctumode = 'A'.
cupdate = 'S'.
CALL TRANSACTION 'MEK1' USING bdcdata
MODE ctumode
UPDATE cupdate
MESSAGES INTO messtab.
READ TABLE messtab WITH KEY msgtyp = 'E'.
IF sy-subrc <> 0 .
COMMIT WORK AND WAIT.
READ TABLE lt_et_eina INTO ls_et_eina INDEX 1.
IF NOT ls_et_eina-info_rec IS INITIAL.
DO 10 TIMES.
SELECT SINGLE infnr
FROM eine
INTO @lv_infnr
WHERE infnr = @ls_et_eina-info_rec
AND ekorg = @is_data-ekorg
AND esokz = @is_data-esokz.
IF sy-subrc = 0.
EXIT.
ELSE.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDDO.
ENDIF.
向BDC传值时,提示错误,在代码传值时,加NO-GAPS即可.
4、对于BAPI+BAPI方式估计也行:ME_INFORECORD_MAINTAIN_MULTI+ BAPI_PRICES_CONDITIONS,暂时未测试;或者ME11直接录屏
以上纯属个人笔记截图均来自SAP系统,仅用于日常分享,如有侵权联系本人删除,喜欢的帮忙点个赞!如果有问题请在下方留言!