Application Development 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: 

Space at 76th character of xml transformation in base64.

BergOff
Explorer
0 Kudos
623

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

Sandra_Rossi
Active Contributor
0 Kudos
597

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

587

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

Sandra_Rossi
Active Contributor
0 Kudos
596

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

0 Kudos
581

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

0 Kudos
551

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

0 Kudos
483

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

0 Kudos
476

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.

0 Kudos
452

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?

0 Kudos
446

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.

0 Kudos
383

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?

Sandra_Rossi
Active Contributor
0 Kudos
475

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.