on 10-28-2011 10:04 AM
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.