Skip to Content
0
Former Member
Jul 03, 2007 at 01:51 PM

/AFS/BAPI_MATERIAL_SAVEDATA

64 Views

Hi all,

i'm trying to change several materials' data. in the loop below, for the first item in gt_mara, this function changes data normally. However, beginning from second item on gt_mara, plantdata does not change.

by the way, /AFS/BAPI_MATERIAL_SAVEDATA is almost the same as FM BAPI_MATERIAL_SAVEDATA.

can anyone help me about this situation.

Thanks to all.

here is the part of the code:

LOOP AT gt_mara.

CLEAR : clientdata,

gs_headdata,

clientdatax,

plantdata,

plantdatax,

i_bapiparex,

gt_return,

w_bapi_te_mara,

w_bapiparex.

REFRESH i_bapiparex.

CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'

EXPORTING

material = gt_mara-matnr

plant = s_werks-low

IMPORTING

clientdata = clientdata_r

plantdata = plantdata_r

TABLES

  • extensionout = i_bapiparex

return = gt_return.

MOVE-CORRESPONDING : clientdata_r TO clientdata.

  • plantdata_r TO plantdata.

plantdata-plant = s_werks-low.

w_bapi_te_mara-material = gt_mara-matnr.

IF p_askili EQ 'X'.

w_bapi_te_mara-zzaski = '2'.

w_bapi_te_mara-zzkolisekli = '2'.

w_bapi_te_mara-zzaskiboy = '1'.

plantdata-loadinggrp = '0002'.

ELSE.

w_bapi_te_mara-zzaski = '1'.

w_bapi_te_mara-zzkolisekli = '1'.

w_bapi_te_mara-zzaskiboy = '0'.

plantdata-loadinggrp = '0001'.

ENDIF.

DATA: l_container TYPE me_max_container.

CALL METHOD cl_abap_container_utilities=>fill_container_c

EXPORTING

im_value = w_bapi_te_mara

IMPORTING

ex_container = l_container

EXCEPTIONS

illegal_parameter_type = 1

OTHERS = 2.

w_bapiparex-valuepart1 = l_container.

w_bapiparex-structure = 'BAPI_TE_MARA'.

APPEND w_bapiparex TO i_bapiparex.

  • Extensioninx bilgileri dolduruluyor.

w_bapi_te_marax-material = gt_mara-matnr.

w_bapi_te_marax-zzaski = 'X'.

w_bapi_te_marax-zzkolisekli = 'X'.

w_bapi_te_marax-zzaskiboy = 'X'.

CLEAR w_bapiparex.

w_bapiparex-structure = 'BAPI_TE_MARAX'.

w_bapiparex-valuepart1 = w_bapi_te_marax.

APPEND w_bapiparex TO i_bapiparexx.

REFRESH gt_return. "added eoflaz

gs_headdata-material = gt_mara-matnr.

gs_headdata-matl_type = gt_mara-mtart.

gs_headdata-sales_view = 'X'.

gs_headdata-basic_view = 'X'.

plantdatax-loadinggrp = 'X'.

plantdatax-plant = s_werks-low.

CALL FUNCTION '/AFS/BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = gs_headdata

clientdata = clientdata

clientdatax = clientdatax

plantdata = plantdata

plantdatax = plantdatax

IMPORTING

return = return

TABLES

returnmessages = gt_returnx "added eoflaz

extensionin = i_bapiparex

extensioninx = i_bapiparexx.

MOVE-CORRESPONDING return TO gt_return.

gt_return-matnr = gt_mara-matnr.

APPEND gt_return.

READ TABLE gt_return WITH KEY type = 'E'.

IF sy-subrc EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

ENDLOOP.