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: 

Need to update PO header custom fields after PO number generate

former_member459142
Participant
0 Kudos

Hi experts,

I need to update PO header custom fields after PO number generation, Intitially i tried in Exit EXIT_SAPMM06E_012 beacuse this exit have Changing parameter for custom fields but no PO number coming and i  also tried  BADi ME_PROCESS_PO_CUST in POST method but here i am not able to set Header data.

My requirement is need to update custom fields after PO number generation while saving PO.

Thanks

Prashant

1 ACCEPTED SOLUTION

Former Member

Dear Prashant,

BADI ME_PROCESS_PO_CUST is the right place.

You do  not see the changing parameter up front, but you need to READ DATA, populate your custom fields and SET DATA. See the screenshot below for a working code.

Regards,

Raju.

13 REPLIES 13

former_member217316
Contributor
0 Kudos

If you say, ME_PROCESS_PO_CUST didn't help, check for ME_PURCHDOC_POSTED or M06E0004/5.

0 Kudos

Hi Harsh,

Thanks for beply but i have checkd enahcemnet M06E0004 but still not getting PO number here and no custom fields. Badi ME_PURCHDOC_POSTED does not have any changing parameter so didnt work for me.

Former Member

Dear Prashant,

BADI ME_PROCESS_PO_CUST is the right place.

You do  not see the changing parameter up front, but you need to READ DATA, populate your custom fields and SET DATA. See the screenshot below for a working code.

Regards,

Raju.

0 Kudos


Hi Raju,

You are correct but i need PO number as well but In badi ME_PROCESS_PO_CUST i checked in

Process_header PO number is not coming, its coming only in Post method but i was trying to set data but it was not heppening.

Hi Prashant,

If you need PO number and need to program in POST METHOD. Then follow the below trick.

Data cl_po type ref to cl_po_header_handle_mm.

DATA: ls_mepoheader TYPE mepoheader.

ls_mepoheader = im_header->get_data( ).


* ls_mepoheader-zzfield = 'sapyard'.

        cl_po ?= im_header.

         cl_po->my_ibs_firewall_on = 'X'.       " You can comment this

         clear : cl_po->my_cust_firewall_on . " You can comment this

         cl_po->set_data( EXPORTING im_data = ls_mepoheader ).

         CALL FUNCTION 'MEPOBADI_PROCESS_HEADER'

           EXPORTING

             im_header = cl_po.


Let me know if it works..


Regards,

Raju.

0 Kudos

Hi Raju,

I tried your way but unfortunatly still data is not saving.

Thanks

Prashant

0 Kudos

Hi Prashant,

Did you get any syntax error? Or were you able to use the above snippet but your data did not get saved as expected?

Can you please paste the code which you have written in POST Method.

It is working for me in our project.

Regards,

Raju.

Juwin
Active Contributor
0 Kudos

Does this field have to be a Zfield in the standard table? Can you create a Ztable, with just the PO number and the Virtual credit card number, instead of the append structure to EKKO? It shouldn't make any difference technically, because the records will still have 1:1 cardinality. If yes, you should be able to save to the Ztable directly from POST method, without worrying about setting the data back to EKKO.

Thanks,

Juwin

Former Member
0 Kudos

I don't think you'll find any suitable exit or badi for this.  By the time that the PO number is assigned (assuming internal number range), the standard programs have prepared all the data and performed all the checks and are not going to support any further changes.

It seems funny that you would have data stored in MEPO that depends on knowing the PO number.  Can you explain the business requirement behind this and maybe someone can propose a different design?

Jim

0 Kudos

Hi Jim,

Yes you are correct. in your perception it can be funny but is a requirement, let me explain business reuirement.

I have to implement Virtual credit card system which need to be trigger while posting PO and i have to send PO data to other system along with PO number. Once card will be generated then i will get card details. those details i have to sotred in PO header(EKKO).

Please suggest.

Thanks

Prashant

0 Kudos

Hi Prashant,

So I guess that during Post method you do a syncrhonous call to the other system where you provide the PO number, a card is generated, that card number is returned to you from that synchronous call and you then store that card number in PO header custom field, is that correct?

I just ran through a PO create in debug, and when my POST method implementation is called, the IM_EBELN parameter is filled with the new PO number.  The EKKO record does not yet exist in the database, but the update function module to create it has already been called using IN UPDATE TASK.  So it's too late too change EKKO data at this point.

I think you must create a Z table as suggested by Juwin above with primary key of the EBELN and store the card number in that table.  You can then call your external system function during POST method and pass it the value you receive in IM_EBELN parameter.  When you receive back the card number, create a record in the Z table to store the card number.  Use an update function module to create the Z record so that if the standard PO update fails (ie you see an update error in SM13) then your custom table update also does not occur and you don't leave orphan records in that table.

Jim

former_member185054
Active Participant
0 Kudos

Using bdc will solve this issue.

Sampath

0 Kudos

Hi Prashanth,

The method ME_PROCESS_PO_CUST~CLOSE will be triggered after saving the PO.

By using GET PARAMETER ID you can fetch the created po number .

Please go through below link :-

User exit PO creation | SCN

-Thanks