cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate field names in File content conversion

Former Member
0 Kudos

Hi,

I need some details for csv to xml file conversion.I have configured the file content conversion adapter for these conversions.In source CSV file we will receive below details in single line.

0020000001000 0020000002000 0020000003000 0020000004000

Now i can successfully generate

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

- <ns:MT_GLMast_out xmlns:ns="http://sap.com/PI/GLMast">

- <GLMasterData>

- <GLMAST>

<Customer1>0020000201000</Customer1>

<Customer2>0020000200000</Customer2>

<Customer3>0020000199000</Customer3>

<Customer4>0020000198000</Customer4>

</GLMAST>

</GLMasterData>

</ns:MT_GLMast_out>

with following parameters

GLMAST.fieldSeparator ,

GLMAST.fieldNames Customer1,Customer2,Customer3,Customer4

GLMAST.endSeparator 'nl'

Now the issue is customer wants to send 3000 customer number in single file.How to maintain the parameter to duplicate filednames just customer instead of customer1,customer2,customer3 etc...

<Customer>0020000201000</Customer>

<Customer>0020000200000</Customer>

<Customer>0020000199000</Customer>

<Customer>0020000198000</Customer>

This can be done if customer sends file like one customer number in one line.please help me how to process multiple customer number in single file separated with comma.

Thanks,

Vijay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

For this what you can do is, create the source and target data types as shown below

Source Data Type

<DTO_Customer>
 <Records> 0..unbounded
   <Customers> </Customers>0..1
 </Records>
</DTO_Customer>

Target Data Type

<DTI_Customer>
 <Records> 0..1
   <Customer> </Customer> 0..unbounded
 </Records>
</DTI_Customer>

Now since your data will come in a single string therefore do the FCC in sender channel as shown below

Records.fieldNames = Customers
Records.fieldSeparator = 'nl'
ignoreRecordsetName = true

So by doing this you will get the data into XI mapping in as single string. Now you need to write an UDF which will split this string into individual customers based on your delimiter in the string.

Now map the output of this UDF to <Customer> field.

You may need to do some other small fixes accordingly.

I hope this will solve your problem.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi.

I guess the Sarvesh Solution is only way.In addition you can use this UDF.

UDF : By Context

Parameters :

List i.e (1055121,5454512,54878)

delimiter i.e ","


 for (int i = 0; i < List.length ; i++) {
    String[] val = List<i>.split(delimiter[0]);
    for ( int j = 0; j < val.length ; j++) {
      result.addValue(val[j]);
    }    
}

source > UDF-- target.

Former Member
0 Kudos

We can increase the performance just by removing one of the "for" loop from the code..

String[] val = List[0].split(delimiter[0]);

for (int i = 0; i < val.length; i++)
result.addValue(val<i>);

former_member192295
Active Contributor
0 Kudos

Hi,

We can implement your required through below changes

Changes occurence from 0..1 to 0...unbound at record set and field level. You problem will be sort out easily.

i.e.,

<GLMAST>---0...unbound

<Field>---0...unbound.

I hope now clear.