cancel
Showing results for 
Search instead for 
Did you mean: 

Problems in fileContentConversion

Former Member
0 Kudos

Hi experts,

in a sender communication channel I receive a flat file like this:

UNA:+.? 'UNB+UNOC:2+I20114T:01'DTM+137:20150206:102'RFF+ON:5100001679'....

Segment are UNA, UNB, DTM, RFF....

They comes in a single line separated by ' (apostrophe).

If I use UNA.endSeparator= '

            UNB.endSeparator= '

             ......

it throws me an error, it seems that system doesn't recognize the ' as endSeparator,

How to convert this?

Thanks

Fabio

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Problem not solvable.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Fabio

The file you have posted looks like a EDI file or an eancom file.

Normally those files are converted to xml using see burger adapter in SAP PI.

Using FCC , it is almost impossible to generate the xml because this will have more than 4 levels of hierarchy in the structure.

Thanks,

Indrajit

Former Member
0 Kudos

Hi Raghu,

thank you for helping me.

A strange things happens:

Every separator that I use is not recognized by the system as endseparator.

It seems that system needs always a new line to separate segments.

Fabio

RaghuVamseedhar
Active Contributor
0 Kudos

Fabio,

You are welcome. Please implement FCC exactly as described in my above response and let us know the results.

Former Member
0 Kudos

Hi Raghu,

I tried:

' works as fieldSeparator, but not as endSeparator.

Fabio

RaghuVamseedhar
Active Contributor
0 Kudos

Fabio,

" ' works as fieldSeparator, but not as endSeparator. "

Please use below FCC parameters. This will split input file for each ' and put it in an element (eachFiled).

NameA.fieldSeparator     '

NameA.fieldNames     eachField

NameA.endSeparator     'nl'

Output of FCC


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

<ns:Document_Name xmlns:ns="Document_Namespace">

  <ns:Reocrdset_Name xmlns:ns="Recordset_Namepace">

  <NameA>

  <eachField>UNA:+.? </eachField>

  </NameA>

  <NameA>

  <eachField>UNB+UNOC:2+I20114T:01</eachField>

  </NameA>

  <NameA>

  <eachField>DTM+137:20150206:102</eachField>

  </NameA>

  <NameA>

  <eachField>RFF+ON:5100001679</eachField>

  </NameA>

  </ns:Reocrdset_Name>

</ns:Document_Name>

In message mapping, map eachField element to target, you can use startsWith function to check if it's start with UNA, UNB.

Former Member
0 Kudos

Hi Raghu,

I'm not sure I understood.

If I specify field separator then I've to specify every field name, not a single field name.

Am I wrong?

Problem is that number of segment to come is variable.

Fabio

RaghuVamseedhar
Active Contributor
0 Kudos

Fabio,

NameA.fieldNames     eachField OR

NameA.fieldNames     asdf_anything.

It is a single field.

In message mapping, map "eachField" OR "asdf_anything" element to target, you can use startsWith function to check if it's start with UNA, UNB.


If it does not work.

Read each line into element of FCC and perform split in message mapping.

Former Member
0 Kudos

Hi Raghu,

my input file is:

UNA:+.? 'UNB+UNOC:2+I20114T:01+05113870967T:ZZZ+150210:1631+35315+XX:XX+++0++0'UNH+35315+ORDRSP:D:96A:UN'BGM+231+8103097714'DTM+137:20150206:102'RFF+ON:5100001679'DTM+2:20150129:102'NAD+SU+F021550::92'NAD+BY+DE11::92'NAD+DP+0000100068::92++NIVOLA STYLE SRL "B"+VIA NUOVA CIRCONVALLAZIONE 27+RIMINI++47900+IT'LIN+10+5+8019227214888:EN'PIA+1+49040663A:IN'PIA+1+2148800:SA'QTY+21:10:PCE'QTY+113:10:PCE'DTM+2:20150129'RFF+ON:5100001679:00001'SCC+1'QTY+113:10:PCE'UNS+S'UNT+19+35315'UNZ+1+35315'

all in a single line.

I have created this structure:

DT_PurchaseOrderResponse_Pirelli

      RecordSet    0..1

            DetailRecord     0....unbounded

                     DataString   0....1

In channel I have specified:

If I start communication channel it raise an error:

Conversion of file content to XML failed at position 0: java.lang.Exception: ERROR converting document line no. 1 according to structure 'DetailRecord':java.lang.Exception: ERROR in configuration / structure 'DetailRecord.': More elements in file csv structure than field names specified!


