Application Development and Automation 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: 
Read only

Avoid saving data when holding purchase order

maria_merino
Active Participant
0 Likes
1,405

Hi experts,

I need to make some checks before saving a purchase order. I'm using badi IF_EX_ME_PROCESS_PO_CUST. If I change Payment termns at header level (and some other conditiones) an error message must be shown .

At method PROCESS_HEADER it's working fine, I compare all fields required and then I give the error

mmpur_business_obj_id lw_mepoheader-id.

mmpur_message_forced 'E' 'ZMM01' '049' l_zterm '' '' ''.

At method CHECK I do the same.

When I save the PO I get the error and it's not possible to save.

The problem is when I change Payment terms and hold the PO (this is the first time I use the button "Hold"). PROCESS_HEADER and CHECK work fine but at the end the PO is saved with the wrong data, I want to keep the previous payment terms. Even if I call to method set_data at method CHECK, when I debug method POST I have the new value.

Is there anything I can do so when holding the PO this field is not changed?

thanks in advance,

Maria

4 REPLIES 4
Read only

MateuszAdamus
Active Contributor
0 Likes
1,345

Hi maria.merino

Why not simply show the message with the MESSAGE keyword?

Are you setting the CH_FAILED to YES ('X') in your CHECK method implementation?

Regards,
Mateusz
Read only

0 Likes
1,345

Yes I set CH_FAILED = 'X':

ch_failed = 'X'.
lw_header-zterm = l_zterm.
im_header->set_data( lw_header ).

in Set_data both my_ibs_firewall_on and my_cust_firewall_on are blank so the field is not being modified.

Read only

0 Likes
1,345

Hi Maria,

Do you get the popup as shown below? It's not enough to allow user to chose between hold and keep editing?

If this is the case, then I found a small hack for you. You need to set the GF_NO_HOLD flag to Yes ('X').

FIELD-SYMBOLS:
  <lv_no_hold> TYPE any.

IF error = abap_true. " execute for some condition which should disable hold possibility
  ASSIGN ('(SAPLMEPO)GF_NO_HOLD') TO <lv_no_hold>.
  IF sy-subrc = 0. " just in case
    <lv_no_hold> = abap_true. " hold is not an option in this case
  ENDIF.
ENDIF.
Regards,
Mateusz
Read only

0 Likes
1,345

Hi Maria,

Please have a look at the ME_HOLD_PO BADI.

I think this is what you're looking for in terms of disabling the HOLD button when document has an error.

Regards,
Mateusz