on 06-08-2012 4:48 AM
We are using PI 7.1 and i have an attachment that I can access in my ABAP mapping. I am able to get the content of my attachment using the IF_MAPPING_ATTACHMENTS-get_attachment method.
Unfortunately the content retrieved is 'XSTRING' type and i have tried all possible options (like below) but I cannot convert the xstring to string? Any ideas? My attachment content is just single line 'XXX'
* DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
* conv = CL_ABAP_CONV_IN_CE=>CREATE( input = string ).
* conv->READ( importing data = lv_content).
I was able to read the attachment once I check the 'read attachment' box in operation mapping
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I just checked that I am using exactly identical code to the one you menioned, to convert xstring to string in one of my scenarios. For your code below:
DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
conv = CL_ABAP_CONV_IN_CE=>CREATE( input = string ).
conv->READ( importing data = lv_content).
Simply make sure that "string" variable that you pass to the CREATE() method is of type xstring and lv_content that you pass to READ() method is of type string.
By the way, were you really able to name your variable "string"?
Regards,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry ,I didn't name my variable String...
the only explanation seems to be that IF_MAPPING_ATTACHMENTS-get_attachment does not work correctly
When I used SCMS_XSTRING_TO_BINARY FM, the Output length I got was '1'... something tells me that the "content" retrieved from Get_Attachment does not work (though the content type is perfect). My content type is text/plain.
I was able to use the inbound proxy to read this attachment, but the fact that I am not able to do this in ABAP mapping bothers me. Any other ideas?
Hi Krish,
That solution that you point, should work. You cant try to copy the HR_KR_XSTRING_TO_STRING from R/3 system, but finally it uses CL_ABAP_CONV_IN_CE too.
Try to improve your code like that:
DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
LOC_XSTRING TYPE XSTRING,
LOC_STRING TYPE STRING.
* Convert XString to String
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = LOC_XSTRING
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = LOC_CONV.
TRY.
CALL METHOD LOC_CONV->READ
IMPORTING
DATA = LOC_STRING.
CATCH CX_SY_CONVERSION_CODEPAGE.
*-- Should ignore errors in code conversions
CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
*-- Should ignore errors in code conversions
CATCH CX_PARAMETER_INVALID_TYPE.
CATCH CX_PARAMETER_INVALID_RANGE.
ENDTRY.
Do you obtain any exception with this code?, could you say us what exception is?
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.