cancel
Showing results for 
Search instead for 
Did you mean: 

Change header field of purchase order on save

elko_hasse
Participant
0 Kudos

Hi all,

my requirement is to set PO header field UNSEZ to a specific value when PO is saved.
Sounds easy but even after trying several suggestions from different posts I have no working solution.

I tried BAdI ME_PROCESS_PO_CUST, but Methods PROCESS_HEADER and PROCESS_ITEM are only triggered when a header or item field is manually changed, and that is not always the case in my scenario.

I also tried Methods POST and CHECK, but I am not able to get changes saved on the database.
From different posts I use following code:

data: lr_po_handle type ref to cl_po_header_handle_mm.
data: ls_header type mepoheader.

* Disable firwall
lr_po_handle ?= im_header.
lr_po_handle->my_cust_firewall_on = mmpur_yes.

* Get header data
ls_header = im_header->get_data( ).

* Set value
ls_header-unsez = text-100.

* Set header data
im_header->set_data( ls_header ).
im_header->set_changed( ).

* Enable firewall
lr_po_handle->my_cust_firewall_on = mmpur_no.

This code will change the field UNSEZ on Dynpro, but will not persist change on database.

Are there any solution to this issue. 

Thanks E. Hasse

 

View Entire Topic
raymond_giuseppi
Active Contributor

If you actually want a constant value, try to add your code in methods OPEN to initialize value) and PROCESS_HEADER (cancel user input)

NB: POST method shouldn't change data, CHECK is the last one allowed.

elko_hasse
Participant
0 Kudos
Thanks, but is not a constant value, it should be set before saving.
raymond_giuseppi
Active Contributor
0 Kudos
Then post your actual code in the CHECK method
elko_hasse
Participant
0 Kudos
Thanks, as I stated in my initial post, I already tried my code (see above) in method CHECK, but value is NOT updated in DB table.
raymond_giuseppi
Active Contributor
0 Kudos

Try to prevent infinite loop, change your code to something such as 

 

* Get header data
ls_header = im_header->get_data( ).
* Prevent infinite loop
if ls_header-unsez ne text-100.
* Set value
  ls_header-unsez = text-100.
* Set header data
  im_header->set_data( ls_header ).
  im_header->set_changed( ).
endif.