However, one customer complains that in the generated word document, the date format is not displayed as they expected.
They hope the date is displayed as "2012.11.28" instead.
In the previous document the architecture about the web service call in document scenario is briefing introduced. The function module generated by office integration framework will be called and the web service response to be merged into word document is contained in importing parameter output of the function module.
The date field in response structure has ABAP type D(8). Although there is available BAdI definition which enables customer to change the content of web service response, this BAdI does not work for this very case, since the field displayed in below screenshot will not be directly used to merge with the document template.
Instead, it is the serialized xml string ( handled by another automatically generated transformation ) which will be merged into the word document and finally displayed to end user.
After transformation, we could observe the value of ABAP type D(8), 20121128, has been transformed to 2012-11-28.
according to sap help, this is working as designed:
Since there is no such BAdI definition provided by SAP which could allow changes on the transformed xml payload, it is necessary to put the adaptation on the response stream into a proper place with the modification-free approach.
1. use SE24 to open class CL_CRM_OI_RT, click Class->Enhance:
Create anew class enhancement implementation:
select method CALL_WS and insert a new post-method for it:
Once done, you could observe a tab in column "PostExit" for method CALL_WS. Click on it and you will navigate to source code editor.
2. Implement the post-exit method.
The signature of method CALL_WS contains three changing parameters:
ev_data: the string format of xml response. We need to change the date format there.
er_payload: the reference pointing to ABAP response. We do not need to change it.
ex_payload: the xstring format of xml response. We need to change the date format there.
the complete source code of transformation could be found in attachment.
Here just some important codes:
Here I develop a new transformation ztime_convert to do the time format transformation:
The implementation of GET_NEW_DATE is very simple:
After that we could test in the runtime and observed the post exit get called, once the execution of CALL_WS method finishes:
And in the final merged word document, the format is now YYYY.MM.DD:
If the default transformation rule listed in screenshot above with title "Value Representation in XML" is not expected by you, you could change the transformed field content with this solution. We didn't do any modifications on standard code, so the change will survive after system upgrade or patch applied.
Although in theory it is possible to change the implementation of automatically generated transformation which could fulfill the same result,
However it is always not recommended to do manual changes on any stuff which are automatically generated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |