I am trying to generate a output file based on below conditions. I have a control card that have 5 fileds in it. But to simplify, i am giving an example with only 2 fileds in it. Have one input file as well.
Example:
I have a control card as input that can have 2 fields. Those 2 fields can have default values or some value in it. Default being 9's.
Control card:
EMP-ID can have 99999 or some value like 34567
Emp-Loc can have 99 or value like OH
Input file: Example records. My input file is much more complicated than this.
Now, control card can have both location details and emp-id detials or only one of them.
If Emp-id is given and not location then all records with that emp-id needs to be pulled. If only location is given then pull all records that match the criteria. The absence of a field is seen by having 9's in that position in control card. If both location and emp-id are given then pull details from input file using both.
Say, I have 99999OH in my control card as input then o/p should look like
12345OH
23456OH
45678OH
34567OH
If I have 3456799 in my control card then o/p has to look like
34567PA
34567OH
If i/p is 34567OH then o/p should look like
34567OH
Using cobol will make it complicated with too many IF's. So I wan to do it using DFSORT/ICETOOL. Need code for the same.
My idea was to check
if EMP-ID has 99999 in it then copy all records else
try to match records based on EMP_ID and pull those into a file.
after that IF LOCATION = 99 then copy file1 to file2
else try to match records based on LOCATION and pull those into another file.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
Kranti M wrote:
I am trying to generate a output file based on below conditions. I have a control card that have 5 fileds in it. But to simplify, i am giving an example with only 2 fileds in it. Have one input file as well.
Input file: Example records. My input file is much more complicated than this.
Kranthi M,
You need to provide more details.
1. What is the LRECL and RECFM of the control file?
2. What is the position and format of ALL the 5 fields in the control file?
3. What is the LRECL and RECFM of the Input file?
4. Post the cobol layout of the input file and explain all the rules to pick a record. As you have 5 different fields , is it an AND cond for all the 5 fields if present in the control file?
i.e if you provide 4 values in the control file and 1 field is all 9's then you want to include the records with the following condition?
Code:
IF FIELD1 = 'CONTROL VALUE 1' AND,
FIELD2 = 'CONTROL VALUE 2' AND
FIELD3 = 'CONTROL VALUE 3' AND
FIELD4 = 'CONTROL VALUE 4'
write output
END-IF
HI ,
I have done this in COBOL and it is working. THere was change in requirement to allow multiple rows in the control card. It means, I would need to have AND condition with 1st record fields and then OR with 2nd record and with in 2nd record i had to do AND. Total of 10 records needs to be allowed.
So, I tried to BUILD
INCLUDE COND=(((1,2,CH,'C'12'),&,
(3,5,CH,C'12345')),OR,
((1,2,CH,C'13')),OR,
((1,2,CH,C'14'),&,
(3,5,CH,C'23456')))
SORT FIELDS = COPY
I could get this for a control card that has 3 record with record having 5 fields and a record can have combination of fields. Missin input field will be 9's.
and then used the above in SORT Step to get my output.