Let us say, I have a lookup table file for Name of the Months. (DD name LOOKUP1 in our example program)
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 01 JANUARY 02 FEBRUARY 03 MARCH 04 APRIL 05 MAY 06 JUNE 07 JULY 08 AUGUST 09 SEPTEMBER 10 OCTOBER 11 NOVEMBER 12 DECEMBER
and I have another file (DD name ACTUAL) for which the month names have to be read from the above file.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 05 12 33 03
Output File should have the month numbers from the ACTUAL file and should have fetched the month name from LOOKUP1 file and put in theĀ outputĀ file.
Ie,
OUTFILE
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 05 MAY 12 DECEMBER 33 INVALID MON 03 MARCH
This Can be achieved by the following program which uses the LOOKUP1 file as a table.
The field names ARG and DESC should not be changed (because those are keywords).
And also the TABLE file should not have high level group variable for the full record.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
LIST ON
FILE LOOKUP1 TABLE
ARG 1 2 A
DESC 4 15 A
FILE ACTUAL
ACTUAL-REC 1 80 A
MONTH-LIST 1 2 A
FILE OUTFILE
OUT-REC 1 80 A
OUT-MONTH-NUM 1 2 A
OUT-MONTH-NAME 4 15 A
JOB INPUT NULL
GET ACTUAL
DO WHILE NOT EOF ACTUAL
MOVE MONTH-LIST TO OUT-MONTH-NUM
SEARCH LOOKUP1 WITH MONTH-LIST , GIVING OUT-MONTH-NAME
IF NOT LOOKUP1
MOVE 'INVALID MON' TO OUT-MONTH-NAME
END-IF
PUT OUTFILE
GET ACTUAL
END-DO
STOP.
4 Comments
very very helpful..
Rajeev Nambyar
MPhasis an HP company..
Hi,
If I have a file of few month numbers only say 01 05 10 and requirement is if month number from input file match any entry in month number file append Yes in the output record else append No in the output record.
How this can be achieved.
Very crazy man!!!
Thanks Rajeev!