cancel
Showing results for 
Search instead for 
Did you mean: 

Update Data in MIGO During Save

tinks_mca
Explorer
0 Kudos

Hi all,

While doing MIGO, 101 movement against inbound, I want to update the value of one field.

MKPF-FRBNR

I want to update it while saving the document. I have a custom logic, which will get some value from the Z table. I want to put it in MKPF-FRBNR.

Please let me know if it is possible.

I have tried MB_Document_badi and MB_MIGO_BADI, but no success yet.

Accepted Solutions (0)

Answers (3)

Answers (3)

DominikTylczyn
Active Contributor

Hello tinks.mca

You can't update the content of the internal tables in MB_DOCUMENT_BADI. That's why I suggested direct update of MKPF. However, as you have noticed that will not update purchase history. I'm not quite sure about possible side effects of such an inconsistency.

You might try another approach. Use MB_MIGO_BADI, the LINE_MODIFY method and put the bill of lading in GOITEM-BOLNR_REFDOC. That should be copied to MKPF-FRBNR if you don't put a bill of lading number in the header of the material document - include LMIGOKL4:

* Fill XBLNR and FRBNR in gohead from first item if not manually filled
* Because verur_refdoc and bolnr_refdoc are moved from wueb, they are
* shortened to 16 instead of 35!!
  IF ps_gohead-xblnr_manual = abap_false AND ps_gohead-xblnr IS INITIAL.
    ps_gohead-xblnr = ls_goitem-verur_refdoc.
  ENDIF.
  IF ps_gohead-frbnr_manual = abap_false AND ps_gohead-frbnr IS INITIAL.
    ps_gohead-frbnr = ls_goitem-bolnr_refdoc.
  ENDIF.

Best regards

Dominik Tylczynski

tinks_mca
Explorer
0 Kudos

Hi,

Thanks for your reply. I am trying to implement the solution provided by you. It seems logical, but still I am not able to implement it. When I try to modify the data of GOITEM I get the following error:

BADI: You are not allowed to change the field content of GOITEM-BOLNR_REFDOC

Message no. MIGO049

The contents of field GOITEM-BOLNR_REFDOC have been changed in BAdI MB_MIGO_BADI (method LINE_MODIFY). The changes, however, are only valid for fields that are represented on a screen in transaction MIGO. The other fields of structure LSGOITEM provide internal control. No changes are made to these fields.


Can you please help me with this? I tried to make these fields to ready for the input through configuration, but it is not available.

Really thankfull for your efforts.

tinks_mca
Explorer
0 Kudos

Hi Dominik Tylczynski,

I was trying to implement the solution provided by you, but unfortunately, I did not get success. MB_MIGO_BADI did not allow me to update the contents.

Now I have searched an include, in which implicit enhancement can be done.

Include name is: LMIGOKH1

There are two methods:

METHOD header_modify.
ps_gohead = i_gohead.

ENDMETHOD.


METHOD header_get.

e_gohead = ps_gohead.
ENDMETHOD.


I have done the changes as per my requirement in these methods through implicit enhancement. I just want to know whether it is the right approach or should I search somehting else.

Thanks for your support.

DominikTylczyn
Active Contributor

Hello tinks.mca

I don't think you are going to find a standard enhancement that suits your needs.

I'd suggest using MB_DOCUMENT_BADI, method MB_DOCUMENT_UPDATE. You can update FRBNR directly in the MKPF database table. It's not the prettiest solution, but it's going to work.

Best regards

Dominik Tylczynski

tinks_mca
Explorer

yeah, I can put a direct update.

But this data is also updated in Purchase history table. So my doubt is there may be certain other tables that should also be updated.

I get the data in MB_DOCUMENT_BADI in internal tables. I updated the internal table also with my requirement, but after that, the data gets vanished.

Finally, MB_DOCUMENT_UPDATE is not getting called. I tried it in update debugging also. But no help.

jbuettner
Explorer
0 Kudos

Hello tinks.mca,
you can try Enhancement Spot ES_SAPLMIGO. Maybe one of them fits your needs.


Best regards,
Julian