Focal Point
[CLOSED] Flat file with multiple header records

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5597017576

April 22, 2015, 02:15 PM
CheriLG
[CLOSED] Flat file with multiple header records
I'm using mainframe FOCUS, version 7.6.13. We have a flat file that has a header record with a date in it, detail records associated to the header record, then a detail record. But there is data in this file from 2001 - 2015. So a header record for each year, detail records, then a trailer record ending the group. Here is a data sample:

12072001 S200111
ODB33403875F 2IC0428 G8352 05 PROJECT61330 000000000
ODB33403875F 2IC0429 G8352 05 PROJECT61330 000000000
ODB33403875F 2IC0430 G8352 05 PROJECT61330 000000000
ODB33403875F 2IC0431 G8352 05 PROJECT61330 000000000
BD936403875F1200 0000122D87830 0G2949 0616011010 87803REV0000 000000000
IN 0000038064 000000753018864{ DELETE 0000001539 000000000059701I DELETE HOL
01082002 S200112
ADB05406500X122055000 4J100020 11 000000102
ODE14406501X125046220 0630323CC6156 00706061 110120019970263032 000000001
ODE13406501X125046220 0630323CC6465 06061 010303022970263032 000000001
ODE13406501X125046220 0630323CC6466 06061 010303021970263032 000000001
ODE14406501X125046220 0630323CC6591 00706061 020512025980263032 000000000
IN 0000037668 000002065222131G DELETE 0000000862 000000006448076M DELETE HOL

in this sample there is a header record for year 200111, the detail records, the trailer record, then the header record for year 200112, etc.
here is my MFD:
FILENAME=RD1236D,SUFFIX=FIX, $
SEGNAME=HREC, $
FIELD=FIL1, , USAGE=A34, ACTUAL=A34, $
FIELD=PDT, , USAGE=A6, ACTUAL=A6, $
FIELD=FIL2, , USAGE=A287, ACTUAL=A287,$
SEGNAME=ONE, $
FIELD=REPORT, ALIAS=RPT, USAGE=A1, ACTUAL=A1, $
FIELD=AGE, ALIAS=CAT, USAGE=A1, ACTUAL=A1, $
FIELD=FC, ALIAS=FC, USAGE=A1, ACTUAL=A1, $
FIELD=REG, ALIAS=REG, USAGE=A2, ACTUAL=A2, $
GROUP=APPN, ALIAS=APPN, USAGE=A16, ACTUAL=A16, $
FIELD=G_A, ALIAS=GA, USAGE=A2, ACTUAL=A2, $
FIELD=T_A, ALIAS=TA, USAGE=A2, ACTUAL=A2, $
FIELD=YR1, ALIAS=YR1, USAGE=A4, ACTUAL=A4, $
FIELD=YR2, ALIAS=YR2, USAGE=A4, ACTUAL=A4, $
FIELD=SYMBOL, ALIAS=SYMBOL, USAGE=A4, ACTUAL=A4, $
FIELD=SUBHEAD, ALIAS=SUBH, USAGE=A4, ACTUAL=A4, $
FIELD=B_C_N, ALIAS=BCN, USAGE=A5, ACTUAL=A5, $
FIELD=SA, ALIAS=SA, USAGE=A1, ACTUAL=A1, $
FIELD=AAA, ALIAS=AAA, USAGE=A6, ACTUAL=A6, $
GROUP=TYPE, ALIAS=TYP, USAGE=A2, ACTUAL=A2, $
FIELD=TC1, ALIAS=TC1, USAGE=A1, ACTUAL=A1, $
FIELD=TC2, ALIAS=TC2, USAGE=A1, ACTUAL=A1, $
FIELD=VOUCHER, ALIAS=DOV, USAGE=A7, ACTUAL=A7, $
FIELD=PAA, ALIAS=PAA, USAGE=A6, ACTUAL=A6, $
FIELD=OBJ, ALIAS=OBJ, USAGE=A3, ACTUAL=A3, $
GROUP=DO, ALIAS=DO, USAGE=A5, ACTUAL=A5, $
FIELD=D1, ALIAS=D1, USAGE=A1, ACTUAL=A1, $
FIELD=DSSN, ALIAS=DSSN, USAGE=A4, ACTUAL=A4, $
FIELD=CL, ALIAS=CLASS, USAGE=A1, ACTUAL=A1, $
FIELD=RPT_MTH, ALIAS=RPM, USAGE=A2, ACTUAL=A2, $
FIELD=REG_MTH, ALIAS=RGM, USAGE=A2, ACTUAL=A2, $
FIELD=DAY, ALIAS=DAY, USAGE=A2, ACTUAL=A2, $
FIELD=COST_CODE, ALIAS=CST, USAGE=A12, ACTUAL=A12, $
FIELD=FRS_SUSP, ALIAS=FRSSUSP, USAGE=A1, ACTUAL=A1, $
FIELD=AMOUNT, ALIAS=AMT, USAGE=P16.2C, ACTUAL=Z14, $
FIELD=DOCUMENT, ALIAS=DOC, USAGE=A15, ACTUAL=A15, $
FIELD=SPIIN, ALIAS=SPIIN, USAGE=A6, ACTUAL=A6, $
FIELD=ACRN, ALIAS=ACRN, USAGE=A2, ACTUAL=A2, $
GROUP=UPDATE_KEY, ALIAS=UPD, USAGE=A11, ACTUAL=A11, $
GROUP=DATE, ALIAS=DATE, USAGE=A6, ACTUAL=A6, $
FIELD=AGE_YEAR, ALIAS=YYYY, USAGE=A4, ACTUAL=A4, $
FIELD=AGE_MONTH, ALIAS=MM, USAGE=A2, ACTUAL=A2, $
FIELD=SERIAL, ALIAS=SERNUM, USAGE=A5, ACTUAL=A5, $
GROUP=LOGIC_KEYS, ALIAS=KEY, USAGE=A28, ACTUAL=A28, $
GROUP=AKC, ALIAS=AKC, USAGE=A14, ACTUAL=A14, $
FIELD=A_1_13, ALIAS=A13, USAGE=A13, ACTUAL=A13, $
FIELD=A_14, ALIAS=A14, USAGE=A1, ACTUAL=A1, $
GROUP=BKC, ALIAS=BKC, USAGE=A14, ACTUAL=A14, $
FIELD=B_1_13, ALIAS=B13, USAGE=A13, ACTUAL=A13, $
FIELD=B_14, ALIAS=B14, USAGE=A1, ACTUAL=A1, $
FIELD=POS_157_316, ALIAS=CERPS, USAGE=A160, ACTUAL=A160, $


in my query I'm saying WHERE PDT EQ '200111' it does return the detail records for that year but it's also returning the detail for future years. I'm thinking my MFD is wrong but don't know what is wrong with it.

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.6
Windows, All Outputs
April 22, 2015, 03:17 PM
j.gross
You need to learn about use of "RECTYPE" -- search for it in documentation.


- Jack Gross
WF through 8.1.05
April 23, 2015, 05:53 AM
CheriLG
Can u please expand on why u think RECTYPE might work ? After reviewing this I think the problem might be that there is nothing that is associating the Header record with the detail records, such as a 'H' code for the header and a 'D' code for the detail.


WebFOCUS 7.6
Windows, All Outputs
April 23, 2015, 09:58 AM
j.gross
quote:
in this sample there is a header record for year 200111, the detail records, the trailer record, then the header record for year 200112, etc.


It helps to mark the sample data as "code", so we can see the column alignment.

12072001                         S200111
ODB33403875F                2IC0428           G8352   05  PROJECT61330 000000000
ODB33403875F                2IC0429           G8352   05  PROJECT61330 000000000
ODB33403875F                2IC0430           G8352   05  PROJECT61330 000000000
ODB33403875F                2IC0431           G8352   05  PROJECT61330 000000000
BD936403875F1200      0000122D87830  0G2949   0616011010  87803REV0000 000000000
IN 0000038064 000000753018864{   DELETE 0000001539 000000000059701I   DELETE HOL
01082002                         S200112
ADB05406500X122055000       4J100020                  11               000000102
ODE14406501X125046220 0630323CC6156        00706061 110120019970263032 000000001
ODE13406501X125046220 0630323CC6465           06061 010303022970263032 000000001
ODE13406501X125046220 0630323CC6466           06061 010303021970263032 000000001
ODE14406501X125046220 0630323CC6591        00706061 020512025980263032 000000000
IN 0000037668 000002065222131G   DELETE 0000000862 000000006448076M   DELETE HOL

So it appears there is no single field (column-position, or block of contiguous columns) common to all records, that effectively identifies the record as Header, Detail (perhaps several types), or Trailer - which could serve the RECTYPE role.

If you can provide a rule for identifying the type of each line, then it becomes possible to transform the file, by prepending an explicit RECTYPE code to each line, into a layout on which you can define a master with RECTYPE declarations for processing the sequence of records.

(It would be nice if a DEFINE could serve as the RECTYPE ... can a business view include RECTYPE structure? ... just thinking aloud)


- Jack Gross
WF through 8.1.05
April 25, 2015, 08:17 PM
Jim Morrow
I have used RECTYPE with an accept range. The file had Low-values , High-values header/control records but the data record had no type field so I set up the accept for all letters and numbers. You will have to workout the accept values for each Record Type. Remember the column tested does not have to be in the same position on each record. Focus will use the frist match found.


Jim Morrow
Web Focus 7.6.10 under Windows 2003
MVS 7.3.3



April 27, 2015, 12:39 PM
Dan Satchell
It is also possible to parse such data by using some of the many character functions available in FOCUS/WebFOCUS. You can create a "read" master file description with a single field whose length is the width of the flat file, then use DEFINEs to parse the data into distinct columns. This is especially useful when 2 or more "tests" are needed to determine a particular record type.


WebFOCUS 7.7.05
April 28, 2015, 09:55 AM
j.gross
quote:
Originally posted by Jim Morrow:
...Remember the column tested does not have to be in the same position on each record. Focus will use the first match found.


@jim

That's useful. Is it explicitly documented?

(undocumented behaviors sometimes get dropped without prior notice in a later release)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Added: I looked it up:


So, if RECTYPE as currently implemented supports non-uniform placement (and uses "first match wins" logic) as you describe, IBI is not committed to supporting that behavior in future releases.

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05