cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Data service for CSV data to custom XML output

Former Member
0 Kudos

HI Experts,

I want to convert Source CSV data into XML output using SAP Data service. I have followed standard approach in Data services but its generated Standard XML output.

But I want to build custom XML output format to read CSV row data into separate Nodes and this XML file has to be in batch output file for every 100 records and has to split the XML files.

Sample Input CSV file:

Column1     Column2     Column3          column4          column5

EMP_no     Dept            Position           Emp_name     location

1000          HR               Staff               Emp_name     location

1001          HR               HR Mgr          Emp_name     location

.

.

.

.

.

.

.

1000 Rows of records.

Sample Output XML format for every 100 records.

<?xml version="1.0" encoding="utf-8"?>

<root>

  <node type ="doc" action="create">

        <location>C:\Output_files</location>

        <title>"Emp_number in column 1"</title>

        <file>"Name  in Column 2"</file>

        <versioncontrol>TRUE</versioncontrol>

        <mime>application/pdf</mime>

     

        <category name=" Emp_Name">

            <attribute name="Emp_No">Value from CSV rows</attribute>

             <attribute name="Dept">value from CSV rows</attribute>

            <attribute name="Position">Value from Column 3</attribute>

              <subitems>reapply</subitems>

        </category>

        </node>

<node type = "Doc" action="Create'>

.

.

.

This format has to built for every 100 set of rows and store the output files in separate record.

Can I use Python script using "USER_Defined"  Transform Function  for XML output with desire format? Please advise with sample code.


Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member187605
Active Contributor
0 Kudos

No need for User_defined transform.

Load your .csv into a table, number your records (row_num_gen). Build a data flow that reads 100 records from the table and produces the .xml file. Loop over the data flow until all records processed.

Use global variables for specifying extraction windows in the table and the names of the output files.

Former Member
0 Kudos

HI Dirk,

Thanks for your information.

Regards,

Victor

Answers (0)