Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HOW TO USE BAPI FOR INBOUND INTERFACE

Hi Experts, Good day!

I am using now BDC for the device creations. But they want to use BAPI, I didnt work before on BAPIs so please send me some sample code. I am sending my rfc fm, please check it and let me know where exactly I want to use the bapis and give me some sample code.

ACTUALLY THE DATA IS SENDING XI.

FUNCTION yisu_rmdmii06_equi_create.

*"----


""Local interface:

*" EXPORTING

*" VALUE(SUBRC) LIKE SYST-SUBRC

*" TABLES

*" DEVICEINFO STRUCTURE YRMDMII06DVCINFO

*" MESSTAB STRUCTURE BDCMSGCOLL

*"----


TYPES: BEGIN OF t_returnmsg,

fldname LIKE bapiret2-field,

msgnr LIKE sy-msgno,

msgv1 LIKE sy-msgv1,

msgv2 LIKE sy-msgv2,

msgv3 LIKE sy-msgv3,

msgv4 LIKE sy-msgv4,

END OF t_returnmsg.

DATA: gwa_returnmsg TYPE t_returnmsg.

*-- Execution Time

gwa_ii06log-exectime = sy-uzeit.

REFRESH: gi_errorlog.

*-- For Multiple deveices to be created

LOOP AT deviceinfo.

*-- Deveices with Register Group

IF NOT deviceinfo-zwgruppe IS INITIAL.

REFRESH: messtab.

CALL FUNCTION 'YISU_RMDMII06_EQUI_CREATE05'

EXPORTING

ctu = 'X'

mode = 'N'

UPDATE = 'L'

nodata = '/'

matnr_001 = deviceinfo-material

sernr_002 = deviceinfo-serialno

eqtyp_003 = 'I'

herst_004 = deviceinfo-manfacture

ab_005 = deviceinfo-valid_date

typbz_006 = deviceinfo-manmodel

baujj_007 = deviceinfo-constyear

zwgruppe_008 = deviceinfo-zwgruppe

besitz_009 = deviceinfo-besitz

bglnetz_010 = 'X'

  • shtxt_011 = 'X'

  • SPARTE_012 = '03'

groes_013 = deviceinfo-groes

herst_014 = deviceinfo-manfacture

typbz_015 = deviceinfo-manmodel

baujj_016 = deviceinfo-constyear

  • shtxt_017 =

stsma_018 = 'ZCOJ'

etx04_019 = 'NTAV'

  • SPARTE_020 = '03'

groes_021 = deviceinfo-groes

herst_022 = deviceinfo-manfacture

typbz_023 = deviceinfo-manmodel

baujj_024 = deviceinfo-constyear

  • shtxt_025 =

IMPORTING

subrc = subrc

TABLES

messtab = messtab.

*if subrc = 0.

*commit work.

*else.

*endif.

LOOP AT messtab.

MOVE-CORRESPONDING messtab TO gwa_returnmsg.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = messtab-msgtyp

cl = messtab-msgid

number = gwa_returnmsg-msgnr

par1 = gwa_returnmsg-msgv1

par2 = gwa_returnmsg-msgv2

par3 = gwa_returnmsg-msgv3

par4 = gwa_returnmsg-msgv4

field = gwa_returnmsg-fldname

IMPORTING

return = gv_return.

gwa_errorlog-material = deviceinfo-material.

gwa_errorlog-serialno = deviceinfo-serialno.

gwa_errorlog-message = gv_return-message.

APPEND gwa_errorlog TO gi_errorlog.

ENDLOOP.

ENDIF.

*-- Deveices with Winding Group

IF NOT deviceinfo-wgruppe IS INITIAL.

REFRESH: messtab.

CALL FUNCTION 'YISU_RMDMII06_EQUI_CREATE03'

EXPORTING

ctu = 'X'

mode = 'N'

UPDATE = 'L'

nodata = '/'

group = 'DEVICE_W'

user = sy-uname

keep = 'X'

  • holddate = sy-datum

matnr_001 = deviceinfo-material

