|
View previous topic :: View next topic
|
| Author |
Message |
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
I have an variable length input file of length 1040 bytes. The format of the file is
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr2
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
My requirement is, if the VersionNbr in HDRRec is 1, then all detail records (including Header and Trailer) under that Header Record needs to be extracted and written into a new file. So in this case the output will be
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
The Header record is identified by the keyword HDR which starts at position 1 and trailer record is identified by the keyword TRL which starts at position 1. The version number will be starting at position 41 and will be 8 bytes in length.
Can this be achieved using DFSORT? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes, I'm pretty sure it can.
If you look through the forum you'll get some good hints as to how, even. |
|
| Back to top |
|
 |
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
I had searched the forum and written the following sort card
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1040:C'N')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR',AND,41,8,ZD,EQ,0001),
OVERLAY=(1041:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
OVERLAY=(1041:C'9'),HIT=NEXT)
The problem I am facing is that the detail records are always getting marked with 'N' even if the header record is satisfying the conditions. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Code: |
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr2
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
|
For your shown input I am really wondering what rules you want to apply to get below output(Shown by you)
| Code: |
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
|
Why below is not output?
| Code: |
HDRRec VersionNbr1
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
|
|
|
| Back to top |
|
 |
elango_K
New User
Joined: 18 Aug 2011 Posts: 44 Location: India
|
|
|
|
| Code: |
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1040:C'N')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR',AND,41,8,ZD,EQ,0001),
OVERLAY=(1041:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
OVERLAY=(1041:C'9'),HIT=NEXT)
|
You are using a VB file, your header will not satisfy this condition.
Start from position 5 . |
|
| Back to top |
|
 |
elango_K
New User
Joined: 18 Aug 2011 Posts: 44 Location: India
|
|
|
|
Try this:
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,3,CH,EQ,C'HDR',AND,
41,8,ZD,EQ,1),END=(5,3,CH,EQ,C'TRL'),PUSH=(1041:ID=8))
OUTFIL OMIT=(1041,1,CH,NE,C'0'),BUILD=(1,1040)
|
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Indrajit_57,
If you pad the group-id indicator at the end of a VB file you will ruin the very concept of VB files and make them all fixed block.
I assumed that your HDR value starts in pos 5 ( first 4 byte of RDW) and the number 1 starts in position 22. In order to retain the original lengths of the VB file, we pad a 1 byte space right after the RDW and use that for pushing the Group-id indicator. since we padded the space before the actual record , now your positions are incremented by 1. So the HDR is now at position 6 and the number is at position 23. While writing out we remove that field, there by retaining the original VB file lengths for each record.
Use the following DFSORT JCL.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your Input VB 1040 Lrecl file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,X,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(6,3,CH,EQ,C'HDR',AND,23,1,ZD,EQ,1),
END=(6,3,CH,EQ,C'TRL'),PUSH=(5:ID=1))
OUTFIL OMIT=(5,1,CH,EQ,C' '),BUILD=(1,4,6)
//* |
|
|
| Back to top |
|
 |
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
| Thanks Skolusu. It is working fine for me. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|