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: 

MB_MIGO_BADI Append field value in IT_MSEG

Former Member
0 Kudos

Hello,

I am using the BAdi MB_MIGO_BADI. In which I am getting a field value Equipment Number.

My query is I am getting the value of this field on screen but if I save the document the equipment number is not updated in the MSEG table.

I am not able to update the IT_MSEG table. Any one knows how to do this?

1 ACCEPTED SOLUTION

JL23
Active Contributor
0 Kudos

What do you actually like to achieve from a process point of view?

What movement type do you execute?

From your code I see that it is probably a goods issue  against a reservation.

But you either have stock or you have equipment.

The field in the BAPI structure is probably used for receipts.

19 REPLIES 19

former_member620069
Participant
0 Kudos

Hi,

Can you share your code!!

U can update it_mseg through workarea.

Regards,

Srini.

0 Kudos

Hello Srini,

I tried the same. But I am getting an error saying that I can not modify this structure. Which is been used by the BADI itself.

Actually in LINE_MODIFY i have got the value. Now I am exporting the value to POST_DOCUMENT method. There I am importing the same value. But in this case also I am not getting the exported value. When I debugged the code, I cam to know that IT_MSEG is the table which is updated at runtime.

If i insert my value in EQUNR field than I think the issue will be solved. But I am not able to do so.

0 Kudos

Hi,

Hope you are written logic in POST_DOCUMENT method which having the MSEG & MKPF table data!!

COMMITWORK.

Regards,

Srini.

0 Kudos

See this is my logic.

But if we are using BADI then I dont think Commit Work should be used. Still I am adding this to my code. Please check the below code.


FIELD-SYMBOLS : <fs_grn_equip> TYPE godynpro-action.
     FIELD-SYMBOLS : <fs_grn1_equip> TYPE godynpro-refdoc.
     CONSTANTS : cs_1000 TYPE mseg-bukrs VALUE '1000' ,
       cs_a07  TYPE godynpro-action VALUE 'A07' ,"TYPE mseg-rsnum VALUE 'A07',
       cs_r09  TYPE godynpro-action VALUE 'R09' .
     READ TABLE it_mseg INTO wa_mseg INDEX 1.
     ASSIGN ('(SAPLMIGO)GODYNPRO-ACTION') TO <fs_grn_equip>.
     ASSIGN ('(SAPLMIGO)GODYNPRO-REFDOC') TO <fs_grn1_equip>.
     DATA : lv_equnr TYPE mseg-equnr.
     IF wa_mseg-bukrs = cs_1000.
       IF <fs_grn_equip> EQ cs_a07 AND <fs_grn1_equip> EQ cs_r09. "AND cs_goitem-xchpf = 'X'..
         SELECT SINGLE equnr
           FROM zpm_resno
           INTO  lv_equnr
           WHERE werks = wa_mseg-werks AND
                 rsnum = wa_mseg-rsnum.
         IF sy-subrc = 0.
*          wa_mseg-equnr = lv_equnr.
*          IMPORT wa_mseg-equnr TO wa_mseg-equnr FROM MEMORY ID 'EQN'.
           IMPORT  cs_goitem-equnr TO wa_mseg-equnr FROM MEMORY ID 'EQN'.
           IF sy-subrc = 0.
             MODIFY TABLE it_mseg FROM wa_mseg.
           ENDIF.
         ENDIF.
       ENDIF.
     ENDIF.

0 Kudos

Yash, Which method within the badi are you using to perform your update?

The method post_document should not be used. The tables IT_MSEG/IS_MKPF are not changing parameters but defined as Importing parameters. This means SAP does not allow you to change any values in these tables.

Did you try using the method LINE_MODIFY? The parameter CS_GOITEM is defined as changing and this structure has the field "equnr".

Also, you should not write COMMIT inside this badi.

V.

0 Kudos

Thanks Vikram for the input.

