Skip to Content

BAPI_MATERIAL_SAVEDATA extensionin DEC type dump

Hi experts,

Under the SAP ERP 6.0 EHP7, we have this requirement added the 2 field( Dec type 9 length 2 point) in BAPI_TE_MVKE:

used the FM: BAPI_MATERIAL_SAVEDATA will have a dump, I guess it have the issue it is the type convert . because standard extension cant input the dec type , just input only char type.


and use the CALL METHOD cl_abap_container_utilities=>fill_container_c to convert the dec type. (the mothod can convert the QUAN type, it is okay work for BApi BAPI_SALESORDER_CREATEFROMDAT2 );

already config the 2 field in SPRO, checked the T130F.

But I got the dump when I run the code as below:


Could you give me the any idea? Thank you very much!




*------------------------------------------------------------------------------

SALES_ORG type VKORG CHAR 4 0

DISTR_CHAN type VTWEG CHAR 2 0

.APPEND type ZSMVKE_BAPI 0 0

ZZXJE type ZEZZXJE DEC 9 2

ZZXJESF type ZEZZXJESF DEC 9 2

And my code:

*-----------------------------------------------------------------------------

DATA: s_te_mvke TYPE bapi_te_mvke.

DATA: s_te_mvkex TYPE bapi_te_mvkex.


DATA: t_extensionin TYPE TABLE OF bapiparex WITH HEADER LINE.
DATA: s_extensionin LIKE LINE OF t_extensionin.
DATA: t_extensioninx TYPE TABLE OF bapiparexx WITH HEADER LINE.
DATA: s_extensioninx LIKE LINE OF t_extensioninx.


CLEAR s_extensionin.
CLEAR s_te_mvke.

s_te_mvke-sales_org = ls_main-vkorg. "
s_te_mvke-distr_chan = ls_main-vtweg. "
s_te_mvke-zzxje = ls_main-zzxje. "enhancement field 1
s_te_mvke-zzxjesf = ls_main-zzxjesf. "enhancement field 2

s_extensionin-structure = 'BAPI_TE_MVKE'.



********

CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = s_te_mvke
IMPORTING
ex_container = s_extensionin-valuepart1
EXCEPTIONS
OTHERS = 0.

*********


APPEND s_extensionin TO t_extensionin.
CLEAR s_extensionin.
CLEAR s_extensioninx.
CLEAR s_te_mvkex.

s_te_mvkex-sales_org = ls_main-vkorg. "
s_te_mvkex-distr_chan = ls_main-vtweg. "
s_te_mvkex-zzxje = 'X'. "enhancement field 1
s_te_mvkex-zzxjesf = 'X'. "enhancement field 2
s_extensioninx-structure = 'BAPI_TE_MVKEX'.

s_extensioninx-valuepart1 = s_te_mvkex.

APPEND s_extensioninx TO t_extensioninx.
CLEAR s_extensioninx.


CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = headdata
clientdata = clientdata
clientdatax = clientdatax
plantdata = plantdata
plantdatax = plantdatax
forecastparameters = forecastparameters
forecastparametersx = forecastparametersx
planningdata = planningdata
planningdatax = planningdatax
storagelocationdata = storagelocationdata
storagelocationdatax = storagelocationdatax
valuationdata = valuationdata
valuationdatax = valuationdatax
warehousenumberdata = warehousenumberdata
warehousenumberdatax = warehousenumberdatax
salesdata = salesdata
salesdatax = salesdatax
storagetypedata = storagetypedata
storagetypedatax = storagetypedatax
flag_online = ' '
flag_cad_call = ' '
no_dequeue = ' '
no_rollback_work = ' '
IMPORTING
return = return
TABLES
materialdescription = materialdescription
unitsofmeasure = unitsofmeasure
unitsofmeasurex = unitsofmeasurex
* internationalartnos = internationalartnos
materiallongtext = materiallongtext
taxclassifications = taxclassifications
returnmessages = returnmessages
* prtdata = prtdata
* prtdatax = prtdatax
extensionin = t_extensionin
extensioninx = t_extensioninx.


IF return-type EQ 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
APPEND return TO et_return.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

et_return[] = returnmessages[].
ENDIF.

