cancel
Showing results for 
Search instead for 
Did you mean: 

How to read a file which has header and without header

former_member192798
Active Contributor
0 Kudos

Hi,

I have a file to file scenario wherein there are txt files in the source system, some of which has header and some without header.

How does the sender adapter dynamically identify a file with header and without header.

I knew that File content Conversion in the sender adapter with "Recordsets per message = 1" can read the header. But how to handle dynamically.

Thanks in advance for suggestions and advice.

Regards.

Praveen

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member192798
Active Contributor
0 Kudos

Hi,

Let me give a more clear picture:-

One of my file which has header and the corresponding values is listed hereunder:

PERNR;KID;PNALT;NACHN;NAME2;VORNA;TITEL;TITL2 and so on.....

;1200;1200;Angus;; and so on.........

Other file which has no header but only values in it:-

1200;1200;;Werner;Angus and so on.......

The structure remains same for all the files. The only difference is that some of the file has header in it and some without header. The Message Type is mentioned hereunder:-

DT_LegacyEmployee (Category - Complex Type)

Employees (Category - Element, Occurence - 1)

Employee (Categroy - Element, Type - DT_LegacyEmployee_Row, Occurence - 0...unbounded)

PERNR

KID

PNALT

NACHN

NAME2 and so on......

I read the file in record row. The file conversion parameters in the file sender adapter are mentioned hereunder:-

Document Name - MT_LegacyEmployee

Document Namespace - http://abc.com/xi

Recordset Name - Employees

Rescordset Structure - Employee,*

Recordsets per Message - 1

Key Field Type - String (Case Sensitive)

Employee.fieldSeparator - ;

Employee.endSeparator - 'nl'

Employee.fieldNames - PERNR,KID,PNALT,NACHN,NAME2,VORNA,TITEL,TITL2 and so on........

How do we dynamically identify whether the file has header or not. Even if the file has header or without header, the file needs to be picked and transferred to the target system. Kindly clarify.

Regards.

Praveen

Former Member
0 Kudos

Hi,

Create the flat data type as follows and read the data in single string.

<Record>

<Row>

</Row>

</Record>

Thanks,

Prateek

Former Member
0 Kudos

Hi Praveen,

If you are picking up the file with NameA.keyFieldValue

then if you have specified a key field for header.

If the header is there the record will get picked up if not then there will not be any error. Only in you mapping, it should not be a mandatory segment.

Regards

Vijaya

Shabarish_Nair
Active Contributor
0 Kudos

Did you try reading the file in a RECORD-ROW style ?

I guess that should solve the problem. But then you will have to involve a different logic for your mapping if any .

Ref: /people/sravya.talanki2/blog/2005/11/29/night-mare-processing-huge-files-in-sap-xi