Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_MATERIAL_SAVEDATA

Former Member
0 Likes
1,587

Hi all! I'm trying to update the product version on Cost View 1, field PLANTDATA-PRODVERSCS (MARC-FVIDK)

I'm filling the PLANTDATA and PLANTDATAX structures, and HEADDATA-COST_VIEW = 'X', along with the necessary material data, and the transaction commit after the bapi call, but the field is not getting updated.

I don't know if there's something else I should be passing to the BAPI, any other value

required to update this value.

headdata-material = 'B3731'.

headdata-matl_type = 'ZSEM'.

headdata-ind_sector = '0'.

headdata-cost_view = 'X'.

plantdata-plant = 'IN55'.

plantdata-prodverscs = '1C'.

plantdatax-plant = 'IN55'.

plantdatax-prodverscs = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = headdata

plantdata = plantdata

plantdatax = plantdatax

IMPORTING

return = return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

I appreciate any help, this is a bit urgent!!

Thanx

Jesus.

10 REPLIES 10
Read only

Former Member
0 Likes
1,314

Hai Check the following Code

types : begin of ty_main,

matnr type bapimathead-material,

mbrsh type bapimathead-ind_sector,

mtart type bapimathead-matl_type,

matkl type bapi_mara-matl_group,

meins type bapi_mara-base_uom,

spras type bapi_makt-langu,

maktx type bapi_makt-matl_desc,

end of ty_main,

begin of ty_mathead,

matnr type bapimathead-material,

mbrsh type bapimathead-ind_sector,

mtart type bapimathead-matl_type,

end of ty_mathead,

begin of ty_client,

matkl type bapi_mara-matl_group,

meins type bapi_mara-base_uom,

end of ty_client,

begin of ty_clientx,

matkl,

meins,

end of ty_clientx,

begin of ty_makt,

spras type bapi_makt-langu,

maktx type bapi_makt-matl_desc,

end of ty_makt,

begin of ty_error,

matnr type bapimathead-material,

mesg type bapiret2-message,

end of ty_error.

data : it_main type standard table of ty_main with header line,

it_makt type standard table of ty_makt with header line,

it_error type standard table of ty_error with header line,

it_mathead type ty_mathead,

it_client type ty_client,

it_clientx type ty_clientx,

it_return type bapiret2.

selection-screen begin of block b1.

parameter : p_file type rlgrap-filename obligatory.

selection-screen end of block b1.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

importing

file_name = p_file.

start-of-selection.

perform get_bapi.

&----


*& Form get_bapi

&----


  • text

----


form get_bapi .

data lv_infile type string.

lv_infile = p_file.

call function 'GUI_UPLOAD'

exporting

filename = lv_infile

filetype = 'ASC'

has_field_separator = 'X'

tables

data_tab = it_main

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

others = 17

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

loop at it_main.

it_mathead-matnr = it_main-matnr.

it_mathead-mbrsh = it_main-mbrsh.

it_mathead-mtart = it_main-mtart.

it_client-matkl = it_main-matkl.

it_client-meins = it_main-meins.

it_clientx-matkl = 'X'.

it_clientx-meins = 'X'.

it_makt-spras = it_main-spras.

it_makt-maktx = it_main-maktx.

append it_makt.

clear it_makt.

call function 'BAPI_MATERIAL_SAVEDATA'

exporting

headdata = it_mathead

clientdata = it_client

clientdatax = it_clientx

importing

return = it_return

tables

materialdescription = it_makt.

clear : it_main,it_mathead,it_client,it_clientx,it_return.

refresh it_makt.

endloop.

endif.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

endform. " get_bapi

Regards

Sreeni

Read only

0 Likes
1,314

Hi Sreeni, thanx for your reply!!

however, the field I'm trying to update is not on your program. I've used this BAPI to update other fields and it works just fine, only with the product version is that I'm having problems.

Thanx

Jesus

Read only

0 Likes
1,314

Can you update this field manually using MM02 for this material? It is greyed out in my system.

Regards,

Rich Heilman

Read only

0 Likes
1,314

Hi Rich!

Yes, for the material I'm testing is enabled, I even try changing it manually on MM02 to check that the value I'm sending is valid, and it updated it with no problems.

Thanx

Jesus

Read only

Former Member
0 Likes
1,314

Hi,

Check the return parameter..

What is the error message you are getting in the return parameter..

Check the sample code..

parameters: p_matnr type matnr.

parameters: p_werks type werks_d.

data: return type bapiret2.

data: headdata type BAPIMATHEAD.

data: plantdata type bapi_marc.

data: plantdatax type bapi_marcx.

headdata-material = p_matnr.

headdata-cost_view = 'X'.

plantdata-plant = p_werks.

plantdata-prodverscs = '1C'.

plantdatax-plant = p_werks.

plantdatax-prodverscs = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = headdata

plantdata = plantdata

plantdatax = plantdatax

IMPORTING

return = return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

Thanks

Naren

Read only

0 Likes
1,314

Hi Narendran!

On the return IMPORTING parameter, it says:

"The material B3731 has been created or extended"

But, on the return TABLE, it says:

"The material cannot be maintained since no maintainable data transferred"

I don't know why this is happening!

Thanx

Jesus

Read only

ferry_lianto
Active Contributor
0 Likes
1,314

Hi,

Please try transaction MASS with object type BUS1001.

Next step, select table MARC and fields MARC-FVIDK then click on execute button. Enter your material and plant and click on execute for update process.

Hope this will help.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,314

Hi,

Did you check the value in the table MARC-FVIDK??

Is not getting updated eventhough it says it is updated..

Thanks,

Naren

Read only

0 Likes
1,314

Hi Narendra... I've checked the value and it's not getting updated on MARC table

Thanx

Jesus

Read only

Former Member
0 Likes
1,314

Hi,

I am not sure why you were not able to modify the data using BAPI..Eventhough you were able to manually change in MM02...

Try changing a different material..

Thanks,

Naren