error2.JPG (110.8 kB)
st22.JPG (159.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Jun 28, 2016 at 09:30 AM

    Hi Dear All,

    I find the solution for it:

    Step 1: copy the str and name it 'ZBAPI_TE_MVKE ' same with BAPI_TE_MVKE.

    Step 2: then move the str to extensionin , like as:

    CLEAR s_extensionin.
    CLEAR s_te_mvke.

    s_te_mvke-sales_org = ls_main-vkorg. "
    s_te_mvke-distr_chan = ls_main-vtweg. "
    s_te_mvke-zzxje = ls_main-zzxje.
    s_te_mvke-zzxjesf = ls_main-zzxjesf.

    s_extensionin-structure = 'ZBAPI_TE_MVKE'.

    s_extensionin-valuepart1+0(4) = s_te_mvke-sales_org.
    s_extensionin-valuepart1+4(2) = s_te_mvke-distr_chan.
    s_extensionin-valuepart1+7(12) = s_te_mvke-zzxje.
    s_extensionin-valuepart1+20(12) = s_te_mvke-zzxjesf.

    APPEND s_extensionin TO t_extensionin.
    CLEAR s_extensionin.
    CLEAR s_extensioninx.
    CLEAR s_te_mvkex.

    s_te_mvkex-sales_org = ls_main-vkorg.
    s_te_mvkex-distr_chan = ls_main-vtweg.
    s_te_mvkex-zzxje = 'X'.
    s_te_mvkex-zzxjesf = 'X'.
    s_extensioninx-structure = 'ZBAPI_TE_MVKEX'.

    s_extensioninx-valuepart1 = s_te_mvkex.

    APPEND s_extensioninx TO t_extensioninx.
    CLEAR s_extensioninx.


    Step 3: CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' :

    the parameter extensionin get the value.


    Step4: 'BAPI_MATERIAL_SAVEDATA' : have a enchancement m its name is STANDARDMATERIAL_SAVE_DATA


    Maybe you can refer to the link:

    http://scn.sap.com/community/erp/logistics-mm/blog/2012/03/21/update-custom-fields-in-material-related-tables-ex-mara-marc-mard-using-bapi-bapimaterialsavedata


    then make a enhancement ZSTANDARDMATERIAL_SAVE_DATA then code in IF_EX_STNDRDMATERIAL_SAVE_DATA~MAP_EXTENSIONIN.

    code is :

    METHOD if_ex_stndrdmaterial_save_data~map_extensionin.

    DATA: ls_extensionin LIKE LINE OF extensionin.
    DATA: ls_extensioninx LIKE LINE OF extensioninx.

    DATA: zbapi_te_mvke TYPE zbapi_te_mvke.
    DATA: zbapi_te_mvkex TYPE zbapi_te_mvkex.
    DATA: zbapi_te_marc TYPE zbapi_te_marc.
    DATA: zsmatnr_configurable TYPE zsmatnr_configurable.

    DATA: ls_mvke_ueb LIKE LINE OF mvke_ueb.
    DATA: ls_marc_ueb LIKE LINE OF marc_ueb.
    DATA: ls_mara_ueb LIKE LINE OF mara_ueb.
    DATA: ls_res_fiels LIKE LINE OF res_fields.

    FIELD-SYMBOLS: <fs_mvke_ueb> LIKE LINE OF mvke_ueb.
    FIELD-SYMBOLS: <fs_marc_ueb> LIKE LINE OF marc_ueb.
    FIELD-SYMBOLS: <fs_mara_ueb> LIKE LINE OF mara_ueb.


    LOOP AT extensionin INTO ls_extensionin.

    CASE ls_extensionin-structure.
    WHEN 'ZSMATNR_CONFIGURABLE'.

    zsmatnr_configurable-matnr = ls_extensionin-valuepart1+0(18) .
    zsmatnr_configurable-kzkfg = ls_extensionin-valuepart1+19(1). "
    *
    LOOP AT mara_ueb ASSIGNING <fs_mara_ueb> WHERE matnr = zsmatnr_configurable-matnr.
    <fs_mara_ueb>-kzkfg = zsmatnr_configurable-kzkfg.
    ENDLOOP.

    IF zsmatnr_configurable-kzkfg IS INITIAL.
    READ TABLE mara_ueb ASSIGNING <fs_mara_ueb> WITH KEY matnr = zsmatnr_configurable-matnr.
    IF sy-subrc = 0.
    ls_res_fiels-fname = 'MARA-KZKFG'.
    ls_res_fiels-tranc = <fs_mara_ueb>-tranc.
    ls_res_fiels-d_ind = <fs_mara_ueb>-d_ind.

    APPEND ls_res_fiels TO res_fields.
    CLEAR ls_res_fiels.
    ENDIF.
    ENDIF.

    WHEN 'ZBAPI_TE_MARC'.
    LOOP AT extensioninx INTO ls_extensioninx WHERE structure = 'ZBAPI_TE_MARCX'.
    IF ls_extensioninx-valuepart1+4(1) = 'X'.

    zbapi_te_marc-plant = ls_extensionin-valuepart1+0(4). "plant + zxmzzm
    zbapi_te_marc-zxmzzm = ls_extensionin-valuepart1+4(6). "plant + zxmzzm

    READ TABLE marc_ueb ASSIGNING <fs_marc_ueb> WITH KEY werks = zbapi_te_marc-plant.

    IF sy-subrc = 0.
    <fs_marc_ueb>-zxmzzm = zbapi_te_marc-zxmzzm.
    ENDIF.

    IF <fs_marc_ueb>-zxmzzm IS INITIAL.
    ls_res_fiels-fname = 'MARC-ZXMZZM'.
    ls_res_fiels-tranc = <fs_marc_ueb>-tranc.
    ls_res_fiels-d_ind = <fs_marc_ueb>-d_ind.

    APPEND ls_res_fiels TO res_fields.
    CLEAR ls_res_fiels.
    ENDIF.
    ENDIF.

    ENDLOOP.

    WHEN 'ZBAPI_TE_MVKE'.

    zbapi_te_mvke-sales_org = ls_extensionin-valuepart1+0(4).
    zbapi_te_mvke-distr_chan = ls_extensionin-valuepart1+4(2).
    zbapi_te_mvke-zzxje = ls_extensionin-valuepart1+7(12).
    zbapi_te_mvke-zzxjesf = ls_extensionin-valuepart1+20(12).

    ls_mvke_ueb-vkorg = zbapi_te_mvke-sales_org. "
    ls_mvke_ueb-vtweg = zbapi_te_mvke-distr_chan. "
    ls_mvke_ueb-zzxje = zbapi_te_mvke-zzxje.
    ls_mvke_ueb-zzxjesf = zbapi_te_mvke-zzxjesf.
    *
    LOOP AT extensioninx INTO ls_extensioninx WHERE structure = 'ZBAPI_TE_MVKEX'.
    zbapi_te_mvkex-sales_org = ls_extensioninx-valuepart1+0(4).
    zbapi_te_mvkex-distr_chan = ls_extensioninx-valuepart1+4(2).
    zbapi_te_mvkex-zzxje = ls_extensioninx-valuepart1+6(1).
    zbapi_te_mvkex-zzxjesf = ls_extensioninx-valuepart1+7(1).

    IF zbapi_te_mvkex-zzxje = 'X'.
    READ TABLE mvke_ueb ASSIGNING <fs_mvke_ueb> WITH KEY vkorg = ls_mvke_ueb-vkorg
    vtweg = ls_mvke_ueb-vtweg.
    IF sy-subrc = 0.
    <fs_mvke_ueb>-zzxje = ls_mvke_ueb-zzxje.

    IF <fs_mvke_ueb>-zzxje IS INITIAL.
    ls_res_fiels-fname = 'MVKE-ZZXJE'.
    ls_res_fiels-tranc = <fs_mvke_ueb>-tranc.
    ls_res_fiels-d_ind = <fs_mvke_ueb>-d_ind.

    APPEND ls_res_fiels TO res_fields.
    CLEAR ls_res_fiels.
    ENDIF.
    ENDIF.
    ENDIF.

    IF zbapi_te_mvkex-zzxjesf = 'X'.
    READ TABLE mvke_ueb ASSIGNING <fs_mvke_ueb> WITH KEY vkorg = ls_mvke_ueb-vkorg
    vtweg = ls_mvke_ueb-vtweg.
    IF sy-subrc = 0.
    <fs_mvke_ueb>-zzxjesf = ls_mvke_ueb-zzxjesf.

    IF <fs_mvke_ueb>-zzxjesf IS INITIAL.
    ls_res_fiels-fname = 'MVKE-ZZXJESF'.
    ls_res_fiels-tranc = <fs_mvke_ueb>-tranc.
    ls_res_fiels-d_ind = <fs_mvke_ueb>-d_ind.

    APPEND ls_res_fiels TO res_fields.
    CLEAR ls_res_fiels.
    ENDIF.

    ENDIF.
    ENDIF.
    ENDLOOP.
    WHEN OTHERS.
    .....
    ENDCASE.
    ENDLOOP.
    ENDMETHOD.


    Above,


    Thanks All.

    Add a comment
    10|10000 characters needed characters exceeded

    • Thanks for the feedback. BUT you should really do things as told by SAP (i.e. EXTENSIONIN table field as characters). My experience with SAP is that we may not benefit of some future features, and worse, SAP may develop code which is not compatible with our non-supported code.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2016 at 10:57 AM

    Hi,

    This is not the way to move extensionin Structure. PFA and follow the process.


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 13, 2016 at 07:03 PM

    I don't remember where it's said exactly, but you must always use character-like fields (C, D, T, N) with fields which are handled with BAPIs with EXTENSIONIN/OUT parameter.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 15, 2016 at 10:04 AM

    Kindly refer to the FM documentation for the EXTENSIONIN parameters. It says clearly that the fields in the BAPI append structure can only be of Character type.

    The structures BAPI_TE_<NAME> (<NAME> = MARA, MARC, MARD, MBEW, MLGN, MLGT, MVKE) and the relevant checkbox structures BAPI_TE_<NAME> (<NAME> = MARAX, etc.) must first be extended by the customer to include the fields required. The standard structures contain only the corresponding key fields. When including new fields in these structures, make sure that the field has the same name as the field in the database table. In addition, the fields in the structures BAPI_TE_<NAME> may only be of the type CHARACTER. The data element BAPIUPDATE must be used for the fields in the checkbox structure (except for key fields).

    Thanks,

    Richa

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 20, 2016 at 11:36 AM

    First, as already written, read documentation on the parameter for restrictions on data types allowed.

    In addition, the fields in the structures BAPI_TE_<NAME> may only be of the type CHARACTER

    Then even with characters fields, in an Unicode system, you are not allowed to move such structure to a flat character field as BAPIPAREX-VALUEPART* fields. Hopefully, SAP provided some class methods for this, look for CL_ABAP_CONTAINER_UTILITIES and methods like FILL_CONTAINER_C (SAP will use the READ_CONTAINER_C)

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.