|
View previous topic :: View next topic
|
| Author |
Message |
useit
Active User
Joined: 05 Oct 2006 Posts: 152
|
|
|
|
HI,
i have subgroup F,G, AND H and their subordinate values are as below.
F--F
F1
F11
F111
F111A
G--G
G1
G11
G111
G111A
H-H
H1
H11
H111
H111A
i have two files.
file1 is as below
01 INREC.
05 QTY PIC 9(2)
say example:
in file1
in file 2 is as below
| Code: |
F
F1
F11
F111A
G
G1
G11
G111A
H
H1
H11
H111A |
my final output shoul include all the matching record from the file1 and subordinate value after that.
| Code: |
F
F1
F11
F111A
G1
G11
G111A
H11
H111A |
please help me in this regard
Regds,
useit |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What is the significance, if any, of only one "dash" in between the H's?
How does your Cobol record-layout relate to any of this?
EDIT: Whilst at it, what are RECFM/LRECL of files? What is the maximum-length field for selection you can have on file 1? |
|
| Back to top |
|
 |
useit
Active User
Joined: 05 Oct 2006 Posts: 152
|
|
|
|
sorry, the record length was mentioned wrongly.
input file1 and file2 has record length =5.(recfm=fb)
01 inrec.
05 subgrp pic x(05).
maximum lenght field wqe can have on file1 is 5
Regds,
useit |
|
| Back to top |
|
 |
useit
Active User
Joined: 05 Oct 2006 Posts: 152
|
|
|
|
say for example.
1)
File1:
FILE2:
| Code: |
F
F1
F11
F111
F111A |
MY OUTPUT WILL BE
| Code: |
F
F1
F11
F111
F111A |
2)IF FILE 1 HAS
MY OUTPUT WILL BE
3)IF FILE 1 HAS
OUTPUT WILL BE
4):IF FILE 1 HAS
MY OUTPUT WILL BE
5):IF FILE 1 HAS
MY OUTPUT WILL BE
Regds,
useit |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
inrec change all file2 to 7 bytes.
you want to joinkeys,
reformat hits to add "H" to byte 6 of file 2
keep all of file f2,
pass the output of above,
inrec:
when byte 6 = 'H",push byte 1 to byte 7
outrec/outfile:
include byte 1 = byte 7
reformat to 5 bytes.
using:
file 1
file 2
| Code: |
F
F1
F11
F111A
G
G1
G11
G111A
H
H1
H11
H111A |
output of joinkeys:
| Code: |
F H
F1
F11
F111A
G
G1 H
G11
G111A
H
H1
H11 H
H111A |
INREC:
| Code: |
F HF
F1 F
F11 F
F111A F
G F
G1 HG
G11 G
G111A G
H G
H1 G
H11 HH
H111A H |
OUTREC/OUTFILE
| Code: |
F
F1
F11
F111A
G1
G11
G111A
H11
H111A
|
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
The best option is to generate INCLUDE COND with SS format from file 1 and use those cards to extract the values.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
F
G1
H11
//SORTOUT DD DSN=&&C,DISP=(,PASS),SPACE=(CYL,(2,2),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=(3:'OPTION COPY',/,
3:'INCLUDE COND=(1,01,CH,NE,1,1,CH,OR,'),
BUILD=(17:1,8,SQZ=(SHIFT=LEFT,LEAD=C'1,10,SS,EQ,C''',
TRAIL=C''',OR,',LENGTH=65)),
TRAILER1=(17:'1,01,CH,NE,1,1,CH)')
//* |
This will create the Control cards as
| Code: |
OPTION COPY
INCLUDE COND=(1,01,CH,NE,1,1,CH,OR,
1,10,SS,EQ,C'F',OR,
1,10,SS,EQ,C'G1',OR,
1,10,SS,EQ,C'H11',OR,
1,01,CH,NE,1,1,CH) |
Now we will use the above generated control cards to extract the desired records
| Code: |
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
F
F1
F11
F111A
G
G1
G11
G111A
H
H1
H11
H111A
//SORTOUT DD SYSOUT=*
//SYSIN DD DSN=&&C,DISP=SHR |
This will produce the following output
| Code: |
F
F1
F11
F111A
G1
G11
G111A
H11
H111A |
|
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
Simple and eloquent.
decide what to look for
build the required INCLUDEs
let er rip.
LEAD and TRAIL for the BUILD parameter are rather powerful.
between those two and SS,
you have reference modification in DFSORT. (Sorry..)
thx kolusu. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|