Application Development 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: 

Adding custom fields to BAPI_MATERIAL_SAVEDATA

Former Member
0 Kudos

With the DFPS module, SAP has added the NSNID field to the MARA table.

However, BAPI_MATERIAL_SAVEDATA makes use of structure BAPI_MARA, which does not have the same field included.

When consulting SAP about this difference, we get the answer that we can use the EXTENSIONIN tables in the BAPI to add this field. Not the best solution ever, but if it works, it works.

So I've appended our field NSNID to the BAPI_TE_MARA and BAPI_TE_MARAX structures (one with the actual type and another with the default bapiupdate type). Next I add those to the EXTENSIONIN and EXTENSIONINX tables, all exactly as shown by SAP.

When the BAPI is called, I see that the values from those tables are copied to the internal table tmara_ueb. However, no actual update takes place.

As a check, I've also added a regular MARA field to the BAPI... it gets updated without a problem. So the BAPI itself works, just not with semi-custom fields. Semi-custom because the field in the MARA is standard SAP, but we have to manually add it here.

What I've found so far is that the name of the field is of no influence (also added ZZTEST, no update either). In various posts I read about table T130F in which the field also has to be declared. The NSNID is already in there, the addition of ZZTEST does not help either.

Is there something abvious I'm missing here? Thanks in advance for the help!

1 ACCEPTED SOLUTION

0 Kudos

Hi,

if the values are available in table TMARA_UEB for the call of function module MATERIAL_MAINTAIN_DARK, then obviously is the new data from the BAPI not merged into the database values. This can be due to the following reasons:

-> The field selection for the BAPI processing sets the field to write protected. As the field can be maintained due to your descriptions in transaction MM02, such an unexpected result in the BAPI case can be only due to the field references MAL1 and MAL2. Can you please check using customizing transaction OMSR, that the field selection settings for field MARA-NSNID don't set these fields to display only or hidden?

-> If the issue is not caused by the field selection settings, then please check which views did you mark for processing in the headdata structure for your BAPI call. The fields is assigned to any possible maintenance status of the material, so this can be only the reason if you didn't mark any view.

regards

Carsten

11 REPLIES 11

Former Member
0 Kudos

Hi,

As you said , you have added NSNID field BAPI_TE_MARA and BAPI_TE_MARAX but have you populated this through your code.you must decalre these structures in your code and then have to popultate your extension structures.

If this doesnt work i would suggest BDC could be a feasible option..

Regards,

Mayank

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

First of all , i assume you are passing 'X' to the EXTENSIONINX structures

We also faced similar issues while updating one custom field. I searched a lil' bit on Google & SCN and general idea was in order to make the EXTENSIONIN param to update the fields the field needs to be present on the screen.

I understand that SAP has added NSNID as part of the DFPS module, i hope that the field is available on MM* trxn. Check if the field is active.

BR,

Suhas

Former Member
0 Kudos

Thanks for the replies Mayank and Suhas. To answer to both:

@Mayank:

Yes, both structures are declared in the code and filled. Afterwards, I assign 'BAPI_TE_MARA' to the structure part of the EXTENSIONIN and fill the valuepart1 field with the values from the declared BAPI_TE_MARA structure. That system works as it should, the values are correctly copied to the internal tmara_ueb table.

* Check field to see if there was a MARA change
ls_clientdata-document  = 'TEST6'.
ls_clientdatax-document = 'X'.

* The added field we want to change
ls_bapi_te_mara-material = ls_headdata-material.
ls_bapi_te_mara-nsnid    = '222222222'.

ls_bapi_te_marax-material = ls_headdata-material.
ls_bapi_te_marax-nsnid = 'X'.

ls_extensionin-structure = 'BAPI_TE_MARA'.
PERFORM transfer_to_extensionin USING ls_bapi_te_mara CHANGING ls_extensionin.
APPEND ls_extensionin TO lt_extensionin.

