Page 1 of 1

How to define two record layout for a single input file

PostPosted: Mon Apr 09, 2012 10:08 am
by Abhay2012
Hi,

Can anyone please suggest how to define two record fields layout for a single input file.
I have a input file but have to read file from two different layouts, so if I read the file both the record fields layout should be populated.
e.g

FILE PERSNL VS
%PERSNL1
%PERSNL2

If have input file,PERSNL and having two layout PERSNL1 and PERSNL2(having same record format and record length). And if read file PERSNL both the filelds layout should populated.

Thanks!

Re: How to define two record layout for a single input file

PostPosted: Mon Apr 09, 2012 1:57 pm
by BillyBoyo
Abhay2012 wrote:Hi,

Can anyone please suggest how to define two record fields layout for a single input file.
I have a input file but have to read file from two different layouts, so if I read the file both the record fields layout should be populated.
e.g

FILE PERSNL VS
%PERSNL1
%PERSNL2

If have input file,PERSNL and having two layout PERSNL1 and PERSNL2(having same record format and record length). And if read file PERSNL both the filelds layout should populated.

Thanks!


That would be a way to define two record layouts for the same file.

However, I have no idea what you mean when you say "have to read file from two different layouts" or "if I read the file both the record fields layout should be populated".

You (or Easytrieve Plus) read the file. What the record-layouts do is "map" the data that is on the file. If you have two record-layouts, you have two "maps" (presumably you can identify which record is the current one from the data, so you know which "map" to use). Nothing gets "populated" into the layouts. You'll only have data on the file, and two different maps of that data (obviously, both maps are of the same storage location).

If you are trying to achieve something else, you'll have to describe as best you can what that is.

Re: How to define two record layout for a single input file

PostPosted: Mon Apr 09, 2012 3:05 pm
by Abhay2012
Thanks Billy for quick response!

Let me try to explain what I'm trying to achieve..

Say, I have a input file PERSNL. And I have to check some condition for two fields GR-STS-CD and DV-STS-CD
i.e

IF GR-STS-CD = A
IF DV-STS-CD = A
........
.........
END-IF
END-IF

But one field GR-STS-CD is present in record layout PERSNL1 and other is in PERSNL2 (field positions are different in file PERSNL for these two fields. GR-STS-CD starts from 727 position for layout PERSNL1 and DV-STS-CD starts from 633 position for layout PERSNL2)

So my question is if I define file as below:

FILE PERSNL VS
%PERSNL1
%PERSNL2

will the data be mapped for both record layout ?

Regards
-Ravi

Re: How to define two record layout for a single input file

PostPosted: Mon Apr 09, 2012 3:27 pm
by BillyBoyo
Yes, the data will be mapped for both record-layouts.

You do have a potential problem. If you ignore identifying which record is which, you may do the test on the second record-type whilst having the data for the first record-type on the file, and get a false "hit" when the data happens to coincide with whatever is on the record at that position.

You must identify first which record-type the current record on the file is, and then you'll know which layout to use for the current record, and have a different logic "leg" for the other record-type.