工作中的需求是这样子的:
在某天,我们公司的采购提了一个需求,说是在从OA创建采购信息记录的时候,价格上限应该自动默认为是价格字段,但是这个在系统里面没有做,采购在创建玩之后需要一个个手工去修改,因此想让我看看能不能通过开发解决。
再来说说修改之前SAP中是怎么处理的吧:
一开始我想通过找个跟这个需求有关的BAPI来完成,但是看了网上所谓的BAPI大全之后,发现即使有创建信息记录的BAPI,也没有对应字段去修改价格上限,所以这种方法被我放弃了;后来公司的前辈和我说,我们是通过BDC录屏来做这个事情的。于是在网上找了相关BDC的博客学习了之后,我自己也去录了一下,具体的步骤如下:
1、进SAP的开发(DEV)系统,输入事务码ME11(创建采购信息记录),先去找一组没有用过的数据,然后再问你是否保存该信息记录的时候点“否”,记录下这组数据;
2、输入事务码SHDB(BDC录屏的事务码),进入下面的界面
3、点击上面的“NEW RECODING”,进入创建BDC的界面:
在这个界面中输入BDC的名称,以及BDC操作的事务码,填写完成以后点击下面的”START RECORDING”,就可以开始录屏了。
4、接下来进入创建采购信息记录的界面,和业务平时的操作一样,将刚才记录下来的数据填写进去:
5、回车进入下一个界面:
接下来就是填写一些必要的数据:
到了这个界面之后,记得点“条件”按钮,进去修改价格上限
选中该行之后,点击工具栏的“细节”,进入修改价格上限界面:
修改好之后点保存录屏就完成了,此时,你在录屏的时候创建的采购信息也可以查询到了,进入以下的界面:
点击保存,退出。至此录屏的工作就完成了。
6、将录屏发布为程序或FUNCTION MODULE:录屏本身的作用很有局限性,但是在录完屏后可以自动将录屏生成为ABAP程序或是函数模块,这样就会大大增强BDC的功能
7、如果选择发布为FUNCTION MODULE,则会自动发布为具有RFC功能的函数模块,其数据来源是由外部传入;
8、如果选择发布为PROGRAM,则会发布为ABAP程序,可以进SE38对程序进行修改,这种情况数据源一般是另外导入的,所以要配合其他的程序去实现业务操作;
9、我这里选择的是发布为函数模块(因为OA中调用的是函数模块) ,可以进SE37进行查看,或debug。
10、接下来我想说的是,我的BDC函数在开发环境中可以很好的运行,但是传输到测试环境的时候,出现了函数一直运行不停止的现象(这个时候其实信息记录早已建立完成),找了半天也没有找出问题点,但这个问题不解决的话,批量处理的时候就会一直卡着,所以这关必须要过。
11、我在QAS里面录的屏也会出现这种现象,在QAS里面录屏出现这种现象的原因我猜测应该是以下几个方面,第一:QAS里面不允许做开发,第二:QAS里面的配置和DEV的有差异;QAS里面即使不能做开发,那录屏应该还是可以的,所以应该是第二个问题。
12、配置问题我可从来没弄过,但业务又催,所以我就想了一个笨办法(死马当活马医),在原本的录屏中除了有ME11的,还有ME12(修改采购信息记录)的,所以我就把原来的两个函数放到一块儿,让他在创建的时候进ME12修改一下,把价格上限修改过来,结果是:这样做了时候在DEV里面运行不了,但是传输到QAS之后却能正常运行(一般QAS和正式环境的配置都不会有差异),这个问题到这里才算解决
13、另:QAS处理BDC的代码和SAP自动生成的代码有较大差异,现贴出来供参考:
FUNCTION ZBW_SET_CREATE_INFORECORD1.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(CTU) LIKE APQI-PUTACTIVE DEFAULT 'X'
*" VALUE(MODE) LIKE APQI-PUTACTIVE DEFAULT 'N'
*" VALUE(UPDATE) LIKE APQI-PUTACTIVE DEFAULT 'L'
*" VALUE(GROUP) LIKE APQI-GROUPID OPTIONAL
*" VALUE(USER) LIKE APQI-USERID OPTIONAL
*" VALUE(KEEP) LIKE APQI-QERASE OPTIONAL
*" VALUE(HOLDDATE) LIKE APQI-STARTDATE OPTIONAL
*" VALUE(NODATA) LIKE APQI-PUTACTIVE DEFAULT '/'
*" VALUE(LIFNR_001) LIKE BDCDATA-FVAL DEFAULT '30108'
*" VALUE(MATNR_002) LIKE BDCDATA-FVAL DEFAULT '1310620'
*" VALUE(EKORG_003) LIKE BDCDATA-FVAL DEFAULT '1100'
*" VALUE(WERKS_004) LIKE BDCDATA-FVAL DEFAULT '1120'
*" VALUE(NORMB_005) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(URZLA_006) LIKE BDCDATA-FVAL DEFAULT 'CN'
*" VALUE(MEINS_007) LIKE BDCDATA-FVAL DEFAULT 'KG'
*" VALUE(UMREZ_008) LIKE BDCDATA-FVAL DEFAULT '1'
*" VALUE(UMREN_009) LIKE BDCDATA-FVAL DEFAULT '1'
*" VALUE(APLFZ_010) LIKE BDCDATA-FVAL DEFAULT '10'
*" VALUE(EKGRP_011) LIKE BDCDATA-FVAL DEFAULT '100'
*" VALUE(NORBM_012) LIKE BDCDATA-FVAL DEFAULT '10'
*" VALUE(WEBRE_013) LIKE BDCDATA-FVAL DEFAULT 'X'
*" VALUE(MWSKZ_014) LIKE BDCDATA-FVAL DEFAULT 'J0'
*" VALUE(IPRKZ_015) LIKE BDCDATA-FVAL DEFAULT 'D'
*" VALUE(NETPR_016) LIKE BDCDATA-FVAL DEFAULT ' 11'
*" VALUE(WAERS_017) LIKE BDCDATA-FVAL DEFAULT 'RMB'
*" VALUE(PEINH_018) LIKE BDCDATA-FVAL DEFAULT '1'
*" VALUE(BPRME_019) LIKE BDCDATA-FVAL DEFAULT 'KG'
*" VALUE(BPUMZ_020) LIKE BDCDATA-FVAL DEFAULT '1'
*" VALUE(BPUMN_021) LIKE BDCDATA-FVAL DEFAULT '1'
*" VALUE(DATAB_022) LIKE BDCDATA-FVAL DEFAULT '2015.04.04'
*" VALUE(DATBI_023) LIKE BDCDATA-FVAL DEFAULT '2015.04.18'
*" EXPORTING
*" VALUE(MSGTYP) TYPE STRING
*" VALUE(L_MSTRING) TYPE STRING
*" VALUE(INFNR) TYPE STRING
*" TABLES
*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL
*"----------------------------------------------------------------------
DATA: IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
- messages of call transaction
DATA: IT_BDCMSG TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.
*Global definition
DATA: G_MODE(1) VALUE ‘E’,
MESSAGE(100) TYPE C,
G_UPDT(1) VALUE ‘S’.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
-
messages of call transaction
*DATA: MESSTAB1 LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
-
error session opened (<span class="hljs-string">' '</span> <span class="hljs-keyword">or</span> <span class="hljs-string">'X'</span>)
DATA: E_GROUP_OPENED.
-
message texts
*TABLES: T100.
- DATA: L_MSTRING(480) TYPE C.
- DATA: MSGTYP(1) TYPE C.
DATA:SUBRC like SYST-SUBRC.
SUBRC = 0.
*perform bdc_nodata using NODATA.
*
*perform open_group using GROUP USER KEEP HOLDDATE CTU.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0100’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-WERKS’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-LIFNR’
LIFNR_001.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-MATNR’
MATNR_002.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-EKORG’
EKORG_003.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-WERKS’
WERKS_004.
CLEAR BDCDATA.
IF NORMB_005 = ‘BZ’.
perform BDC_FIELD1 TABLES BDCDATA using ‘RM06I-NORMB’
‘X’.
ELSEIF NORMB_005 = ‘WX’.
perform BDC_FIELD1 TABLES BDCDATA using ‘RM06I-LOHNB’
‘X’.
ELSEIF NORMB_005 = ‘GD’.
perform BDC_FIELD1 TABLES BDCDATA using ‘RM06I-PIPEL’
‘X’.
ELSEIF NORMB_005 = ‘JS’.
perform BDC_FIELD1 TABLES BDCDATA using ‘RM06I-KONSI’
‘X’.
ENDIF.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0101’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINA-MAHN1’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-URZLA’
URZLA_006.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-MEINS’
MEINS_007.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-UMREZ’
UMREZ_008.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-UMREN’
UMREN_009.
************2015.07.08 取消更新货源清单的功能
*CLEAR BDCDATA.
*PERFORM BDC_DYNPRO1 TABLES BDCDATA USING ‘SAPLMEOR’ ‘0230’.
*CLEAR BDCDATA.
*PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_CURSOR’
-
<span class="hljs-string">'EORD-BDATU(01)'</span>.
*CLEAR BDCDATA.
*PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_OKCODE’
-
<span class="hljs-string">'/00'</span>.
*CLEAR BDCDATA.
*PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘EORD-VDATU(01)’
-
DATAB_022.
*CLEAR BDCDATA.
*PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘EORD-BDATU(01)’
-
DATBI_023.
*CLEAR BDCDATA.
*PERFORM BDC_DYNPRO1 TABLES BDCDATA USING ‘SAPLMEOR’ ‘0230’.
*CLEAR BDCDATA.
*PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_CURSOR’
-
<span class="hljs-string">'EINA-INFNR'</span>.
*CLEAR BDCDATA.
*PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_OKCODE’
-
<span class="hljs-string">'=EN'</span>.
*CLEAR BDCDATA.
*perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0101’.
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
-
<span class="hljs-string">'EINA-MAHN1'</span>.
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
-
<span class="hljs-string">'/00'</span>.
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-URZLA’
-
URZLA_006.
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-MEINS’
-
MEINS_007.
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-UMREZ’
-
UMREZ_008.
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘EINA-UMREN’
-
UMREN_009.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0102’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-NETPR’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-APLFZ’
APLFZ_010.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-EKGRP’
EKGRP_011.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-NORBM’
NORBM_012.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-WEBRE’
WEBRE_013.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-MWSKZ’
MWSKZ_014.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-IPRKZ’
IPRKZ_015.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-NETPR’
NETPR_016.
*信息记录中的币别有供应商中的订单单位自动带出 因此注释一下代码 20160729 wxb
*CLEAR BDCDATA.
*perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-WAERS’
-
WAERS_017.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-PEINH’
PEINH_018.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-BPRME’
BPRME_019.
“CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-BPUMZ’
BPUMZ_020.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘EINE-BPUMN’
BPUMN_021.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0105’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-ANGNR’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘=KO’.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMV13A’ ‘0201’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘RV13A-DATBI’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘=BACK’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘RV13A-DATAB’
DATAB_022.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘RV13A-DATBI’
DATBI_023.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0105’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-ANGNR’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPMM06I’ ‘0103’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_CURSOR’
‘RM06I-LTEX1(01)’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform BDC_DYNPRO1 TABLES BDCDATA using ‘SAPLSPO1’ ‘0100’.
CLEAR BDCDATA.
perform BDC_FIELD1 TABLES BDCDATA using ‘BDC_OKCODE’
‘=YES’.
PERFORM BDC_TRANSACTION1 TABLES MESSTAB BDCDATA
USING ‘ME11’
CTU
MODE
UPDATE
L_MSTRING
MSGTYP
INFNR.
if sy-subrc <> 0.
subrc = sy-subrc.
exit.
endif.
增加的修改信息记录功能 20170505 by lcq***********************
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMM06I’ ‘0100’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-WERKS’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINA-LIFNR’
LIFNR_001.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINA-MATNR’
MATNR_002.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-EKORG’
EKORG_003.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-WERKS’
WERKS_004.
*CLEAR BDCDATA.
*perform bdc_field2 TABLES BDCDATA using ‘RM06I-NORMB’
-
NORMB_005. CLEAR BDCDATA. IF NORMB_005 = 'BZ'.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RM06I-NORMB’
‘X’.
ELSEIF NORMB_005 = ‘WX’.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RM06I-LOHNB’
‘X’.
ELSEIF NORMB_005 = ‘GD’.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RM06I-PIPEL’
‘X’.
ELSEIF NORMB_005 = ‘JS’.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RM06I-KONSI’
‘X’.
ENDIF.
CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMM06I’ ‘0101’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINA-MAHN1’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘=KO’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINA-URZLA’
URZLA_006.
*CLEAR BDCDATA.
*perform bdc_field2 TABLES BDCDATA using ‘EINA-REGIO’
-
REGIO_007.
*CLEAR BDCDATA.
*perform bdc_field2 TABLES BDCDATA using ‘EINA-TELF1’
-
TELF1_008.
-
CLEAR BDCDATA.
*perform bdc_field2 TABLES BDCDATA using ‘EINA-MEINS’
-
MEINS_009. CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINA-UMREZ’
UMREZ_008.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINA-UMREN’
UMREN_009.
CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPLV14A’ ‘0102’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘VAKE-DATAB(01)’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘=PICK’.
CLEAR BDCDATA.
PERFORM BDC_DYNPRO1 TABLES BDCDATA USING ‘SAPMV13A’ ‘0201’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_CURSOR’
‘RV13A-DATAB’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_OKCODE’
‘=PDAT’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV13A-DATAB’
DATAB_022.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV13A-DATBI’
DATBI_023.
CLEAR BDCDATA.
PERFORM BDC_DYNPRO1 TABLES BDCDATA USING ‘SAPMV13A’ ‘0201’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_CURSOR’
‘KONP-KSCHL(01)’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_OKCODE’
‘=PDAT’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV13A-DATAB’
DATAB_022.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV13A-DATBI’
DATBI_023.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV130-SELKZ(01)’
-
SELKZ_01_030.'X' 'X'.
CLEAR BDCDATA.
PERFORM BDC_DYNPRO1 TABLES BDCDATA USING ‘SAPMV13A’ ‘0300’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_CURSOR’
‘RV13A-DATBI’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘BDC_OKCODE’
‘=BACK’.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV13A-DATAB’
DATAB_022.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘RV13A-DATBI’
DATBI_023.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘KONP-KBETR’
NETPR_016.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘KONP-GKWRT’
NETPR_016.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘KONP-STFKZ’ STFKZ_035."</span>A <span class="hljs-string">'A'</span>.
CLEAR BDCDATA.
PERFORM BDC_FIELD1 TABLES BDCDATA USING ‘KONP-KZNEP’KZNEP_036.<span class="hljs-string">"'X' 'X'. CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMV13A’ ‘0201’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘KONP-KBETR(01)’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘BACK’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘RV13A-DATAB’
DATAB_022.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘RV13A-DATBI’
DATBI_023.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘KONP-KBETR(01)’
NETPR_016.
CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMM06I’ ‘0101’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINA-MAHN1’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINA-URZLA’
URZLA_006.
*CLEAR BDCDATA.
*perform bdc_field2 TABLES BDCDATA using ‘EINA-REGIO’
-
REGIO_016.
*CLEAR BDCDATA.
*perform bdc_field2 TABLES BDCDATA using ‘EINA-TELF1’
-
TELF1_017. CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMM06I’ ‘0102’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-APLFZ’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-APLFZ’
APLFZ_010.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-EKGRP’
EKGRP_011.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-NORBM’
NORBM_012.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-WEBRE’
WEBRE_013.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-MWSKZ’
MWSKZ_014.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘EINE-IPRKZ’
IPRKZ_015.
CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMM06I’ ‘0105’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘EINE-ANGNR’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPMM06I’ ‘0103’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_CURSOR’
‘RM06I-LTEX1(01)’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘/00’.
CLEAR BDCDATA.
perform bdc_dynpro1 TABLES BDCDATA using ‘SAPLSPO1’ ‘0100’.
CLEAR BDCDATA.
perform bdc_field1 TABLES BDCDATA using ‘BDC_OKCODE’
‘=YES’.
*perform bdc_transaction tables messtab
*using ‘ME12’
-
CTU
-
MODE
-
UPDATE.
PERFORM BDC_TRANSACTION1 TABLES MESSTAB BDCDATA
USING ‘ME12’
CTU
MODE
UPDATE
L_MSTRING
MSGTYP
INFNR.
if sy-subrc <> 0.
subrc = sy-subrc.
exit.
endif.
perform close_group1 using CTU.
ENDFUNCTION.
*———————————————————————-
** data definition
*———————————————————————-
** Batchinputdata of single transaction
*DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
** messages of call transaction
*DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
** error session opened (’ ’ or ‘X’)
*DATA: E_GROUP_OPENED.
** message texts
*TABLES: T100.
&———————————————————————
*& Form BDC_DYNPRO
&———————————————————————
-
text
———————————————————————-
-
-->P_0021 text
-
-->P_0022 text
———————————————————————-
FORM BDC_DYNPRO1 TABLES BDCDATA STRUCTURE BDCDATA USING VALUE(P_0021)
VALUE(P_0022).
- DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
- CLEAR BDCDATA.
BDCDATA-PROGRAM = P_0021.
BDCDATA-DYNPRO = P_0022.
BDCDATA-DYNBEGIN = ‘X’.
APPEND BDCDATA.
ENDFORM. ” BDC_DYNPRO
&———————————————————————
*& Form BDC_FIELD
&———————————————————————
-
text
———————————————————————-
-
-->P_0026 text
-
-->P_0027 text
———————————————————————-
FORM BDC_FIELD1 TABLES BDCDATA STRUCTURE BDCDATA
USING VALUE(P_0026)
VALUE(P_0027).
- DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
IF P_0027 <> ‘/’.
- CLEAR BDCDATA.
BDCDATA-FNAM = P_0026.
BDCDATA-FVAL = P_0027.
APPEND BDCDATA.
ENDIF.
ENDFORM. ” BDC_FIELD
&———————————————————————
*& Form BDC_TRANSACTION
&———————————————————————
-
text
———————————————————————-
-
-->P_MESSTAB text
-
-->P_0298 text
-
-->P_CTU text
-
-->P_MODE text
-
-->P_UPDATE text
———————————————————————-
FORM BDC_TRANSACTION1 TABLES P_MESSTAB STRUCTURE BDCMSGCOLL
BDCDATA STRUCTURE BDCDATA
“插入正确名称 <…>
USING VALUE(P_0298)
P_CTU
P_MODE
P_UPDATE
L_MSTRING
MSGTYP
INFNR.
- DATA: L_MSTRING(480) TYPE C.
- DATA: MSGTYP(1) TYPE C.
DATA: L_SUBRC LIKE SY-SUBRC.
** batch input session
- IF SESSION = ‘X’.
- CALL FUNCTION ‘BDC_INSERT’
-
EXPORTING TCODE = TCODE
-
TABLES DYNPROTAB = BDCDATA.
- IF SMALLLOG <> ‘X’.
-
<span class="hljs-symbol">WRITE:</span> / <span class="hljs-string">'BDC_INSERT'</span>(I03),
-
TCODE,
-
<span class="hljs-string">'returncode:'</span>(I05),
-
SY-SUBRC,
-
<span class="hljs-string">'RECORD:'</span>,
-
SY-INDEX.
- ENDIF.
** call transaction using - ELSE.
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: ZT100 LIKE T100 OCCURS 0 WITH HEADER LINE. - DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
REFRESH MESSTAB.
CALL TRANSACTION P_0298 USING BDCDATA
MODE P_MODE
UPDATE P_UPDATE
MESSAGES INTO MESSTAB.
L_SUBRC = SY-SUBRC. - IF SMALLLOG <> ‘X’.
WRITE: / ‘CALL_TRANSACTION’,
P_0298,
‘returncode:’(I05),
L_SUBRC,
‘RECORD:’,
SY-INDEX.
LOOP AT MESSTAB.
SELECT SINGLE * FROM T100 INTO ZT100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = ZT100-TEXT.
IF L_MSTRING CS ‘&1’.
REPLACE ‘&1’ WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE ‘&2’ WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE ‘&3’ WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE ‘&4’ WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE ‘&’ WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE ‘&’ WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE ‘&’ WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE ‘&’ WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING. -
<span class="hljs-symbol">WRITE:</span> / MESSTAB-MSGTYP, L_MSTRING(<span class="hljs-number">250</span>).
MSGTYP = MESSTAB-MSGTYP.
INFNR = MESSTAB-MSGV1.
ELSE.
WRITE: / MESSTAB.
ENDIF.
ENDLOOP.
SKIP.
- ENDIF.
** Erzeugen fehlermappe ************************************************ - IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
-
IF E_GROUP_OPENED = <span class="hljs-string">' '</span>.
-
CALL FUNCTION <span class="hljs-string">'BDC_OPEN_GROUP'</span>
-
EXPORTING CLIENT = SY-MANDT
-
GROUP = E_GROUP
-
USER = E_USER
-
KEEP = E_KEEP
-
HOLDDATE = E_HDATE.
-
E_GROUP_OPENED = <span class="hljs-string">'X'</span>.
-
ENDIF.
-
CALL FUNCTION <span class="hljs-string">'BDC_INSERT'</span>
-
EXPORTING TCODE = TCODE
-
TABLES DYNPROTAB = BDCDATA.
- ENDIF.
- ENDIF.
REFRESH BDCDATA.
ENDFORM. ” BDC_TRANSACTION
&———————————————————————
*& Form CLOSE_GROUP
&———————————————————————
-
text
———————————————————————-
-
-->P_CTU text
———————————————————————-
FORM CLOSE_GROUP1 USING P_CTU.
ENDFORM. ” CLOSE_GROUP
&———————————————————————
*& Form OPEN_GROUP
&———————————————————————
-
text
———————————————————————-
-
-->P_GROUP text
-
-->P_USER text
-
-->P_KEEP text
-
-->P_HOLDDATE text
-
-->P_CTU text
———————————————————————-
FORM OPEN_GROUP1 USING P_GROUP
P_USER
P_KEEP
P_HOLDDATE
P_CTU.
ENDFORM. ” OPEN_GROUP
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/19884.html