sernr_002 = deviceinfo-serialno

eqtyp_003 = 'I'

herst_004 = deviceinfo-manfacture

ab_005 = deviceinfo-valid_date

typbz_006 = deviceinfo-manmodel

baujj_007 = deviceinfo-constyear

wgruppe_008 = deviceinfo-wgruppe

besitz_009 = deviceinfo-besitz

stsma_011 = 'zcoj'

etx04_012 = 'NTAV'

IMPORTING

subrc = subrc

TABLES

messtab = messtab.

*if subrc = 0.

*commit work.

*else.

LOOP AT messtab.

MOVE-CORRESPONDING messtab TO gwa_returnmsg.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = messtab-msgtyp

cl = messtab-msgid

number = gwa_returnmsg-msgnr

par1 = gwa_returnmsg-msgv1

par2 = gwa_returnmsg-msgv2

par3 = gwa_returnmsg-msgv3

par4 = gwa_returnmsg-msgv4

field = gwa_returnmsg-fldname

IMPORTING

return = gv_return.

gwa_errorlog-material = deviceinfo-material.

gwa_errorlog-serialno = deviceinfo-serialno.

gwa_errorlog-message = gv_return-message.

APPEND gwa_errorlog TO gi_errorlog.

ENDLOOP.

ENDIF.

ENDLOOP.

*-- Completion Time

gwa_ii06log-compltime = sy-uzeit.

PERFORM f_yrmdmii06errlog TABLES gi_errorlog.

subrc = sy-subrc.

  • commit work.

ENDFUNCTION.

FUNCTIONS MODULES.

1. YISU_RMDMII06_EQUI_CREATE05

FUNCTION yisu_rmdmii06_equi_create05.

*"----


""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(MATNR_001) LIKE BDCDATA-FVAL DEFAULT '130'

*" VALUE(SERNR_002) LIKE BDCDATA-FVAL DEFAULT 'NewTest01'

*" VALUE(EQTYP_003) LIKE BDCDATA-FVAL DEFAULT 'I'

*" VALUE(HERST_004) LIKE BDCDATA-FVAL DEFAULT 'ABB / ELSTER'

*" VALUE(AB_005) LIKE BDCDATA-FVAL DEFAULT '30072007'

*" VALUE(TYPBZ_006) LIKE BDCDATA-FVAL DEFAULT 'HELIX 3000'

*" VALUE(BAUJJ_007) LIKE BDCDATA-FVAL DEFAULT '2005'

*" VALUE(ZWGRUPPE_008) LIKE BDCDATA-FVAL DEFAULT 'WMKL15-5'

*" VALUE(BESITZ_009) LIKE BDCDATA-FVAL DEFAULT '03'

*" VALUE(BGLNETZ_010) LIKE BDCDATA-FVAL DEFAULT 'X'

*" VALUE(SHTXT_011) LIKE BDCDATA-FVAL OPTIONAL

*" VALUE(SPARTE_012) LIKE BDCDATA-FVAL DEFAULT '03'

*" VALUE(GROES_013) LIKE BDCDATA-FVAL DEFAULT '15MM'

*" VALUE(HERST_014) LIKE BDCDATA-FVAL DEFAULT 'ABB / ELSTER'

*" VALUE(TYPBZ_015) LIKE BDCDATA-FVAL DEFAULT 'HELIX 3000'

*" VALUE(BAUJJ_016) LIKE BDCDATA-FVAL DEFAULT '2005'

*" VALUE(SHTXT_017) LIKE BDCDATA-FVAL OPTIONAL

*" VALUE(STSMA_018) LIKE BDCDATA-FVAL DEFAULT 'ZCOJ'

*" VALUE(ETX04_019) LIKE BDCDATA-FVAL DEFAULT 'NTAV'

*" VALUE(SPARTE_020) LIKE BDCDATA-FVAL DEFAULT '03'

*" VALUE(GROES_021) LIKE BDCDATA-FVAL DEFAULT '15MM'

*" VALUE(HERST_022) LIKE BDCDATA-FVAL DEFAULT 'ABB / ELSTER'

