cancel
Showing results for 
Search instead for 
Did you mean: 

IF_EX_CRM_OI_WEBSERVICE_BADI: Has anyone implemented this BAdI

sebastianlenz85
Explorer
0 Kudos

Hello together,

In SAP CRM 7.0 EhP1 SP 04 we would like to integrate Microsoft Word. For this reason we have to create a web service with the web service tool (WS_DESIGN_TOOL) in order to use it in the template designer (CRM_OI_TEMPLDSG) especially in Word. Due to our customers requirements we are looking for a solution to prepare the required data in a certain form so that this data can be used in Word as per requirements. Since the web service design tool only can access the BOL, we have to find a suitable solution.

We identified the following solutions:

1. Create a function module and provide access to it via a webservice by stamping of the above mentioned BAdI.

2. Enhance BOL-Model with requested fields whose data are determined at every action (save or read data on Web UI).

3. Enhance the GenIL component with requested fields whose data are determined in GenIL layer.

From my point of view the first solution approach is most obvious. What do you think about it?

Has someone already had a similar problem and solved it in this way?

Thank you very much in advance!

Regards,

Sebastian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sebastian,

You can try implement BAdI CRM_OFFICE_TEMPLATE_BADI to add custom data to your document template.

1. Redefine Get_attributes method (you can filter it by web service name)


method IF_EX_CRM_OFFICE_TEMP_BADI~GET_ATTRIBUTES.
  DATA: ls_attr TYPE CRM_KW_TEMP_ATTR,
        lt_attr TYPE CRM_KW_TEMP_ATTR_TAB.
*  IF iv_wsname = 'ZTESTQUO001'.
    ls_attr-NAME = 'CustomAddr'.
    ls_attr-DESCRIPTION = 'Custom Address'.
    INSERT ls_attr INTO TABLE lt_attr.
    ct_attributes = lt_attr.
*  ENDIF.
endmethod.

2. redefine get_values method (you can filter it by web service name)


  DATA: ls_val TYPE CRM_KW_TEMP_VALUE,
        lt_val TYPE CRM_KW_TEMP_VALUE_TAB.
*  IF iv_wsname = 'ZTESTQUO001'.
    ls_val-NAME = 'CustomAddr'.
    ls_val-VALUE = 'ABC street'.
    INSERT ls_val INTO TABLE lt_val.
    ct_values = lt_val .
*  ENDIF.

3. Then insert your variable in your document by clicking Insert - Field - choose categories Mail Merge - choose field names MergeField - enter field name your custom attribute (for example in this BAdI :disappointed_face: CustomAddr . The field will be shown as «CustomAddr» (note this menu only shown in Microsoft Office Word 2003, in 2007, you have to use add-in such as Classic Menu for Office ).

or you can try suggestion from Tzanko Stefanov here

What if you try to insert these manually - directly type in the field within brackets - <<fieldname>>. .

Hope it helps.

Agus

Edited by: The Agus Santoso on Nov 4, 2011 4:58 AM

sebastianlenz85
Explorer
0 Kudos

Hello Agus,

Thank you very much for your answer. I tried to implement the BAdI CRM_OFFICE_TEMPLATE_BADI and it works fine. Nevertheless I didn't see a hyperlink "Call BADI" in the document template (I'm using Word 2003). Is this a problem?

Now I would like to set the attribue values, that I have to determine depending on the business object (e.g. sales order). But I don't see any solution to access business object related data like object id or guid in the get_values method.

Do you have any idea to solve this problem?

Thanks in advance and kind regards,

Sebastian

sebastianlenz85
Explorer
0 Kudos

Hi!

With the help of the import structure is_object in the get_values method you can determine the guid of the business object. This and standard function modules like crm_order_read offer many options to determine necessary data.

Best regards,

Sebastian

Former Member
0 Kudos

Hi Sebastian,