I am using LINE_MODIFY method for getting the equnr and I am getting the value also in variable and also in the MIGO screen field. But the issue is when I save the document I am not getting that equnr value against the document.

I am not using Commit in this badi.

0 Kudos

Is this during a GR creation via MIGO?

What exactly do you mean by you are getting the value on the screen but not updated to the table? IS this value entered by the user on the screen?

I also see that you get the value for the field from a Z table. Then what is that you are importing and where did you export that from?

V.

0 Kudos

Yes this is during GR creation via MIGO in Reservation(R09).

I am getting the value through LINE_MODIFY.  Yes I am getting the value from Z table. But that is not the issue. I debugged and found that the EQUNR field is not available in the work area which is passed in IT_MSEG. So what is the alternative of this?

0 Kudos

I am confused.

If you are using line_modify where are you modifying it_mseg? it_mseg is not a part of line_modify but is only a parameter of the method post_document.

The field EQUNR  is available on both line_modify and post_document although you cannot change this field in post_document but can be changed in line_modify.


When you get the field EQUNR  from your Z table in line modify, update the structure GOITEM-EQUNR. When you do this you should see the change reflected.


V.

0 Kudos

See this is the code.

IF cs_goitem-bukrs = cs_1000.
     IF <fs_grn_equip> EQ cs_a07 AND <fs_grn1_equip> EQ cs_r09. "AND cs_goitem-xchpf = 'X'..
       SELECT SINGLE equnr
         FROM zpm_resno
         INTO lv_equnr
         WHERE werks = cs_goitem-werks AND
               rsnum = cs_goitem-rsnum.
       IF sy-subrc = 0.
         cs_goitem-equnr = lv_equnr.
       ENDIF.
     ENDIF.
   ENDIF.


I have passed the EQUNR in cs_goitem-equnr. But after doing this I am not getting the value in posted document.

0 Kudos

Yash,

Is the the field EQUNR open to editing via MIGO?

Are you using the transaction MIGO or something else like MB01?


From SAPs documentation:


  • The BAdI MB_MIGO_BADI is only active in transaction MIGO.
  • Changed data in GOITEM is only adopted if the relevant fields are visible and ready for input.
  • Changed data in GOITEM is not adopted if the relevant field is not used in any MIGO screen (warning via MIGO 049).
  • Changed data in GOITEM is not adopted if the relevant fields are not ready for input (warning via MIGO 050)

V.

0 Kudos

I am using the Tcode MIGO.

Also the field is there in the ITEM LEVEL of MIGO screen in the Material tab.

Yes the field is open for editing. But dont know the value is not reflecting in the table. The docuement is posted but the value is not there against this docuement.

0 Kudos

Yash,

Did you try to update the value from the screen instead of using the BADI and see if its getting updated?

If the above process works then you need to debug further after the badi is executed and see if SAP is changing the value after your update. The first step here is to check if the value is update correctly immediately after you come out of the badi. If its updated correctly, then create a watch point and see where the same is getting changed.

V.

0 Kudos

Yes you are true buddy.

I tried the same thing, running the transaction directly from MIGO and inserted the EQUNR and saved the document. But the posted document also is not having the equipment number(EQUNR) against it. So i have to put a watch point then. And see where it is changing the value.

0 Kudos

There you go. It might be worth the time to look at what Jurgen has mentioned below.

V.

JL23
Active Contributor
0 Kudos

What do you actually like to achieve from a process point of view?

What movement type do you execute?

From your code I see that it is probably a goods issue  against a reservation.

But you either have stock or you have equipment.

The field in the BAPI structure is probably used for receipts.

Former Member
0 Kudos

Hi Jurgen,

This is for Movement type 201.

Actually the requirement is to get the equipment number when the document is posted.

Former Member
0 Kudos

And I am getting the equipment number from Z table. Passing WERKS and RSNUM in the Z table and getting the EQUNR from it. And displaying the same on screen.

JL23
Active Contributor