cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a requirement routine that excludes a condition type?

walkerist
Participant
0 Kudos

Hi I have created a requirement routine that removes ZDC1 if ZNP1 is not present. However, other existing condition types gets removed in the VA01 Condition Record which is not expected.

Here's my code:

IF KOMK-VKORG = 'S099'
IF KOMT1-KSCHL = 'ZNP1'.
SY-SUBRC = 4.
ENDIF.
ENDIF.

Accepted Solutions (0)

Answers (2)

Answers (2)

DominikTylczyn
Active Contributor

Hello walkerist

I don't think you need to implement any requirements here. All you need is condition exclusion, which is pricing standard functionality - SAP Help Condition Exclusion You requirement falls under Excluding the Conditions in an Exclusion Group

The configuration sits in SPRO Sales and Distribution -> Basic Functions -> Pricing -> Condition Exclusion

You need to define two condition groups, assign ZC02 to the 1st group and ZD01 to the 2nd group. Then you add condition exclusion procedure D "Exclusive" to your pricing procedure.

That should work without a single line of ABAP code.

Best regards

Dominik Tylczynski

walkerist
Participant

3a9e4ce873a94034b33dc62b0ce600ee

The link was helpful. However, it should be NOT present(my bad). ZD01 should not be present when ZC02 is not present.

DominikTylczyn
Active Contributor

walkerist First let me rephrase your requirement to make sure I get it right. If ZC02 is present, then ZD01 can be present. If ZC02 is not present, then ZD01 mustn't be present.

If so, I can think of two options.

You can either use Condition Supplements and add ZD01 as a suplement to ZC02. Then ZD01 will only be determined if ZC02 is determined.

Or you can stick to condition exclusions and add one more dummy statistical condition, let's call it ZDMY. Create exclusion groups as follows:

  • GR-A with ZC02
  • GR-B with ZDMY
  • GR-C with ZD01

Insert two exclusions of type D into your pricing procedure:

  1. First group: GR-A, second group: GR-B
  2. First group: GR-B, second group GR-C

The 1st exclusion will determine ZDMY only if ZC02 is not present. Then, the 2nd exclusion will not determine ZD01, because ZDMY is present. And vice versa, if ZC02 is present, the 1st exclusion will not determine ZDMY. Then, the 2nd exclusion will determine ZD01.

I think the first approach is more straight forward.

Best regards

Dominik Tylczynski

walkerist
Participant
0 Kudos

3a9e4ce873a94034b33dc62b0ce600ee Thanks for this but the owner want to do it in ABAP. Here's what I have tried

*IF sy-subrc = 4, ZD01 will be not be present in condition record since ZC02 is not present in KOMT1 table
*IF sy-subrc = 0, Nothing will be done since ZC02 is present in KOMT1 table. Hence ZD01 should also be present.
IF KOMK-VKORG = 'S099' AND KOMT1-KSCHL = 'ZD01'.
sy-subrc = COND #( WHEN line_exists( komt1[ kschl = 'ZC02' ] )
THEN 0
ELSE 4 ).
ENDIF.

However, upon trying to create a Sales Order, when ZC02 is present, the ZD01 is not present in Condition Records.

EDIT:
I was able to display the ZD01 when ZC02 is present. However, ZD01 is still present when ZC02 is missing 😞

DominikTylczyn
Active Contributor
0 Kudos

walkerist I understand however that's most peculiar that the owner prefers ABAP over standard. See my next answer with the solution proposal.

DominikTylczyn
Active Contributor
0 Kudos

Hello walkerist

walkeristFor ABAP based solution, I'd suggest using condition exclusion with the exclusion indicator KZNEP - see the note 836243 - How condition exclusion works in R/3, point 2.

Assign both ZC02 (or ZNP1 as you are using both types throughout this question) and ZD01. ZC02 needs to be followed by ZD01.

Define a new exclusion indicator in SPRO Sales and Distribution -> Basic Functions -> Pricing -> Condition Exclusion -> Condition Exclusion For Condition Types And Records.

Assign the indicator to the ZC02 condition type in its configuration:

Define a new pricing requirement in VOFM similar to the standard 6 requirement. Your implementation should check if KOMP-KZNEP <> <the exclusion indicator> and set sy-subrc = 4 in that case or sy-subrc = 0 otherwise.

Assign the requirement to ZD01 condition type in the pricing procedure.

That will work as follows:

  • if ZC02 condition is determined, then KOMP-KZNEP will be set to the exclusion indicator defined, then the requirement will set sy-subrc = 0 for ZD01, thus ZD01 will be activated.
  • if ZC02 condition is not determined, then KOMP-KZNEP will not be set to the exclusion indicator defined, then the requirement will set sy-subrc = 4 for ZD01, thus ZD01 will be supressed.

Best regards

Dominik Tylczynski