ls_extensioninx-structure = 'BAPI_TE_MARAX'.
PERFORM transfer_to_extensionin USING ls_bapi_te_marax CHANGING ls_extensioninx.
APPEND ls_extensioninx TO lt_extensioninx.

<execute BAPI>

FORM transfer_to_extensionin USING    is_bapi_extensionin TYPE any
                             CHANGING cs_bapiparex        TYPE bapiparex.

  DATA l_distance_characters TYPE i.

  FIELD-SYMBOLS <any> TYPE any.

  DESCRIBE DISTANCE BETWEEN cs_bapiparex-structure
            AND cs_bapiparex-valuepart1
            INTO l_distance_characters
            IN CHARACTER MODE.

  ASSIGN cs_bapiparex+l_distance_characters(*) TO <any>
    CASTING LIKE is_bapi_extensionin.

  <any> = is_bapi_extensionin.

ENDFORM.                    "transfer_to_extensionin

BDC is the very very very last thing I want to think about here... even more since - in my opinion - SAP should have updated the BAPI_MARA structure and working of the BAPI to accomodate the addition of the NSNID field.

@Suhas:

Yup, except for the material number field of course, that's the actual number as key.

The NSNID field is already available on screen, on the 'Basic Data 2' tab. So that shouldn't be a problem.

0 Kudos

The BAPI internally calls 'MATERIAL_MAINTAIN_DARK'. Did you check the table TMARA_UEB is populated correctly with NSNID field ?

BR,

Suhas

Former Member
0 Kudos

I've mentioned the tmara_ueb table in both of my posts... yes, the values are copied correctly.

Further in the process, FM's MARA_ARRAY_READ and MARA_CHANGE_CHECK are called. The first collects the current MARA data from the database. Curiously it puts the data in both internal structures imara as tmara.

In the second FM, those two structures are compared to determine whether there were changes in the material. This seems like a waste of time, since both are equal. I would've expected a comparison with the tmara_ueb somewhere in the process.

If I change the value of the NSNID field in the tmara structure and F8 the whole process, the field gets updated. Somehow the value from the EXTENSIONIN doesn't get transferred to the tmara structure.

0 Kudos

Hi,

if the values are available in table TMARA_UEB for the call of function module MATERIAL_MAINTAIN_DARK, then obviously is the new data from the BAPI not merged into the database values. This can be due to the following reasons:

-> The field selection for the BAPI processing sets the field to write protected. As the field can be maintained due to your descriptions in transaction MM02, such an unexpected result in the BAPI case can be only due to the field references MAL1 and MAL2. Can you please check using customizing transaction OMSR, that the field selection settings for field MARA-NSNID don't set these fields to display only or hidden?

-> If the issue is not caused by the field selection settings, then please check which views did you mark for processing in the headdata structure for your BAPI call. The fields is assigned to any possible maintenance status of the material, so this can be only the reason if you didn't mark any view.

regards

Carsten

0 Kudos

Hello Carsten,

Thanks for your post. I agree FC should maintain these settings but doesn't hurt to know these details.

You just made my day !!

Cheers,

Suhas

0 Kudos

Any idea how did you fix this issue.

I have added one field in MARA table but not getting updated when i use SAVE_REPLICA BAPI.

Same issue it is not getting custom field values in TMARA_UEB table.

looks you solved for your - please help appreciate !

Thanks,

Mahesh.

Former Member
0 Kudos

Hoorah, problem resolved!

In our case it was the MAL1 and MAL2 setting that prevented the update. With those two fields adjusted, the code works as expected and updates the NSNID value.

0 Kudos

Hi Venema,

Good Day..!!

Currently I am working on a report where I need to update MARA-NSNID using the FM 'BAPI_MATERIAL_SAVEDATA'. I have the similar issue as you have explained in this post. I have gone through the post and understood the problem.

Could you please let me know the code that you have used to populate the structures EXTENSIONIN and EXTENSIONINX in order to update the MARA table. Thanks in advance,

Thanks & Regards,

Paddu.

0 Kudos

Hi, could you please learn me how to solve the problem?

Very special Thx.

Giampy