Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

ABAP to XML Simple Transformation - only one line of a string value is passed

$
0
0

Hi,

 

The goal of the extract program that I'm currently developing is to extract employee photos from ArchiveLink and corresponding data (e.g. name and date of birth), convert to XML and download it. I have created a transformation program to follow the template of the system that will utilize the XML file. I pass an internal table containing the employee data and the photo converted from binary into base64 string in a string field to the transformation program--like...

 

types: begin of ty_person,

             firstname type pa0002-vorna,

             lastname type pa0002-nachn,

             birthdate type pa0002-gbdat,

             photo type string,

          end of ty_person.

 

data: gt_data type standard table of ty_person.

 

The issue that I'm encountering at the moment is that when the internal table gt_data has more than 1 record, the resulting XML file doesn't seem to have the contents of field photo from record 2 onwards. Only record 1's data is complete and for the succeeding records, only firstname, lastname and birthdate shows. The resulting XML when parsed looks like this--

 

<Employees count = "4">

     <EmployeeData>

          <FirstName>Joe</FirstName>

          <LastName>Bloggs</LastName>         

          <Birthdate>1960-01-01</Birthdate>

           <Photo>  very long string of data here                                                                                                                   </Photo>

     </EmployeeData>

     <EmployeeData>

          <FirstName>John</FirstName>

          <LastName>Doe</LastName>         

          <Birthdate>1976-03-26</Birthdate>

          <Photo>  blank                                                                                                                                                   </Photo>

     </EmployeeData>

     <EmployeeData>

          <FirstName>Jane</FirstName>

          <LastName>Doe</LastName>         

          <Birthdate>1978-03-31</Birthdate>

          <Photo>  blank                                                                                                                                                   </Photo>

     </EmployeeData>

     <EmployeeData>

          <FirstName>Test</FirstName>

          <LastName>Person</LastName>         

          <Birthdate>1970-10-18</Birthdate>

          <Photo>  blank                                                                                                                                                   </Photo>

     </EmployeeData>

</Employees>

 

My transformation program is coded like this--

 

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

<tt:root name="EMPDATA"/>

  <tt:template>

      <tt:loop ref=".EMPDATA" name="line">
        <FirstName>
          <tt:value ref="$line.firstname" />
        </FirstName>
        <LastName>
          <tt:value ref="$line.lastname" />
        </LastName>

        <Birthdate>
          <tt:value ref="$line.birthdate" />
        </Birthdate>

        <Photo>
          <tt:value ref="$line.photo" />
        </Photo>

      </tt:loop>
  </tt:template>

</tt:transform>

 

I am certain that PHOTO field of records 2-4 is not empty and converted properly into base64. I debugged and can confirm that $line.photo is not empty for records 2-4. Does anyone have a clue why the value of PHOTO field only works for the first record and what can be done to correct the issue? Do Simple Transformations have limitations on string values?

 

Your help is very much appreciated!

 

Cheers,

Jocelyn


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>