cancel
Showing results for 
Search instead for 
Did you mean: 

File Content Conversion - No Key Field in Detail Structure

vijay_ravindran
Explorer
0 Kudos

Hi,

     Background - We are receiving a Flat File from an external system which contains Header, Detail and Trailer records. Detail Records are fixed length comma separated. See Sample data below -

HDRXXXYYY12345

MM8100422373,M631530008  ,1530008,031615,17 

MN8100424411,M631530008  ,1530008,031615,22 

XY8100422373,M631530008  ,1530008,031615,17 

TRLXXZZZ4321

First line is the header (HDR - identifier) and the last line is trailer (TRL - identifier). As you can see there is no identifier for Detail records.

And so, it is throwing an error in the File Content Conversion of this file. Is there any way to implement the logic that if identifier is not equal to 'HDR' or 'TRL', it should be detail record?

Does anyone have idea on how to segregate the data into Header, Details and Trailer records? Is there any way to achieve this using java coding before message processing?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vijay,

It is possible through Graphical mapping itself take the whole file records as string and maintain mapping as per your requirement please find the attached images to achieve this. Use logic based on Fixed length of your fields use substring.

Regards,

Suhale Shaik.

former_member355445
Participant
0 Kudos

This message was moderated.

Answers (4)

Answers (4)

RaghuVamseedhar
Active Contributor
0 Kudos

Vijay,

Please try below approach (FCC + Graphical mapping)

former_member183816
Active Participant
0 Kudos

Converting File Content in the Sender Adapter - SAP XI: Runtime - SAP Library


Key Field Name

If you specified a variable number of substructures for Recordset Structure, in other words, at least one substructure has the value ‘*’, then the substructures must be identified by the parser from their content. This means that a key field must be set with different constants for the substructures. You must specify a key field and the field name must occur in all substructure


As per this documentation, your structure has more than one substructure (*) for details, so you have to use key in this case. That's why you are getting error.


Either go for custome module indicated by or substring your details line in another mapping as suggested by


I will go for Suhale's option as it requires less effort and no deployment and custom coding.


I never tried || (or operator) while defining keyfield value here,


  1. NameA.keyFieldValue

Specify the value of the key field for the structure. This specification is mandatory.

It's worth a try if somehow you can apply all possible keyFieldValue for detail lines for your file.

Former Member
0 Kudos

Hi Vijay,

IF you have read and write access to NFS folders of your PI system(NFS is simple, FTP is a bit slow and complex), you can have a two round processing.

round 1: process flat file with java map to add a key to Details and output to specific NFS folder.

round 2: process files with keys added from NFS folder with FCC.

Java map is very simple, you can use BufferedReader to read each line from flat file, then add key, say DET if the line isn't started with HDR or TRL. then concat each line and output to the NFS folder.

engswee
Active Contributor
0 Kudos

Hi Vijay

Coincidentally, I have been working on an enhancement to the DeepPlain2XMLConverter of to cater for such a scenario with no key field.

I've just released the latest version of the module converter and updated the following article with Scenario 3 using your example as the test case.

You can check it out to see if you want to use that solution to handle the FCC in your case.

Rgds

Eng Swee