2024 Oct 29 12:13 PM
Hi, experts.
Why xml transformation sets a space or '/n' at 76 character? Is it possible to set up so that doesn't do it.
I've created a simple program:
data : lv_body TYPE xstring,
lv_trans_name TYPE string.
types : begin of struct_type,
name type xstring,
end of struct_type.
data : lt_tab TYPE TABLE OF struct_type,
ls_tab like LINE OF lt_tab.
ls_tab-name = '30313034363034373235303030393738323135583E4C4D756365745A71374E3C47533E3931454531303C47533E39322B457A2F743153736732306A656A733276426A2F49786F68373243787A304A2F684B7930554431612B6B773D'.
insert ls_tab into table lt_tab.
ls_tab-name = '3031303436303437323530303039373832313550385227584130267144676C3C47533E3931454531303C47533E39326A4A687830364A347A5574555A44565542732B4A6E344F486E536551765044586D79313366725376646B553D'.
insert ls_tab into table lt_tab.
lv_trans_name = 'ZVA_TEST'.
TRY.
CALL TRANSFORMATION (lv_trans_name)
SOURCE root = lt_tab
RESULT XML lv_body.
ENDTRY.
And at the end i'm having
Spaces are always at 76 character.
2024 Oct 29 12:53 PM
I'd like to test it. Could you paste the transformation code as text please?
2024 Oct 29 1:06 PM
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<FieldCodeMarkHeader>
<tt:loop ref="ROOT">
<FieldCodeMark tt:value-ref="NAME"/>
</tt:loop>
</FieldCodeMarkHeader>
</tt:template>
</tt:transform>
2024 Oct 29 12:56 PM
It's a newline character U+000A which is ignored by the standard MIME specification: "The encoded output stream must be represented in lines of no more than 76 characters each. All line breaks or other characters not found in Table 1 must be ignored by decoding software."
2024 Oct 29 1:26 PM
So why i don't see string after 76th at new line, it's just space
2024 Oct 29 2:07 PM
It's not related. The XML browser renders these "space-like" characters like one space.
2024 Oct 30 9:06 AM - edited 2024 Oct 30 9:07 AM
2024 Oct 30 9:32 AM
I don't see any mention of customizing in the ABAP documentation and in the SAP notes. So go for a REPLACE in ABAP or tt:call-method in ST.
2024 Oct 30 2:31 PM - edited 2024 Oct 30 2:32 PM
I've tried this, but it's doesn't work, i'm still have a space at 76th. I think it adds after transformation is done.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:variable name="result"/>
<tt:variable name="result2"/>
<tt:template>
<FieldCodeMarkHeader>
<tt:loop ref="ROOT">
<tt:call-method class="ZVA_XMLCONVERTER_BASE64" s-name="CONVERT">
<tt:with-parameter name="INP_STR" ref="name"/>
<tt:with-parameter name="OUT_STR" var="result"/>
</tt:call-method>
<FieldCodeMark>
<tt:write var="result"/>
</FieldCodeMark>
</tt:loop>
</FieldCodeMarkHeader>
</tt:template>
</tt:transform>
method CONVERT.
data : lv_str type xstring,
lv_str2 type xstring.
lv_str = '0A'.
lv_str2 = ''.
out_str = inp_str.
replace all OCCURRENCES OF lv_str in out_str WITH lv_str2 in BYTE MODE.
endmethod.
I have another question : Can i see how the RESULT XML lv_body is changing during the debug inside transformation?
2024 Oct 30 3:49 PM - edited 2024 Oct 30 4:03 PM
Return a string, not xstring.
You may use the AUTO tab and also see the variable value in the calling program with this syntax: (programname)variablename.
2024 Oct 31 9:23 AM - edited 2024 Oct 31 9:36 AM
Ok, it works with
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:variable name="result"/>
<tt:template>
<FieldCodeMarkHeader>
<tt:loop ref="ROOT">
<tt:call-method class="CL_HTTP_UTILITY" s-name="IF_HTTP_UTILITY~ENCODE_X_BASE64">
<tt:with-parameter name="UNENCODED" ref="name"/>
<tt:with-parameter name="ENCODED" var="result"/>
</tt:call-method>
<FieldCodeMark>
<tt:write var="result"/>
</FieldCodeMark>
</tt:loop>
</FieldCodeMarkHeader>
</tt:template>
</tt:transform>
But what to do with deserialization, can i check which type of transformation (serialization/deserialization ) is called and then call method with smth like if/else?
2024 Oct 30 9:37 AM
I looked again at the specifications, in fact U+000A doesn't seem to be very standard, I'm curious why SAP has decided to insert this character.