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: 

Update custom fields in MARC - BAPI_MATERIAL_SAVEDATA

Former Member
0 Kudos
4,670

Hi Gurus,

I did find many good replies on the similar thread but didn't work for me. Hope you could help.

Req: -

Add a custom checkbox on a customer subscreen and update the same in a program via BAPI

Problem:

Screen enhanced. If the value is added manually and saved, it gets updated in MARC and works well.

Now when i add the same value through program using BAPI_MATERIAL_SAVEDATA, the value is not getting updated in database (and obviously is not present on screen as well).

Solution already implemented: -

structures BAPI_TE_MARC and BAPI_TE_MARCX is updated with custom field.

In tcode OMSR a new sel grp 111 is created for custom field of MARC and following values are passed:

I have also tried with value of maintenance status - KDEVALBQPSZXCFG (though didn't understand the difference).

in debugging checked at various places (following places for your convenience of reference): -

BADI implementation of STANDARDMATERIAL_SAVE_DATA.

BADI implementation of badi_material_check

Implementation of customer exit: EXIT_SAPLMGMU_001

at the end of execution of FM "MATERIAL_MAINTAIN_DARK"

at all the places value of custom field was present correctly.

BAPI_TRANSACTION_COMMIT also done.

So at the end of the BAPI I get a success message though the success of updating the field is not achieved.

I believe, there is not much to do on technical front here (i could be wrong), possibly some customizing mistake or miss.

Would really appreciate if you could help on this.

Thanks in advance.

Cheers,

Shreya

1 ACCEPTED SOLUTION

Former Member
0 Kudos
2,367

Hi all,

the issue is solved. There is one catch. While using bapi we are passing header data where we are passing material number and any view.

it is mandatory to pass any standard field of that view in the Bapi alongwith extension field. Only passing extension field doesn't work.

Hope it helps.

Thanks,

Cheers,

Shreya

Editing this message to clarify one thing: -

If you keep the same data as in database in the standard field, it won't work. You have to change the data. So, we have to use the BAPI twice:

First make the unintended change to standard field to achieve update of custom field in extension.

Secondly again remove the unintended change from standard field and make it as previous value.

I am genuinely not convinced with this solution. SAP cannot have such glitch, I must be missing something, But for the time being I am using this. If you have any pointers on this, highly appreciated.

I would also look for the same and will post If I suceed.

Cheers,

Shreya

Message was edited by: shreya tagra

6 REPLIES 6

Former Member
0 Kudos
2,367

Hi Shreya,

Check on these structures :

EXTENSIONIN

EXTENSIONINX


I hope you have extended the structures BAPI_TE_MARC and BAPI_TE_MARCX with the field which is having same name as in your database table MARC.


Have you used data element BAPIUPDATE for your field in BAPI_TE_MARCX.


Also check , if you have passed 'BAPI_TE_MARC' in extensionin-structure  and extensioninx-structure field.


Also check if you have set indicator as 'X' in EXTENSIONINX and passed plant in BAPI_TE_MARC and BAPI_TE_MARCX.


Thanks,

Chirdip


0 Kudos
2,367

Hi Chirdip,

Thanks for your reply.

Yes, I did all the above mentioned things. Any more pointers would be highly appreciated.

Thanks,

Cheers,

Shreya

Former Member
0 Kudos
2,368

Hi all,

the issue is solved. There is one catch. While using bapi we are passing header data where we are passing material number and any view.

it is mandatory to pass any standard field of that view in the Bapi alongwith extension field. Only passing extension field doesn't work.

Hope it helps.

Thanks,

Cheers,

Shreya

Editing this message to clarify one thing: -

If you keep the same data as in database in the standard field, it won't work. You have to change the data. So, we have to use the BAPI twice:

First make the unintended change to standard field to achieve update of custom field in extension.

Secondly again remove the unintended change from standard field and make it as previous value.

I am genuinely not convinced with this solution. SAP cannot have such glitch, I must be missing something, But for the time being I am using this. If you have any pointers on this, highly appreciated.

I would also look for the same and will post If I suceed.

Cheers,

Shreya

Message was edited by: shreya tagra

0 Kudos
2,367

I read some more posts and they referred settings of MAL1 and MAL2...

In my case, I have set MAL1 and MAL2 wih Optional Entry radiobutton. I hope it is correct.

I see many posts where only custom fields is also maintainable which is not the case for my issue.

Could you please check in my descriptions above as in what i am missing ?

We cannot go with the option of forcibly updating a standard field to change a custom field.... makes no sense actually 😐

Your inputs are highly appreciated.

Thanks in advance.

Cheers,

Shreya

0 Kudos
2,367

Okay so finally found the Solution:-

Select any view in Header ... eg: Purchasing View

so now header structure has 2 values: material number and an "X" in Purchase View.

In PLANTDATA: pass plant value (key field!) and space in Purchase Org or any other char field

In PLANTDATAX: pass plant value (key field!) and DO NOT pass "X" in any of the field

In Extensionin pass:

BAPI_TE_MARC in structure and in valuepart1 pass <plant><value>

in extensioninx pass:

BAPI_TE_MARCX in structure and in valuepart1 pass <plant>X.

Execute and Commit.

It works!! yes it does update the custom field now without updating the standard field Purchasing Org..

SIGH!!

Hope this would be helpful for someone here.

Cheers,

Shreya

dang_thanhdung
Explorer
0 Kudos
1,704

Hi,

I have the same problem and resolved it. We also need to maintain the added field in OMSR tcode or t130f table (SM30).2024-08-20_15-52-21.png