cancel
Showing results for 
Search instead for 
Did you mean: 

duplicate R/3 custom requirement in IPC

Former Member
0 Kudos

I am new to CRM/SAP, I need to "copy" a custom pricing requirement routine on R3 to IPC in CRM (routine attached below).

The R/3 routine involves a Z table which we have duplicated in CRM and it looks like:

-


FIELD -- DATA ELEMENT -- Short descrpt.

MANDT -- MANDT

VKORG -- VKORG -- sales org

MTPOS -- CRMT_ITEM_CAT_GROUP -- item category grp

KSCHL -- KSCHL -- condition type

PSTYV -- PSTYV -- sales doc item categor

KOBED -- KOBED -- requirement

-


Dom kindly told me in one of the earlier posting that I need to make sure every field is added and value filled in the communication structure, I am told that all fields have now been added all the fields in the communication structure. Can some one kindly tell me what fields we need to fill besides MTPOS that Dom mentioned? How do I "get/reference and use" them in the IPC? Should I modifiy PricingUserExits.checkRequirement(IConditionFindingManagerUserExit item, IStep step, int reqNo)? Looking at the R/3 routine, I don't have a good idea as what I need to code in the switch statement, would it be possible for someone to post a sample code snip?

Appreciate any help very much,

Yanhui

Please see the R3 routine source code for reference:

**********************************************************

  • 06/12/97 DV2K907733 - Andrew Bright / Origin Technology

  • New Routine to check that the condition is allowed for the

  • item category.

**********************************************************

FORM KOBED_900.

DATA: BEGIN OF MORE_REQ,

FIX(6) VALUE 'KOBED_',

NR LIKE T683S-KOBED,

END OF MORE_REQ,

X_VALID .

TABLES:ZSITCATPRI,MVKE.

CLEAR X_VALID.

SY-SUBRC = 4.

  • Find out the item cat. group from the material

  • master for S.Org, D.chn and division

  • - Jit Bhandari - DV2K913980

SELECT SINGLE * FROM MVKE WHERE MATNR = KOMP-MATNR

AND VKORG = KOMK-VKORG

AND VTWEG = KOMK-VTWEG.

IF SY-SUBRC = 0.

  • Check whether the record exit in table ZITCATPRI

  • First check whether the entry exist with the item

  • category also as a key or not

SELECT SINGLE * FROM ZSITCATPRI

WHERE VKORG = KOMK-VKORG

AND MTPOS = MVKE-MTPOS

AND PSTYV = KOMP-ZZPSTYV

AND KSCHL = KOMT1-KSCHL.

IF SY-SUBRC EQ 0.

  • If it is found in the table then this condition

  • type is to come in the calculation of the prices

IF ZSITCATPRI-KOBED NE 0.

  • Look for any other req.check exist in the table

MORE_REQ-NR = ZSITCATPRI-KOBED.

PERFORM (MORE_REQ) IN PROGRAM SAPLV61A.

ENDIF.

ELSE.

  • The item category record is not found in the ZSITCATPRI

SELECT * FROM ZSITCATPRI

WHERE VKORG = KOMK-VKORG

AND MTPOS = MVKE-MTPOS

AND KSCHL = KOMT1-KSCHL.

IF ZSITCATPRI-PSTYV IS INITIAL.

IF ZSITCATPRI-KOBED NE 0.

    • Look for any other req.check exist in the table

MORE_REQ-NR = ZSITCATPRI-KOBED.

PERFORM (MORE_REQ) IN PROGRAM SAPLV61A.

ENDIF.

EXIT.

ELSE.

X_VALID = 'N'.

EXIT.

ENDIF.

ENDSELECT.

ENDIF.

ENDIF.

IF NOT X_VALID IS INITIAL. SY-SUBRC = 4. ENDIF.

*if no record is found, then requirement not met (sy-subrc <> 0).

ENDFORM.

  • Vorstep

FORM KOBEV_900.

SY-SUBRC = 0.

ENDFORM.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Yanhui

Now that all the attributes are being passed in the communication structure, you can code your routine without worrying about SELECT statements.

Your routine simply has to give a boolean true or false output. In ABAP this is achieved by the value of field SY-SUBRC - this return code is checked, 0 = true, anything else = false.

The first thing to do is to program the

determineRelevantAttributesForRequirement

method. Not all communication structure attributes are provided to the user exits. So, work out the ones you need.

These may be named differently in the field catalog to the field names you gave above.

Ask your colleagues for the names, or check in CRM - go to the field catalog transaction /SAPCND/CTFC . Often a 'ZZ' is prefixed to the field name to avoid conflict with future SAP standard fields. I'll assume that this has happened from now in this post.

So, your

determineRelevantAttributesForRequirement

method would look something like this:

public String[] determineRelevantAttributesForRequirement(
		boolean headerAttributes, int reqNo) {
  // String of relevant attribute names to return
  String[] relevantAttributes = new String[0];

  // Header?
  if (headerAttributes) {
	// KOMK fields
	switch (reqNo) {
	
	case 701:
		// Nothing needed at header level
		break;
	}
	
  }
  // Item
  else {
	// KOMP fields
	switch (reqNo) {
	
	case 701:
		relevantAttributes = new String[]{ "ZZKSCHL", "ZZKOBED", "ZZPSTYV" };
		break;
	}
}
//		 Return the determined string of attributes
	return relevantAttributes;
	
}

And then you will be able to access these attributes in your new routine.

You need to register your new routine also. It is number 900. This is done in method

getRequirementNumbers

:

	public int[] getRequirementNumbers() {
		return new int[] { 900 };
	}

Now you can code the actual requirement. This is done in method

checkRequirement

. A switch takes place depending on the requirement number.


    public boolean checkRequirement(IConditionFindingManagerUserExit item,
			IStep step, int reqNo) {

		switch (reqNo) {
		case 900: //This is our special requirement
                // *** Logic will go here, see below

		default:
			throw new FormulaNotImplementedException(item, "requirement", reqNo);
		}
	}

Now you need to code the actual logic.

Your ABAP requirement has an X_VALID field that is used to keep track of the true/false status.

In the same way, you can declare this at the start:

	boolean x_valid = false;

And return it at the end as the result:

  return x_valid;

In the middle, we need to add the custom logic. Now, one of the things they do in the ABAP is that if a different pricing routine is specified in table ZSITCATPRI field KOBED, then they perform that routine to get the true/false.

So, you could do the same thing - get the KOBED value from the communication structure as an integer:

int kobed = Integer.parseInt(item.getItemAttributeValue("ZZKOBED").getValue());

Remember I am assuming KOBED has a ZZ prefix in the field catalog.

And then we can call that routine (we are calling the same method we are in, but with another requirement number, not 900):

x_valid = checkRequirement(item, step, kobed);

Now, what is immediately apparent here is that these routines must be coded and available. I am not convinced that all the preparation work has been done by your colleagues.

In particular, I am interested by this Z table as one of the key fields is Condition Type. I don't know how they can provide this in the communication structure as the communication structure is at pricing document level, whereas Condition Type is at pricing step level.

Is their design fixed? You may end up being forced to read this Z table from within the pricing routine. This is possible but should be avoided. I am sorry, but your work is not easy due to the ABAP design.

Good Luck

Dom