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: 

ME_PROCESS_PO_CUST~PROCESS_HEADER

Former Member
0 Kudos

I'm trying to change a Z field on our purchase order headers. Here is the code:

METHOD if_ex_me_process_po_cust~process_header .

DATA: ls_mepoheader TYPE mepoheader.

ls_mepoheader = im_header->get_data( ).

  • The terms in the purchase order should come from the contract. If

  • there are no contract terms, use the vendor's terms.

IF ls_mepoheader-konnr IS NOT INITIAL.

SELECT SINGLE zterm INTO ls_mepoheader-zterm FROM ekko

WHERE ebeln = ls_mepoheader-konnr

AND bstyp = 'K'.

IF sy-subrc <> 0 OR ls_mepoheader-zterm IS INITIAL.

SELECT SINGLE zterm INTO ls_mepoheader-zterm FROM lfm1

WHERE lifnr = ls_mepoheader-lifnr

AND ekorg = ls_mepoheader-ekorg.

ENDIF.

ELSE.

SELECT SINGLE zterm INTO ls_mepoheader-zterm FROM lfm1

WHERE lifnr = ls_mepoheader-lifnr

AND ekorg = ls_mepoheader-ekorg.

ENDIF.

im_header->set_data( im_data = ls_mepoheader ).

im_header->set_changed( ).

ENDMETHOD.

It doesn't work - debugging shows its going through the code ok but the PO doesn't have the right ZTERM once its saved.

Can anybody tell me what I've done wrong?

Thanks, Brigitte

1 ACCEPTED SOLUTION

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Brigitte!

I just had a look into our implementation, this part looks pretty much the same:

    if ls_bestellkopf_neu-zterm <> ls_bestellkopf-zterm or
       ls_bestellkopf_neu-zbd1t <> ls_bestellkopf-zbd1t or
       ls_bestellkopf_neu-zbd2t <> ls_bestellkopf-zbd2t or
       ls_bestellkopf_neu-zbd3t <> ls_bestellkopf-zbd3t.
      move ls_bestellkopf_neu-zterm to ls_bestellkopf-zterm.
      move ls_bestellkopf_neu-zbd1t to ls_bestellkopf-zbd1t.
      move ls_bestellkopf_neu-zbd2t to ls_bestellkopf-zbd2t.
      move ls_bestellkopf_neu-zbd3t to ls_bestellkopf-zbd3t.

      call method im_header->set_data
        exporting
          im_data = ls_bestellkopf.
    endif.

But inside of method im_header->set_data some checks are performed ('my_cust_firewall_on') - just debug this method to see, what is going on there.

Also a call of set_changed() seems not to be necessary.

Regards,

Christian

4 REPLIES 4

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Brigitte!

I just had a look into our implementation, this part looks pretty much the same:

    if ls_bestellkopf_neu-zterm <> ls_bestellkopf-zterm or
       ls_bestellkopf_neu-zbd1t <> ls_bestellkopf-zbd1t or
       ls_bestellkopf_neu-zbd2t <> ls_bestellkopf-zbd2t or
       ls_bestellkopf_neu-zbd3t <> ls_bestellkopf-zbd3t.
      move ls_bestellkopf_neu-zterm to ls_bestellkopf-zterm.
      move ls_bestellkopf_neu-zbd1t to ls_bestellkopf-zbd1t.
      move ls_bestellkopf_neu-zbd2t to ls_bestellkopf-zbd2t.
      move ls_bestellkopf_neu-zbd3t to ls_bestellkopf-zbd3t.

      call method im_header->set_data
        exporting
          im_data = ls_bestellkopf.
    endif.

But inside of method im_header->set_data some checks are performed ('my_cust_firewall_on') - just debug this method to see, what is going on there.

Also a call of set_changed() seems not to be necessary.

Regards,

Christian

Former Member
0 Kudos

Thanks for the tip Christian. I need to set my_cust_firewall_on to 'no'. I'm new to BADIs and objects so haven't been able to find how/where. Where did you do it in your code (if you did)?

(Also, I coded set_changed() because it was suggested elsewhere in SDN - it didn't work for that Poster either!)

0 Kudos

Hi Brigitte!

No, we don't set my_cust_firewall_on. Anyway, looks like it has to be set to 'X' (= mmpur_yes), otherwise this check will end the execution of method set_data.

This is not the usual BADI way - all the complex handling via interface is a special technic for the PO (and maybe somewhere else), but most BADIs work just like a function module (roughly).

This 'firewall' is a public instance attribute - but not of the interface, but of the implementation of im_header... So I don't know if you get direct access (at least in debugger you can see this attribute below im_header).

There are a lot of places, where this is set. Make some tests to figure out what's going on. A watchpoint might help, also try manual creation via ME21N (then it's OK for us)...

I couldn't find any documentation on this part, so it's your own investigation.

Regards,

Christian

Former Member
0 Kudos

I worked out what needed to be done & thought I should post it in case it helped somebody in the future. After the last ENDIF, i've changed the code to:

  • Update the attributes in the im_header interface, so

  • that SAP standard fields can actually be modified.

if ch_po is initial.

ch_po ?= im_header.

endif.

ch_po->my_ibs_firewall_on = 'X'.

ch_po->my_cust_firewall_on = ' '.

im_header->set_data( im_data = ls_mepoheader ).

endmethod.