What I have done wrong?

RaghuVamseedhar
Active Contributor
0 Kudos

Fabio,

Can you please try

NameA.fieldSeparator     'nl'

NameA.fieldNames     DataString

NameA.endSeparator     '0x03'

This one will read each line into DataString element (I can see there is only one line in input file).

NameA.endSeparator 0x03 is End of File, if it does not work, try 'nl' OR '0x0A' (Line Feed).

Former Member
0 Kudos

Hi,

now is like that:

- <RecordSet>

- <DetailRecord>

<DataString>UNA:+.?</DataString>

</DetailRecord>

- <DetailRecord>

<DataString>UNB+UNOC:2+I20114T:01+05113870967T:ZZZ+150218:1412+37731+XX:XX+++0++0</DataString>

</DetailRecord>

- <DetailRecord>

<DataString>UNH+37731+ORDRSP:D:96A:UN</DataString>

</DetailRecord>

- <DetailRecord>

<DataString>BGM+231+8103097714</DataString>

</DetailRecord>

- <DetailRecord>

<DataString>DTM+137:20150206:102</DataString>

</DetailRecord>


I I think it works, but my next question is:

I I have to map DataString to an IDOC with multiple segments with different occurrences.

How is it possible?



RaghuVamseedhar
Active Contributor
0 Kudos

Fabio,

In message mapping, map DataString element to target, you can use startsWith function to check if it's start with UNA, UNB.

You can write UDF (single input multiple output UDF) if transformation logic can not be archived using standard functions.

Former Member
0 Kudos

Hi Raghu,

thanks.

For me is not clear how to map field DataString that comes in unbounded Detail Record to for example IDOC header segment EDI_DC40 that comes with occurrence 1.

For example:

I have to map a field of UNH segment (that comes in the third occurrence of DetailRecord) with EDI_DC40, but if I try PI reads always the first occurrence of DetailRecord.

Any hints?

Thanks

Fabio

RaghuVamseedhar
Active Contributor
0 Kudos

Fabio,

First let's be sure that all FCC parameters are set correctly.

1)

As shown in attached screenshots, create an input file, FCC and let us know, you got same output as shown in attachments.

2)

Then,

change the input file. Replace all , with '.

change FCC. NameA.fieldSeparator     '     OR     '0x27'

Let us know, the output.

3)

If above solution does not work. Then read entire line into an element of XML and the write a UDF in message mapping to split string. I can guide you with splitting logic.

NameA.fieldSeparator     'nl'

NameA.fieldNames     eachLine

NameA.endSeparator     'nl'

Former Member
0 Kudos

Hi Fabio,

Use key field as UNA, UNB, DTM, RFF....

and endSeparator as '0x27'(including the quotation marks).

Regards,

Soumyadip

Former Member
0 Kudos

Hi Soumyadip,

thanks but it doesn't work.

Also if I use a simple example file:

UNA:+.? 'UNB+UNOC'

with endSeparator = '0x27'

and keyFields

it doesn't work.

error is ='converting document line no. 1 according to structure 'UNA':java.lang.Exception: ERROR in configuration / structure 'UNA.': More elements in file csv structure than field names specified!'

It seems that system thinks that there only UNA structure.

Fabio

Former Member
0 Kudos

Hi Fabio,

If I consider that flat file contain fieldSeparator as " + " and endSeparator as " ' " then there is " : " symbol coming after UNA key field.

Probably that is the reason why error is coming.

Regards,

Soumyadip

giridhar_vegi
Participant
0 Kudos

Hi Fabio,

               Use the parameter node.addintionalLastFields if you are having the additional fields in the input file and make the value as ignore. hope this will help to you

Thanks

Giridhar

Former Member
0 Kudos

Hi,

I've tried with a test file:

UNA12345'UNB+UNOC'

but still no luck

Former Member
0 Kudos

Hi Fabio,

Have you tried with test file like UNA+12345'UNB+UNOC' ?

Regards,

Soumyadip

Former Member
0 Kudos

Hi boni,

  Which version of PI you are using?  If it is older version then please use hexadecimal value of ' for separator.

thanks

Former Member
0 Kudos

Hi,

we are on PI 7.0.

Can you give me example?

thanks

Former Member
0 Kudos

UNA.endSeparator= 27

            UNB.endSeparator= 27.

Else if you know the exact length of the each field, use fieldFixedlength.

Former Member
0 Kudos

Hi Samir,

thanks but it doesn't work.

I have to change file encoding?

Unfortunately fields lengths are not fixed.

Fabio