08-11-2015 10:56 AM
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?
08-11-2015 3:01 PM
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.
08-11-2015 10:59 AM
Hi,
Can you share your code!!
U can update it_mseg through workarea.
Regards,
Srini.
08-11-2015 11:03 AM
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.
08-11-2015 11:11 AM
Hi,
Hope you are written logic in POST_DOCUMENT method which having the MSEG & MKPF table data!!
COMMITWORK.
Regards,
Srini.
08-11-2015 11:15 AM
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.
08-11-2015 1:09 PM
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.
08-11-2015 1:31 PM
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.
08-11-2015 1:59 PM
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.
08-11-2015 2:19 PM
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?
08-11-2015 2:26 PM
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.
08-11-2015 2:33 PM
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.
08-11-2015 2:39 PM
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:
V.
08-11-2015 2:45 PM
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.
08-11-2015 2:49 PM
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.
08-11-2015 2:54 PM
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.
08-11-2015 3:05 PM
There you go. It might be worth the time to look at what Jurgen has mentioned below.
V.
08-11-2015 3:01 PM
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.
08-11-2015 3:04 PM
Hi Jurgen,
This is for Movement type 201.
Actually the requirement is to get the equipment number when the document is posted.
08-11-2015 3:06 PM
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.
08-11-2015 4:59 PM
Please have a look into KBA 1920081 - Equipment number is not updated in material document table MSEG