cancel
Showing results for 
Search instead for 
Did you mean: 

Read transfered name value pairs from IPC within my Java Userexits

Former Member
0 Kudos

Dear SAP developers,

I have the following requirement: In my java userexits I would like to read out the header name value pairs which are transfered via the COND_COM_BADI. I think they can be set via the implementation of the method IF_EX_CRM_COND_COM_BADI~HEADER_NAME_VALUE. Can anybody give me a Java code snippet how this is done?

I would guess that there must be some kind of method which returns a Map that contains these name value pairs. But where is this method located?

Greets Ruben

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Arun,

thank you very much for your replies. They helped me because when it is only possible to pass a string with the restriction to 50 chars then it does not make sense from my point of view to pass a customizing table via CRM_COND_COM_BADI. Because every time when it is growing I have to create new attributes.

Now I have got the idea to access this Z-Table via JavaConnector once with the first call and then store this data within a singleton.

Greets Ruben

former_member192716
Contributor
0 Kudos

Hi Ruben,

Can you explain how to acces z-Table using JavaConnector. I have no idea about how to access CRM tables from java routines. If possible please explain how you did it.

Thanks & Regards,

Arun

Former Member
0 Kudos

Hi Arun,

there is a JCO library and I would like to use it for accessing this Z-Table. Till now I have not tested it. I will give you a feedback when I am through. But it can take same time.

Greets Ruben

Former Member
0 Kudos

Hi Arun,

we found another way without JCo to transfer the differences from ABAP to JAVA.

If you use the COND_COM_BADI then do the following in method item_name_value:

METHOD if_ex_crm_cond_com_badi~item_name_value.

DATA: ls_inv TYPE prct_attr_name_value,

lv_seq TYPE prct_attr_sequence_number,

lv_pricing type char1.

FIELD-SYMBOLS: <ls_inv> TYPE prct_attr_name_value.

get parameter id 'YY_PRICING_EXIT' field lv_pricing.

check: lv_pricing = 'X'.

READ TABLE ct_item_name_value ASSIGNING <ls_inv>

WITH KEY attr_name = 'CAMPAIGN_GUID'.

IF sy-subrc <> 0.

lv_seq = 0.

ELSE.

lv_seq = 1.

ENDIF.

  • CRM_PRIDOC_COMM_BADI

ls_inv-attr_name = 'CAMPAIGN_GUID'.

ls_inv-seq_number = lv_seq.

ls_inv-attr_value = '11111111111111111111111111111111'.

INSERT ls_inv INTO TABLE ct_item_name_value.

lv_seq = lv_seq + 1.

ls_inv-attr_name = 'CAMPAIGN_GUID'.

ls_inv-seq_number = lv_seq.

ls_inv-attr_value = '22222222222222222222222222222222'.

INSERT ls_inv INTO TABLE ct_item_name_value.

lv_seq = lv_seq + 1.

ls_inv-attr_name = 'CAMPAIGN_GUID'.

ls_inv-seq_number = lv_seq.

ls_inv-attr_value = '33333333333333333333333333333333'.

INSERT ls_inv INTO TABLE ct_item_name_value.

ENDMETHOD.

Then in JAVA you can read the multi-value attribute with the following coding:

String[] test = pricingItem.getAttributeValues("CAMPAIGN_GUID");

userexitLogger.writeLogDebug("Length: " + test.length);

for (int i = 0; i < test.length; i++){

userexitLogger.writeLogDebug("CAMPAIGN_GUID: " + test<i>);

}

Greetings Ruben

former_member192716
Contributor
0 Kudos

Hi Ruben,

Thanks a lot for your reply. This seems to be a better alternative to creating attributes in field catalog and assigning them to userexits. I will try this out. If possible please post this as a wiki. Thanks again.

Regards,

Arun

Former Member
0 Kudos

Hi Arun,

be careful the CAMPAIGN_GUID is an attribute which is defined by the SAP standard. If you want to use customer specific multi-valued attributes you have to define them in the field catalogue and map them via transaction /SAPCND/UEASS on your own.

Edited by: hardy1982 on Oct 19, 2010 10:14 AM

Former Member
0 Kudos

Hi ,

I have same requirement to pass multi-valued attributes from CRM_COND_COM_BADI to my IPC Java user exit in which I need to extract all the values as String array.

I have implemented the same process as you have explained above. But I am not able to retrieve the values in my Java user exit for my custom attributes. All the values are coming as empty list in my String array.

The steps I have done as below.

1. Defined the Filed Catalog attribute ZZ_KBETR in maintain field catalog ( Filed type = I, Virtual = A, Selection type = D).

     SPRO->CRM->Basic Functions->Pricing->Maintain Catalog

2. Click on change mode and New entries.

3. Enter the custom field with the custom Data type - ZZ_KBETR Data element

4. Save and generated the field catalog. I could see my custom attribute in the BADI item communication structure.

5. Implemented the logic to populate multiple values for ZZ_KBETR, in the BADI.

6. Used the method String zz_kbetr[] =  item.getAttributeValues("ZZ_KBETR");

