‎2007 Jul 05 7:42 PM
We want to access the following method using SAP badi. Implementation interface is IF_EX_ME_PROCESS_REQ_CUST. Implementation name is : Z_BBH_PREQ1.
Method: IF_RELEASABLE_MM~IS_RESET_REL_ALLOWED
Parameter: RE_ALLOWED (Boolean)
We were having issues in accessing this method (syntax issues).
Once the parameter RE_ALLOWED is returned (as true or false) we can put in our logic (custom error messages).
method IF_EX_ME_PROCESS_REQ_CUST~PROCESS_ITEM .
*- Message the user about more than one cost centers in PR
DATA : s_exkn TYPE exkn,
s_items TYPE MMPUR_ACCOUNTING_LIST,
z_items TYPE MMPUR_ACCOUNTING_TYPE,
s_knttp TYPE knttp,
s_allowed TYPE mmpur_bool.
CALL METHOD IM_ITEM->IF_ACCT_CONTAINER_MM~GET_CATEGORY
RECEIVING
re_knttp = s_knttp.
IF s_knttp NE 'F' AND s_knttp NE 'K' and s_knttp NE ''.
MESSAGE e014(zmm).
ENDIF.
IF s_knttp EQ ''.
Return.
Else.
CALL METHOD IM_ITEM->IF_ACCT_CONTAINER_MM~GET_ITEMS
RECEIVING
re_items = s_items.
READ TABLE s_items INTO z_items INDEX 1.
CALL METHOD z_items-model->GET_EXKN
RECEIVING
re_exkn = s_exkn.
IF s_knttp = 'F'.
IF s_exkn-kostl <> ''.
MESSAGE e002(zmm).
ENDIF.
IF s_exkn-aufnr = ''.
MESSAGE e003(zmm).
ENDIF.
IF s_exkn-aufnr BETWEEN '000000030000' AND '000000049999'.
MESSAGE e004(zmm).
ENDIF.
IF s_exkn-sakto = ''.
MESSAGE e005(zmm).
ENDIF.
IF s_exkn-aufnr BETWEEN '000000010000' AND '000000019999'
AND NOT s_exkn-sakto BETWEEN '0000080000' AND '0000080009'.
MESSAGE e009(zmm).
ELSEIF s_exkn-aufnr BETWEEN '000000020000' AND '000000029999'
AND NOT s_exkn-sakto BETWEEN '0000080010' AND '0000080019'.
MESSAGE e010(zmm).
ELSEIF s_exkn-aufnr BETWEEN '000000050000' AND '000000059999'
AND NOT s_exkn-sakto BETWEEN '0000080020' AND '0000080029'.
MESSAGE e011(zmm).
ELSEIF s_exkn-aufnr BETWEEN '000000060000' AND '000000069999'
AND NOT s_exkn-sakto BETWEEN '0000080030' AND '0000080039'.
MESSAGE e012(zmm).
ELSEIF s_exkn-aufnr BETWEEN '000000280000' AND '000000689999'
AND NOT s_exkn-sakto BETWEEN '0000080040' AND '0000080049'
OR s_exkn-aufnr BETWEEN '000031000000' AND '000039999999'
AND NOT s_exkn-sakto BETWEEN '0000080040' AND '0000080049'
OR s_exkn-aufnr BETWEEN '000051000000' AND '000051999999'
AND NOT s_exkn-sakto BETWEEN '0000080040' AND '0000080049'.
MESSAGE e013(zmm).
ENDIF.
ELSEIF s_knttp = 'K'.
IF s_exkn-kostl = ''.
MESSAGE e007(zmm).
ENDIF.
IF s_exkn-aufnr <> ''
AND NOT s_exkn-aufnr BETWEEN '000000030000' AND '000000049999'.
MESSAGE e008(zmm).
ENDIF.
IF s_exkn-sakto = ''.
MESSAGE e005(zmm).
ENDIF.
IF NOT s_exkn-sakto BETWEEN '0000050000' AND '0000069999'.
MESSAGE e006(zmm).
ENDIF.
ENDIF.
else.
write:/ 'Release not possible, check the account assignment'.
endif.
*----
endif.
endmethod.
I have to write a new code to Check for different cost center/order # on different requisition lines: Error message if cost center /order # do not match up on all lines.
Can anyone help to rewrite the code for me. Thanks heaps
‎2007 Jul 06 4:49 AM
Hello Mukunda
Assuming that all information you require and that has to be checked can be found in EXKN the logic should look like this:
DATA:
ls_exkn TYPE exkn,
lt_exkn TYPE STANDARD TABLE OF exkn.
...
s_items = IM_ITEM->IF_ACCT_CONTAINER_MM~GET_ITEMS( ).
"READ TABLE s_items INTO z_items INDEX 1. " Replaced by:
REFRESH: lt_exkn.
" Collect requisition lines
LOOP AT s_items INTO z_items.
ls_exkn = z_items-model->GET_EXKN( ).
APPEND ls_exkn TO lt_exkn.
ENDLOOP.
IF ( lt_exkn IS NOT INITIAL ).
READ TABLE lt_exkn INTO ls_exkn INDEX 1.
LOOP AT lt_exkn TRANSPORTING NO FIELDS
WHERE ( kostl NE ls_exkn-kostl ).
EXIT.
ENDLOOP.
" At least one requisition line has a different cost center -> error
IF ( syst-subrc = 0 ).
... " send error message
ENDIF.
ENDIF.
Regards
Uwe