Glad can help you FYI link Call BAdI exist in Document template designer. Go to TCODE BSP_WD_CMPWB , enter component CRM_OI_TEMPLDSG , click Test. Choose one of your document template by clicking the left button of your document in the document list, then click Edit.

If you have successfully implemented BAdI CRM_OFFICE_TEMPLATE_BADI , link "Call BAdI" will be enabled and if you click it, it will shows all the attributes that can be put into the document.

If your code is wrong / there's no implementation yet for CRM_OFFICE_TEMPLATE_BADI, link "Call BAdI" will be disabled.

And thank you for your info regarding IS_OBJECT parameter in GET_VALUES method. Really helpful.

Agus.

sebastianlenz85
Explorer
0 Kudos

Hi Agus,

Thank you again for your reply.

When I follow your steps I can't see any hyperlink (neither disabled or enabled). Perhaps because we are using EhP1!?

But this doesn't matter because after implementing the BAdI we successfully can use merge-fields in Word.

Best regards,

Sebastian

Former Member
0 Kudos

Hi Sebastian,

Just FYI I'm using CRM 7.0 Ehp1 too. Here is the screenshot Call BAdI link:

[http://tinypic.com/r/2rel7hy/5|http://tinypic.com/r/2rel7hy/5]

after you click it will be like this :

[http://tinypic.com/r/qwyqv5/5|http://tinypic.com/r/qwyqv5/5]

Best regards,

Agus

sebastianlenz85
Explorer
0 Kudos

Hello Agus,

Thanks for uploading the screenshots.

I debugged the component and found the mistake: In the get_attributes method I didn't assigned the table with the attributes to the changing parameter.

Just adding this line of code "solved" my problem

ct_attributes = lt_attr.

Regards,

Sebastian

sebastianlenz85
Explorer
0 Kudos

Servus Agus,

When I add a mergefield in word (for example Z_DATE) but this field contains no data in CRM the text <<Z_DATE>> appears in Word. How did you handle megefields in Word that don't receive any data from the CRM?

Using field functions "IF" in Word don't works

Best regards,

Sebastian

Former Member
0 Kudos

Servus Agus,

When I add a mergefield in word (for example Z_DATE) but this field contains no data in CRM the text <<Z_DATE>> appears in Word. How did you handle megefields in Word that don't receive any data from the CRM?

Using field functions "IF" in Word don't works

Best regards,

Sebastian

Hello Sebastian,

I haven't tried for merge fields that have no data. But maybe you can try validate in the BAdI, if the CRM field has no values, you can replace it with value like '-' . Or another complicated way, you can try adding attribute to the BOL , and update it via BAdI order_save , and use that Z attribute instead of merge fields.

I have used that way for custom item fields that can't be handled by CRM_OFFICE_TEMPLATE_BADI.

Hope it helps.

Agus

sebastianlenz85
Explorer
0 Kudos

Hello Agus,

Thank you for your reply.

As mentioned in SAP note [1420943|https://service.sap.com/sap/support/notes/1420943] you can also use square brackets like [[[<attribute>]]] instead of mergefields. Sometimes the method get_value( ) in line 65 of CL_CRM_OI_TRANSFORM_RT->REPLACE_BADI_VALUES returns wrong value. In order to solve this issue you have to delete the attribute in the word document and insert it again. That's not very logical, but it works.

Kind regards,

Sebastian

faruk_
Explorer
0 Kudos

Hi Agus, Hi Sebastian,

Your solution helped me a lot. Thank you so much. But I have another problem. I need to display some data in word document as table. Is it possible when using CRM_OFFICE_TEMPLATE_BADI implementation and MergeFields?

sebastianlenz85
Explorer
0 Kudos

Hello Faruk,

sorry, but I didn' find any solution for this issue. From my point of view only using webservices can make this possible.

Regards,

Sebastian

faruk_
Explorer
0 Kudos

Thank you for your interest Sebastian,

I will try with webservices

Regards

Faruk

Answers (0)