I am attaching my Field catalog configuration and Java piece of code. Please help me what went wrong as it is very urgent for my Client requirement.

String ZZKBETR_1[] =  pricingItem.getAttributeValues("ZZKBETR_1");

if(ZZKBETR_1 != null )

{

  userexitlogger.writeLogDebug(" 935 formula , overwriteConditionValue ::  ZZKBETR_1.length=[ "+ZZKBETR_1.length+"]");

  for(int k=0;k<ZZKBETR_1.length;k++)

  {

  try

  {

  userexitlogger.writeLogDebug(" 935 formula , overwriteConditionValue :: ZZKBETR_1["+k+"]= [" + ZZKBETR_1[k] + "] ");

  }

  catch(Exception ex1)

  {

  userexitlogger.writeLogDebug(" 935 formula , overwriteConditionValue :: Error Message=[ "+ex1.getMessage()+"]");

  }

  }

  }

CRM_COND_COM_BADI - > IF_EX_CRM_COND_COM_BADI~ITEM_NAME_VALUE method     Logic as below

     l_seqno = l_seqno + 1.

     is_val-attr_name = 'ZZKBETR_1'.

    is_val-seq_number = l_seqno.

    is_val-attr_value = 'VSE0100'.

    INSERT is_val INTO TABLE ct_item_name_value.

    CLEAR is_val.

    l_seqno = l_seqno + 1.

    is_val-attr_name = 'ZZKBETR_1'.

    is_val-seq_number = l_seqno.

    is_val-attr_value = 'VSE1200'.

    INSERT is_val INTO TABLE ct_item_name_value.


    l_seqno = l_seqno + 1.

    is_val-attr_name = 'ZZKBETR_1'.

    is_val-seq_number = l_seqno.

    is_val-attr_value = 'VSE1300'.

    INSERT is_val INTO TABLE ct_item_name_value.

Can some body throw  light into this, why I am not getting the multi values in Java user exit - Condition Value Formula. In the CRM ABAP debugging I am able to see the multi values for ZZKBETR_1.



I am able to retrieve the values for CAMPAIGN_GUID in user exit, if I pass multi values from BADI. But I am not at all able to retrieve the multi values for my custom attributes.


Any kind of help or  inputs are highly appreciated and will be rewarded.


Am I doing some thing wrong at maintain Field catalog configuration. What are the properties/parameters  (Field type , Virtual, selection type ) to be provided for custom fields at maintain field catalog.



Thanks

Srikar

former_member192716
Contributor
0 Kudos

Hi Ruben,

In your java routine use item.getAttributeValue to read the attribute passed from COND COM BADI.


public BigDecimal overwriteConditionValue(IPricingItemUserExit item,
			IPricingConditionUserExit condition) 
{   

String flag = item.getAttributeValue("ATTR_1");
}

Also you can refer the coding part of this wiki its a requirement routine,

http://wiki.sdn.sap.com/wiki/x/s4TYCw

Regards,

Arun

Edited by: Arun Kumar on Aug 11, 2010 11:52 AM

Former Member
0 Kudos

Hi Arun,

thank you very much for your answer, but there is no method on header level (pricingItem.getUserExitDocument().getAttributeValue())?

Is it always necessary that a attribute is defined via transaction /SAPCND/UEASS?

My requirement needs a bit more generic approach. I want to calculate several differences between different conditions. For example I want to calculate the difference between the condition types ZC00 and ZC01. In the case that the difference is positive its value should be assigned to condition type ZC02 and if it is negative it should be assigned to condition type ZC03. How can I pass on header level a whole Z-Table with the fields PRICING_PROCEDURE, MINUEND, SUBTRAHEND, DIFFERENCE_POSITIVE and DIFFERENCE_NEGATIVE?

Another idea was to pass these differences stored in Z-Table via a string attribute (like "ZPRICPRO/ZC00/ZC01/ZC02/ZC03"... and "/" as separator) . But then I have the restriction of the string length!

Do you have any other ideas?

Greets Ruben

former_member192716
Contributor
0 Kudos

Hi Ruben,

1.I dont think you can pass attributes at header level. And all attributes must be assigned only through /SAPCND/UEASS. You have to fill the attribute values in any of the methods HEADER_COMMUNICATION_STRUCTURE or ITEM_COMMUNICATION_STRUCTURE.

2. You can assign values to different condition types using the below sample code,


IPricingConditionUserExit[] prSubItems = pricingItem.getUserExitConditions();
IPricingConditionUserExit iPCondition  = null;
for (int j = 0; j < prSubItems.length; j++) 
{	
     if(prSubItems[j].getConditionTypeName() .trim().equalsIgnoreCase("ZC00"))
     {
        iPCondition = (IPricingConditionUserExit) prSubItems[j];
        iPCondition.setConditionRateValue(...)
     }
}

3. String length is restricted to 50 chars and i wonder why you have to pass the pricing procedure details. You can get the pricing procedure using "pricingItem.getUserExitDocument().getPricingProcedure()"

Refer these similar threads,

Regards,

Arun

Edited by: Arun Kumar on Aug 11, 2010 7:27 PM