*" VALUE(TYPBZ_023) LIKE BDCDATA-FVAL DEFAULT 'HELIX 3000'

*" VALUE(BAUJJ_024) LIKE BDCDATA-FVAL DEFAULT '2005'

*" VALUE(SHTXT_025) LIKE BDCDATA-FVAL OPTIONAL

*" EXPORTING

*" VALUE(SUBRC) LIKE SYST-SUBRC

*" TABLES

*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL

*"----


subrc = 0.

PERFORM bdc_nodata USING nodata.

PERFORM open_group USING group user keep holddate ctu.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '1000'.

PERFORM bdc_field USING 'BDC_CURSOR' 'RISA0-SERNR'.

PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

PERFORM bdc_field USING 'RISA0-MATNR' matnr_001.

PERFORM bdc_field USING 'RISA0-SERNR' sernr_002.

PERFORM bdc_field USING 'RM63E-EQTYP' eqtyp_003.

PERFORM bdc_dynpro USING 'SAPLE10R' '1100'.

PERFORM bdc_field USING 'BDC_CURSOR' 'EDEVICED-BGLJAHR'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SAVE'.

PERFORM bdc_field USING 'EDEVICED-HERST' herst_004.

PERFORM bdc_field USING 'EDEVICED-AB' ab_005.

PERFORM bdc_field USING 'EDEVICED-TYPBZ' typbz_006.

PERFORM bdc_field USING 'EDEVICED-BAUJJ' baujj_007.

PERFORM bdc_field USING 'EDEVICED-ZWGRUPPE' zwgruppe_008.

PERFORM bdc_field USING 'EDEVICED-BESITZ' besitz_009.

PERFORM bdc_field USING 'EDEVICED-BGLNETZ' bglnetz_010.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE' '=T\01'.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-SHTXT'.

PERFORM bdc_field USING 'ITOB-SHTXT' shtxt_011.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SU'.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-GROES'.

PERFORM bdc_field USING 'ITOB-SPARTE' sparte_012.

PERFORM bdc_field USING 'ITOB-GROES' groes_013.

PERFORM bdc_field USING 'ITOB-HERST' herst_014.

PERFORM bdc_field USING 'ITOB-TYPBZ' typbz_015.

PERFORM bdc_field USING 'ITOB-BAUJJ' baujj_016.

PERFORM bdc_field USING 'ITOB-SHTXT' shtxt_017.

PERFORM bdc_dynpro USING 'SAPLBSVA' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE' '=DIRI'.

PERFORM bdc_field USING 'BDC_CURSOR' 'JOSTD-STSMA'.

PERFORM bdc_field USING 'JOSTD-STSMA' stsma_018.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0500'.

PERFORM bdc_field USING 'BDC_OKCODE' '=OPT1'.

PERFORM bdc_dynpro USING 'SAPLBSVA' '0882'.

PERFORM bdc_field USING 'BDC_CURSOR' 'JESTD-ETX04'.

PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.

PERFORM bdc_field USING 'JESTD-ETX04' etx04_019.

PERFORM bdc_dynpro USING 'SAPLBSVA' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-MATNR'.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.

PERFORM bdc_field USING 'ITOB-SPARTE' sparte_020.

PERFORM bdc_field USING 'ITOB-GROES' groes_021.

PERFORM bdc_field USING 'ITOB-HERST' herst_022.

PERFORM bdc_field USING 'ITOB-TYPBZ' typbz_023.

PERFORM bdc_field USING 'ITOB-BAUJJ' baujj_024.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-MATNR'.

PERFORM bdc_field USING 'ITOB-SHTXT' shtxt_025.

PERFORM bdc_transaction TABLES messtab

USING 'IQ01'

ctu

mode

update.

IF sy-subrc <> 0.

subrc = sy-subrc.

EXIT.

ENDIF.

PERFORM close_group USING ctu.

ENDFUNCTION.

2. yisu_rmdmii06_equi_create03.

FUNCTION yisu_rmdmii06_equi_create03.

*"----


