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

Validating Internal Order Settlement Rule during creation

Former Member
0 Likes
2,643

Does anybody know of a user exit, badi, anything, that can be used to validate assignement data when creating/changing the settlement rule on an internal order?

Appreciate the help...

Sam

Does anybody know of a user exit, badi, anything, that can be used to validate assignement data when creating/changing the settlement rule on an internal order?

Appreciate the help...

Sam

9 REPLIES 9
Read only

Former Member
0 Likes
2,217

Hi,

Please check the following exit for assignment data validation.

User exit M06B0002.

I think, this would help you out.

Thanks and Regards,

Vanitha S

Read only

0 Likes
2,217

Hi Vanitha, thanks for the response. However, this is not what I was looking for. The exit that you mentioned is used during PO requisition release. IT provides the communication component during the release.

What I am looking for is an exit that gets called when a user is creating/changing settlement rule on an internal order master. (NOTE: NOT during order settlement)

There are 7 exits that I can currently find, however non of them have the structure/assignments for the settlement (receiver, sender, etc) data. We would like to validate the data that user enters in the settlement rule detail fields.

Thanks,

Sam

Read only

0 Likes
2,217

Check the BADI CO_SRULE_CHECK and its method DISTRIBUTION_RULE_CHECK...

see if it can be used in your scenario...

Thanks,

Renjith

Read only

0 Likes
2,217

HI Renjith, thanks for your response. Would you happen to have a sample code on how to implement this BADI?

We would like to insert custom validation to check assignment values when user is creating/changing the settlement rule. A sample code will really help...

Thanks,

Sam

Read only

0 Likes
2,217

Hi Sam,

Steps for implementing a BADI

Steps:

1.Execute Business Add-In(BADI) transaction SE18

2.Enter BADI name i.e. CO_SRULE_CHECK and press the display button

3.Select menu option Implementation->Create

4.Give implementation a name such as Z_CO_SRULE_CHECK

5.You can now make any changes you require to the BADI within this implementation, for example choose the Interface tab

6.Double click on the method you want to change, you can now enter any code you require.

7.Please note to find out what import and export parameters a method has got return the original BADI definition (i.e. CO_SRULE_CHECK) and double click on the method name for example within DISTRIBUTION_RULE_CHECK contract is a method

    • supposing you want to validate the settlement type..then the code would be like...

if DISTRIBUTION_RULE-perbz <> 'CORRECT'.

raise not_allowed.

endif.

8.When changes have been made activate the implementation in SE19

Thanks,

Renjith.

Read only

0 Likes
2,217

Hi Renjith, thanks again for your input. I think we are getting hot! You know, there is a certain prerequisite that we are missing: The BADI method call requires that we export a COBRB (settlement rule) structure. To call the BADI, we have to create an instance of it and call its method passing it r_cobrb (which is of type COBRB).

My problem is that r_cobrb is not filled and the core of the issue is that I don't know how to obtain an internal table/structure that contains the data entered by the user on the settlement rule detail screen.

Please forgive my ignorance as I am not very familiar with how the BADI architecture should work. However, here's what I attempted to do:

==============PSEUDOCODE SNIPPET==================

DATA: Settle_exit type ref to IF_EX_CO_SRULE_CHECK.

DATA: r_cobrb LIKE cobrb.

class CL_EX_CO_SRULE_CHECK definition load.

call method cl_exithandler=>get_instance

changing

instance = Settle_exit.

call method: Settle_exit->DISTRIBUTION_RULE_CHECK

EXPORTING DISTRIBUTION_RULE = r_cobrb.

================CODE Ends==========================

(1) To implement this code, I have to place it somewhere in the call chain after the user clicks the Save button.

(2) Since we cannot change standard SAP, and have to do it in a customer exit (which is a function module), there lies my problem. I need r_cobrb! No exit that I have found so far passes COBRB. They all have AUFK which is not what I want.

(3) Basically, the BADI does not get triggered like a standard user exit, unless I create an instance and call it. That is, with a standard user exit, SAP fills in the structure and pass you the data via a function module. Then you can manipulate this data as you wish. With the BADI, I don't see this similar mechanism. OR am I missing something?

Thanks,

Sam

Read only

0 Likes
2,217

Hi, I just wanted to come back and add this extra information incase someone else needs it in the future:

I think we were finally able to come up with an acceptable solution.

<b>The Problem:

============</b>

SAP does not provide an easy way to validate detail section of a settlement rule for an internal order. The user exits that are available do not import the COBRB structure that contains the screen data entered by user in the detail screen.

<b>Solution:

===========</b>

Watch out for wrapped lines!

(1) Implement the BADI: <b>CO_SRULE_CHECK</b>; NO filter; Settlement Rule Custom Validation BADI

(see current thread for details)

Inside the <b>DISTRIBUTION_RULE_CHECK</b> method of your BADI, implement your custom validation. You can call out to your standard CO validaton module, or whatever.

(2) Implement user exit: EXIT_SAPLRKIO_002(include zxaufu02): Call settlement_rule_check.

(3) Implement a subroutine as shown (adapt to your business environment):

FORM settlement_rule_check.

DATA: exit type ref to IF_EX_CO_SRULE_CHECK.

DATA: lt_cobra LIKE cobra OCCURS 0 WITH HEADER LINE, lt_cobrb LIKE cobrb OCCURS 0 WITH HEADER LINE.

  • don't validate in display mode

CHECK I_ACTVT NE 03.

  • Call function to get the current settlement rule from

  • memory buffer (this is the crux of the solution)

call function 'K_SETTLEMENT_RULE_GET'

EXPORTING

objnr = i_aufk-OBJNR

x_all = ' '

TABLES

e_cobra = lt_cobra

e_cobrb = lt_cobrb

EXCEPTIONS

not_found = 1

others = 2.

if SY-SUBRC <> 0.

  • raising E_MESSAGE.

endif.

  • Now Prepare/call BADI to check the custom rules

class CL_EX_CO_SRULE_CHECK definition load.

  • create an instance of BADI

call method cl_exithandler=>get_instance

changing

instance = exit.

  • call the check method of the BADI

call method: exit->DISTRIBUTION_RULE_CHECK

EXPORTING

DISTRIBUTION_RULE = lt_cobrb

EXCEPTIONS

not_allowed = 1

not_allowed_with_msg = 2.

  • either use a standard message function or create your

  • own

IF sy-subrc = 1.

PERFORM message_send

USING 'KD' 'E' '027' space space space space space.

ELSEIF sy-subrc = 2.

PERFORM message_send

USING sy-msgid sy-msgty sy-msgno

sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

space. "...

ENDIF.

endform.

(4) Test, Test, Test. Hope it works for you.

Sam

Read only

2,217

Hi,

I am not able to see the BADI CO_SRULE_CHECK in SE18.

Can u pls guide me in this regard?

Points will be rewarded.

thnx inadvance.

Read only

Former Member
0 Likes
2,217

Hello Sam

Thankyou very much for adding your solution. You have solved a problem that I have been grappling with for some time - how to access the cost settlement details from the input screen.

Thanks again

Ros