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: 

PO Cost center validation

Former Member
0 Kudos

hi all,

BADI ME_PROCESS_CUST_PO Method -->PROCESS_ACCOUNT

i was trying to add a validation for the cost center, if a particular cost center is entered a againist a G/L system should give a error message with " use the right combination of cost center" and should not let the PO to save or atleast add the message to colllecter and should not all to proceed further document.

cna you please provide a sample code? This is what am doing right now but it is letting me to save the PO.

  • INCLUDE mm_messages_mac.

**

  • DATA: ls_acct TYPE mepoaccounting.

  • DATA: lv_sakto TYPE saknr,

  • lv_kostl TYPE kostl.

*

*

    • DATA: lt_im_account TYPE REF TO if_purchase_order_account_mm.

**

  • ls_acct = im_account->get_data( ).

**

  • IF NOT ls_acct-kostl IS INITIAL.

***

  • lv_sakto = ls_acct-sakto.

  • lv_kostl = ls_acct-kostl.

**

  • SELECT SINGLE * FROM zgl_cc INTO lt_zgl_cc WHERE

  • glacc = lv_sakto AND

  • costcenter = lv_kostl.

*

  • IF sy-subrc NE 0 AND lv_sakto GE '0000500000'.

*

  • mmpur_message_forced 'E' 'ZM' '048' TEXT-003 ' ' ' ' ' ' .

  • CALL METHOD im_account->invalidate( ).

    • CONTINUE.

Edited by: prashanth348 on Jun 23, 2010 8:08 PM

4 REPLIES 4

Former Member
0 Kudos

Moderator message - Welcome to SCN. The code you have posted has everything commented out, so it is impossible to say what you are doing. Please re-post the actual code you are using and use the code tag button (angle brackets) to format your code. Also, Please read and and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again. Rob

0 Kudos
INCLUDE mm_messages_mac.

  DATA: ls_acct TYPE mepoaccounting,
        lt_zgl_cc TYPE zgl_cc,
        ls_customer TYPE mepo_badi_exampl,
        ls_tbsg     TYPE tbsg.

  ls_acct = im_account->get_data( ).

  IF NOT ls_acct-kostl IS INITIAL.
    SELECT SINGLE  * FROM zgl_cc INTO lt_zgl_cc WHERE
                                     glacc      = ls_acct-sakto AND
                                     costcenter = ls_acct-kostl.

    IF sy-subrc NE 0 AND  ls_acct-sakto GE '0000500000'.
      mmpur_message_forced 'E' 'ZM' '048' TEXT-003 ' '  ' ' ' ' .
      CALL METHOD im_account->invalidate( ).
    ENDIF.
    else.
    mmpur_remove_messages_by_id ls_acct-id.
  ENDIF.

Edited by: Rob Burbank on Jun 23, 2010 3:11 PM

Former Member
0 Kudos

i was able to validate the cost center and raise error message in the message collector however when i save the PO with errors and go back in to change mode again the errors message is cleared from the message collector of the PO.

any suggestion why the error message is cleared after saving the PO and when re-opened?

Former Member
0 Kudos

solved myself.

the process_account method doesnt work good , I switched over to the CHECK method where there is a real flexibily to retrive the data and only issue with the check mothod is if you have multiple line items and wanted to issue multiple messages( one per item) then you have to restirct the error message length to 'abt 40char otherwise SAP is overriding the previous messages.

MIGHT NEED to do some system debugging...

METHOD if_ex_me_process_req_cust~check.

INCLUDE mm_messages_mac.

mmpur_message_forced 'E' 'ME' '303' text '' '' '' macro is very critical issuing forced message in the message collector.

endmethod.

so closing this thread......