Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

Space at 76th character of xml transformation in base64.

BergOff
Explorer
0 Likes
2,853

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

1000000163.jpg

ā€ƒSpaces are always at 76 character.

11 REPLIES 11
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,827

I'd like to test it. Could you paste the transformation code as text please?

Read only

2,817

<?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>

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,826

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."

Read only

0 Likes
2,811

So why i don't see string after 76th at new line, it's just space

Read only

0 Likes
2,781

It's not related. The XML browser renders these "space-like" characters like one space.

Read only

0 Likes
2,713

So it's not possible to set up to not put  space after 76th?

Read only

0 Likes
2,706

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.

Read only

0 Likes
2,682

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.

 

 

test.jpg

I have another question : Can i see how the RESULT XML lv_body is changing during the  debug inside transformation?

Read only

0 Likes
2,676

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.

Read only

0 Likes
2,613

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?

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,705

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.