cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to pick a flat flie of such structure?

Former Member
0 Kudos

Hello All,

I have a scenario where I need to pick up flat file from a FTP server and pass to ECC as IDOC:

I am wondering is it possible to pick up from a file format as below:

Header1

Item1

Item2

Item3

Header2

Item1

Item2

Item3

and so on..

How can I create DT and FCC parameters for the above structure?

Thanks

Rajeev

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi!

You shoud create a message type in enterprise service builder which has the following structure

MT_Message

--RECORDSET (0..unbounded)

-


HEADER (0..1)

-


field1

...

-


fieldn

-


ITEM (0..unbounded)

-


field1

..

-


fieldn

In Your Sender communicaion channel set the Message protocol to content conversion.

Set the following parameters on "Content Conversion" tab:

Document name : MT_Message (the file adatper will transform the flat file into this message type )

Document namespace (the namespace that You've defined the message above)

Recordset name : RECORDSET (in our example - generaly the structure that is repeating in file and represented by a structure node in xml message and contains the HEADER and the ITEM structures)

Recordset Structure : HEADER,1,ITEM,* (this means in one adjacent data block in the flat file the header structure can occure once and the item structure can occure n-times)

Key Field Name: the name of the fields which binds the header and the item records (in databese aspect the key field in header and foreign key in item, the field that are the same value and meaning in header and items as well )

After all You have to define the recordset structure parameters for recordset srtructure HEADER and also for ITEM.

eg

HEADER.fieldFixedLengths

HEADER.fieldNames

HEADER.endSeparator

...and so on

ITEM.fieldFixedLengths

ITEM.fieldNames

ITEM.endSeparator

For possible values of recordset structure parameters see:

[http://help.sap.com/saphelp_nwpi71/helpdata/en/44/655453b48a4ddfe10000000a1553f7/frameset.htm]

Edited by: Andras Heger on Feb 2, 2010 11:26 PM

Edited by: Andras Heger on Feb 2, 2010 11:26 PM

Edited by: Andras Heger on Feb 2, 2010 11:29 PM

Former Member
0 Kudos

Andras,

that MT Structure will certainly work for;

HEADER

ITEM1

ITEM2

ITEM(n)

But the format described appears repeating, with the file made up of multiple occurences of header. Unless the file was appended too and had a clearly recognisable header row, how could one determine when a new header row begins if you've specified;

Recordset Structure : HEADER,1,ITEM,* ??

Former Member
0 Kudos

Hi Jason!

The record structuse identifies clearly wether it's a HEADER or an ITEM. During the file processing the first node at in converted XML will be the RECORDSET then the folloving structure node the HEADER then come the ITEM nodes. Plus the key field parameter will bind a HEADER to the corresponding ITEMs in one certain RECORDSET .

When an ITEM is followed by a HEADER then a new RECODSET node will be generated. And a HEADER as well..and so on..

As I wrote

"Recordset name : RECORDSET (in our example - generaly the structure that is repeating in file and represented by a structure node in xml message and contains the HEADER and the ITEM structures)

Recordset Structure : HEADER,1,ITEM,* (this means in one adjacent data block in the flat file the header structure can occure once and the item structure can occure n-times)"

The recordset structure is not equals the file structure. If I want to represent a the xml structure in flat file that will be the following:

header_field11,header_field12,...header_field1n;

item_field111,item_field112,...item_field11n;

...

item_field1n1,item_field1n2,...item_field1mn;

header_field21,header_field22,...header_field2n;

item_field211,item_field212,...item_field21n;

...

item_fieldkn1,item_fieldkn2,...item_fieldkmn;

and so on

In this case a recondset is for example the following

header_field21,header_field22,...header_field2n;

item_field211,item_field212,...item_field21n;

...

item_fieldkn1,item_fieldkn2,...item_fieldkmn;

This structure is definetly the same that the mentioned rule describes: "Recordset Structure : HEADER,1,ITEM,* "

And again: the KeyField Name is binding the corresponding header and items...

Regards A Héger

Edited by: Andras Heger on Feb 3, 2010 10:18 AM

Former Member
0 Kudos

So the important aspect of the recordset structure is the notion of the key field. In that if the following file was read for conversion;


keyField1,headerDataA1,headerDataA1,headerDataA1,headerDataA1
keyField1,itemDataA1,itemDataA1,itemDataA1,itemDataA1,itemDataA1,itemDataA1
keyField1,itemDataA2,itemDataA2,itemDataA2,itemDataA2,itemDataA2,itemDataA2
keyField1,itemDataA3,itemDataA3,itemDataA3,itemDataA3,itemDataA3,itemDataA3
keyField1,itemDataA4,itemDataA4,itemDataA4,itemDataA4,itemDataA4,itemDataA4
keyField2,headerDataB1,headerDataB1,headerDataB1,headerDataB1
keyField2,itemDataB1,itemDataB1,itemDataB1,itemDataB1,itemDataB1,itemDataB1
keyField2,itemDataB2,itemDataB2,itemDataB2,itemDataB2,itemDataB2,itemDataB2
keyField2,itemDataB3,itemDataB3,itemDataB3,itemDataB3,itemDataB3,itemDataB3
keyField3,headerDataC1,headerDataC1,headerDataC1,headerDataC1
keyField3,itemDataC1,itemDataC1,itemDataC1,itemDataC1,itemDataC1,itemDataC1
keyField3,itemDataC2,itemDataC2,itemDataC2,itemDataC2,itemDataC2,itemDataC2
keyField3,itemDataC3,itemDataC3,itemDataC3,itemDataC3,itemDataC3,itemDataC3
keyField3,itemDataC4,itemDataC4,itemDataC4,itemDataC4,itemDataC4,itemDataC4

It becomes the change in the keyfield which generates the new recordset with a new header entry and N lines of items.

Former Member
0 Kudos

Hi!

Partly You've right.

The value of the key field and the changing of structure are both controlling the "flat file to XML" conversion in the file adapter.

As we can see it below

Original flat file

keyField1,headerDataA1,headerDataA1,headerDataA1,headerDataA1

keyField1,itemDataA1,itemDataA1,itemDataA1,itemDataA1,itemDataA1,itemDataA1

keyField1,itemDataA2,itemDataA2,itemDataA2,itemDataA2,itemDataA2,itemDataA2

keyField1,itemDataA3,itemDataA3,itemDataA3,itemDataA3,itemDataA3,itemDataA3

keyField1,itemDataA4,itemDataA4,itemDataA4,itemDataA4,itemDataA4,itemDataA4

keyField2,headerDataB1,headerDataB1,headerDataB1,headerDataB1

keyField2,itemDataB1,itemDataB1,itemDataB1,itemDataB1,itemDataB1,itemDataB1

keyField2,itemDataB2,itemDataB2,itemDataB2,itemDataB2,itemDataB2,itemDataB2

keyField2,itemDataB3,itemDataB3,itemDataB3,itemDataB3,itemDataB3,itemDataB3

keyField3,headerDataC1,headerDataC1,headerDataC1,headerDataC1

keyField3,itemDataC1,itemDataC1,itemDataC1,itemDataC1,itemDataC1,itemDataC1

keyField3,itemDataC2,itemDataC2,itemDataC2,itemDataC2,itemDataC2,itemDataC2

keyField3,itemDataC3,itemDataC3,itemDataC3,itemDataC3,itemDataC3,itemDataC3

keyField3,itemDataC4,itemDataC4,itemDataC4,itemDataC4,itemDataC4,itemDataC4

Transformed output

Regards A Héger

Former Member
0 Kudos

The changing of structure will signify that a new header line has occured? I'm going to have to setup a test and get back to you

I certainly understand that a keyfield change indicates a new block of data, as to how a structure change is used thereby means that PI compares the read line of data to that of expected structure and then maps accordingly. I assumed that when the defined the recordset structure as say;

HEADER,1,ITEMS,*

that PI would then read the first line as the header and then ALL following lines as ITEMS.

Former Member
0 Kudos

Hi Jason!

Let's analyze these rules:

Recordset name : RECORDSET

Recordset Structure : HEADER,1,ITEM,*

The Recordset Stucture rule describes the RECORDSET structure node. This means for PI the RECORDSET sutructure can contain only one HEADER and N ITEM subnodes.If the file adapter founds a new record which is adjacent to HEADER structure it will mean that it must append a new RECORDSET structure node (this event is the context change) and the newly found HEADER must append under this new RECORDSET. If after this the adapter founds an ITEM, it has to analize the keyfield of that. If it has been already created a HEADER or ITEM in XML that contains the same keyfield then the actual ITEM has to append under that RECORDSET as a substructure node.Else it has to create a new RECORDSET sutructure node.If the adapter found a new ITEM first we have to thrust in that it will found the corresponding HEADER later in the file. If it wont happen that causes an error...

It can be easily imagine that could exist a file where all the headers sent firs and after the headers are appended all the possible items....

But fell free to try the two possibilities below for recordset structure rules

-Recordset Structure : HEADER,1,ITEM,*

-Recordset Structure : HEADER,,ITEM,

I can tell that I've alredy completed a project where the file structure was the same as in our example and XML structure as well .And "Recordset Structure : HEADER,1,ITEM,*" worked for me for this type of parsing ...

Regard A Héger

Answers (2)

Answers (2)

JaganMohan
Participant
0 Kudos

Dear Rajeev,

Please see the following blogs it may help you in this regard.

/people/venkataramanan.parameswaran/blog/2006/12/12/java-mapping-to-handle-flat-files-in-sap-xi

https://wiki.sdn.sap.com/wiki/display/Snippets/Convert%20flat%20XML%20file%20to%20nested%20using%20X...

/people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter

Like this there are lot of details availbe in SDN. Please search.

Regards,

JP.

sunil_singh13
Active Contributor
0 Kudos

Hi Rajeev,

If you have PI 7.1 (Ehp1) then there is a standard module available to convert the flat file into Idoc.

Thanks,

Sunil Singh