""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(MATNR_001) LIKE BDCDATA-FVAL DEFAULT '136'

*" VALUE(SERNR_002) LIKE BDCDATA-FVAL DEFAULT 'tebza03'

*" VALUE(EQTYP_003) LIKE BDCDATA-FVAL DEFAULT 'I'

*" VALUE(HERST_004) LIKE BDCDATA-FVAL DEFAULT 'ABB / ELSTER'

*" VALUE(AB_005) LIKE BDCDATA-FVAL DEFAULT '01012006'

*" VALUE(TYPBZ_006) LIKE BDCDATA-FVAL DEFAULT 'ABBE 6008'

*" VALUE(BAUJJ_007) LIKE BDCDATA-FVAL DEFAULT '2006'

*" VALUE(WGRUPPE_008) LIKE BDCDATA-FVAL DEFAULT 'MCT600/5'

*" VALUE(BESITZ_009) LIKE BDCDATA-FVAL DEFAULT '03'

*" VALUE(SHTXT_010) LIKE BDCDATA-FVAL DEFAULT ''

*" VALUE(STSMA_011) LIKE BDCDATA-FVAL DEFAULT 'zcoj'

*" VALUE(ETX04_012) LIKE BDCDATA-FVAL DEFAULT 'NTAV'

*" VALUE(SHTXT_013) LIKE BDCDATA-FVAL DEFAULT ''

*" EXPORTING

*" VALUE(SUBRC) LIKE SYST-SUBRC

*" TABLES

*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL

*"----


subrc = 0.

PERFORM bdc_nodata USING nodata.

PERFORM open_group USING group user keep holddate ctu.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '1000'.

PERFORM bdc_field USING 'BDC_CURSOR' 'RISA0-SERNR'.

PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

PERFORM bdc_field USING 'RISA0-MATNR' matnr_001.

PERFORM bdc_field USING 'RISA0-SERNR' sernr_002.

PERFORM bdc_field USING 'RM63E-EQTYP' eqtyp_003.

PERFORM bdc_dynpro USING 'SAPLE10R' '1100'.

PERFORM bdc_field USING 'BDC_CURSOR' 'EDEVICED-BESITZ'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SAVE'.

PERFORM bdc_field USING 'EDEVICED-HERST' herst_004.

PERFORM bdc_field USING 'EDEVICED-AB' ab_005.

PERFORM bdc_field USING 'EDEVICED-TYPBZ' typbz_006.

PERFORM bdc_field USING 'EDEVICED-BAUJJ' baujj_007.

PERFORM bdc_field USING 'EDEVICED-WGRUPPE' wgruppe_008.

PERFORM bdc_field USING 'EDEVICED-BESITZ' besitz_009.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE' '=SU'.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-SHTXT'.

PERFORM bdc_field USING 'ITOB-SHTXT' shtxt_010.

PERFORM bdc_dynpro USING 'SAPLBSVA' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE' '=DIRI'.

PERFORM bdc_field USING 'BDC_CURSOR' 'JOSTD-STSMA'.

PERFORM bdc_field USING 'JOSTD-STSMA' stsma_011.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0500'.

PERFORM bdc_field USING 'BDC_OKCODE' '=OPT1'.

PERFORM bdc_dynpro USING 'SAPLBSVA' '0882'.

PERFORM bdc_field USING 'BDC_CURSOR' 'JESTD-ETX04'.

PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.

PERFORM bdc_field USING 'JESTD-ETX04' etx04_012.

PERFORM bdc_dynpro USING 'SAPLBSVA' '0300'.

PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-MATNR'.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.

PERFORM bdc_field USING 'BDC_CURSOR' 'ITOB-MATNR'.

PERFORM bdc_field USING 'ITOB-SHTXT' shtxt_013.

PERFORM bdc_transaction TABLES messtab USING 'IQ01'

ctu

mode

update.

IF sy-subrc <> 0.

subrc = sy-subrc.

EXIT.

ENDIF.

PERFORM close_group USING ctu.

ENDFUNCTION.

INCLUDE: bdcrecxy.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question