|
View previous topic :: View next topic
|
| Author |
Message |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Hi ,
i want to extract records from a file from a particular position which is in binary format .
I want to check for the values for 1 ,2, 3 ,4, 5 .
I know the below syntax is wrong . I am not sure on how to give the values in binary format .
SORT FIELDS=COPY
INCLUDE COND=((2,1,BI,EQ,C'1'),OR,
(2,1,BI,EQ,C'2'),OR,
(2,1,BI,EQ,C'3'),OR,
(2,1,BI,EQ,C'4'),OR,
(2,1,BI,EQ,C'5'))
Can you please help in this . |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| BI is a numeric data-type. You are using a character literal. You need to use a numeric literal. |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
So you mean to say if i use in the below format , this will work ?
SORT FIELDS=COPY
INCLUDE COND=((4,1,BI,EQ,1),OR,
(4,1,BI,EQ,2),OR,
(4,1,BI,EQ,3),OR,
(4,1,BI,EQ,4),OR,
(4,1,BI,EQ,5))
The input file has the data in COMP format . This is a 9 byte field that has been declared as S9(9) COMP . So it would occupy 4 bytes . I want to extract records that end with 1, 2,3,4,5 in the 9th position
So how do i need to change my INCLUDE condition ? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Syntactically it is correct, but you haven't given enough information to know if it will work.
S9(9) isn't nine bytes, it is nine digits. The S means it has been defined as signed. Can it contain a negative value? If yes, then do you want those negative values to be included as well?
| Code: |
000000005
000000015 |
For the first of those, the fourth byte will be X'05', so it will be INCLUDEd. For the second, it will be X'0F', so won't be INCLUDEd.
Do you have some sample values of the entire four-byte field? |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Hi Bill ,
After putting a HEX ON on the file s. i am seeing records in the below format .
09BA
CE9E
----
LL
3DD9
933A
----
09B6
CEA3
----
LR1
3DDF
9391
----
09B7
CEA7 |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
when i use copybook the data is in the below format .
4/BI 211771397
4/BI 205025540
4/BI 206023172
4/BI 212709892
My requirement is to extracts records that are ending with 1,2,3,4,5 in the position that i have highlighted |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
If you are looking to extract records with binary fields using decimal numbers, I would think you need to get DFSORT to convert the number from BI to ZD before you extract based on the ZD field in position 9. Do this as an extension of the input record and drop the extension on output.
Garry. |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
| Can you please let me know how to go about this ? I am not sure about the syntax that needs to be used for the conversion . |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
You might try something like...
| Code: |
| INREC BUILD(1,80,81:1,4,BI,TO=ZD,LENGTH=9,90:X) |
to build the intermediate record. Then drop bytes from 81 in the output phase.
I've assumed 80 byte fixed length records based on the value in the 89th position.
Garry. |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1216 Location: Dublin, Ireland
|
|
|
|
... typo, sorry
Then drop bytes from 81 in the output phase based on the value I the 89th position...
Garry |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Hi ,
My file is a VB file of length 10500 .
So my statement should be like this .
INREC BUILD(4,10504,15:1,4,BI,TO=ZD,LENGTH=9,10505:X)
SORT FIELDS=COPY
INCLUDE COND=((10513,1,CH,EQ,C'1'),OR,
(10513,1,CH,EQ,C'2'),OR,
(10513,1,CH,EQ,C'3'),OR,
(10513,1,CH,EQ,C'4'),OR,
(10513,1,CH,EQ,C'5'))
Correct me if i am wrong . |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
For variable-length records you should do the extension at the beginning of the record, else all your variable-length records will become fixed-length records which happen to have an RDW.
It doesn't matter what order you put the commands in, DFSORT will always process them in its own order. INCLUDE/OMIT COND= comes before INREC.
There is no need to store all nine digits. If you have a sequence of numbers, test for the sequence, not individually.
| Code: |
INREC BUILD=(1,4,5,4,BI,TO=ZD,LENGTH=1,5)
SORT FIELDS=COPY
OUTFIL INCLUDE=((5,1,CH,GE,C'1'),AND,
(5,1,CH,LE,C'5')),
BUILD=(1,4,6) |
|
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
hi Bill ,
I tried this , but something is wrong in my coding , . I am getting the below error .
| Code: |
SYSIN :
INREC BUILD(1,4,15,4,BI,TO=ZD,LENGTH=1,9)
SORT FIELDS=COPY
OUTFIL INCLUDE=((9,1,CH,EQ,C'1'),OR,
(9,1,CH,EQ,C'2'),OR,
(9,1,CH,EQ,C'3'),OR,
(9,1,CH,EQ,C'4'),OR,
(9,1,CH,EQ,C'5'))
BUILD=(1,4,10500)
*
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
|
Can you let me know what is wrong in my statement ?
Code'd and moved to SyncSORT |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Posting my JCL also .
//JS210R EXEC PGM=SORT
//SYSOUT DD SYSOUT=X
//SYSPRINT DD SYSOUT=X
//SYSUDUMP DD SYSOUT=X
//SORTIN DD DSN=INPUT.FILE.VB,
// DISP=SHR
//SORTOUT DD DSN=OUTPUT.FILE.EXTRACT,
// DISP=SHR
//SYSIN DD *
INREC BUILD(1,4,15,4,BI,TO=ZD,LENGTH=1,9)
SORT FIELDS=COPY
OUTFIL INCLUDE=((9,1,CH,EQ,C'1'),OR,
(9,1,CH,EQ,C'2'),OR,
(9,1,CH,EQ,C'3'),OR,
(9,1,CH,EQ,C'4'),OR,
(9,1,CH,EQ,C'5'))
BUILD=(1,4,10500)
/*
// |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Please use the Code tags to preserve space.
You've not coded a comma before the BUILD.
|
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Hi Bill ,
i had corrected that comma , and the JCL ran fine . But when i check the output file , i am seeing all the input records in my output file .
| Code: |
SYSIN :
INREC BUILD(1,4,15,4,BI,TO=ZD,LENGTH=1,9)
SORT FIELDS=COPY
OUTFIL INCLUDE=((9,1,CH,EQ,C'1'),OR,
(9,1,CH,EQ,C'2'),OR,
(9,1,CH,EQ,C'3'),OR,
(9,1,CH,EQ,C'4'),OR,
(9,1,CH,EQ,C'5')),
BUILD=(1,4,10500)
WER108I SORTIN : RECFM=V ; LRECL= 10500; CISIZE = 12288
WER073I SORTIN : DSNAME=INPUT.FILE.VB
WER257I INREC RECORD LENGTH = 10501
WER110I SORTOUT : RECFM=VB ; LRECL= 10504; BLKSIZE= 27998
WER074I SORTOUT : DSNAME=OUTPUT.FILE.EXTRACT
WER405I SORTOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
WER054I RCD IN 1512099, OUT 1512099 |
Can you let me know what am i doing wrong ?
Code'd again |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
| How to over come this issue ? |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
| Your 15,4 in INREC with length=1 is actually column 5. So, you need to compare column 5 and not 9. |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
I am confused ...
the field that i want to convert to ZD starts in the 15th position and is of length 4 bytes. In this i want to check for the 9th position
4/BI 211771397
4/BI 205025540
4/BI 206023172
4/BI 212709892
Please let me know how to correct my syntax ? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
INREC BUILD=(1,4,
15,4,BI,
TO=ZD,
LENGTH=1,
9)
SORT FIELDS=COPY
OUTFIL INCLUDE=((5,1,CH,GE,C'1'),AND,
(5,1,CH,LE,C'5')),
BUILD=(1,4,6) |
Try that with you test file. Check that the start-position of 15 is relative to the start of the record, not the start of the data, and adjust if not. |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Nope , it not working . i am still seeing all the records .
19th is the relative position (15 + 4 bytes)
SYSIN :
INREC BUILD(1,4,19,4,BI,TO=ZD,LENGTH=1,9)
SORT FIELDS=COPY
OUTFIL INCLUDE=((5,1,CH,EQ,C'1'),OR,
(5,1,CH,EQ,C'2'),OR,
(5,1,CH,EQ,C'3'),OR,
(5,1,CH,EQ,C'4'),OR,
(5,1,CH,EQ,C'5')),
BUILD=(1,4,10500) ----------> 10500 is the total length of the record
WER108I SORTIN : RECFM=V ; LRECL= 10500; CISIZE = 12288
WER073I SORTIN : DSNAME=INPUT.FILE.VB
WER257I INREC RECORD LENGTH = 10501
WER110I SORTOUT : RECFM=VB ; LRECL= 10504; BLKSIZE= 27998
WER074I SORTOUT : DSNAME=OUTPUT.FILE.EXTRACT
WER405I SORTOUT : DATA RECORDS OUT 0; TOTAL RECORDS OUT 0
WER054I RCD IN 1512850, OUT 1512850 |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Can you try this:
| Code: |
INREC BUILD=(1,4,
19,4,BI,
TO=ZD,
LENGTH=9,
5)
SORT FIELDS=COPY
OUTFIL INCLUDE=((13,1,CH,GE,C'1'),AND,
(13,1,CH,LE,C'5')),
BUILD=(1,4,14) |
|
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Bill ,
Still i am getting all the records in the output file .
SYSIN :
INREC BUILD(1,4,19,4,BI,TO=ZD,LENGTH=9,5)
SORT FIELDS=COPY
OUTFIL INCLUDE=((13,1,CH,GE,C'1'),OR,
(13,1,CH,LE,C'5')),
BUILD=(1,4,14)
WER108I SORTIN : RECFM=V ; LRECL= 10500; CISIZE = 12288
WER073I SORTIN : DSNAME=INPUT.FILE.VB
WER257I INREC RECORD LENGTH = 10513
WER238I POTENTIALLY INEFFICIENT USE OF INREC
WER110I SORTOUT : RECFM=VB ; LRECL= 10504; BLKSIZE= 27998
WER074I SORTOUT : DSNAME=OUTPUT.FILE.EXTRACT
WER405I SORTOUT : DATA RECORDS OUT 1513130; TOTAL RECORDS OUT 1513130
WER054I RCD IN 1513130, OUT 1513130 |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code tags. Code tags.
| Code: |
| Code tags. Code tags. |
Click the Quote button, and see what I did there.
I can't believe your test file contains 1.5m records.
| Code: |
OPTION STOPAFT=10
INREC BUILD=(1,4,19,4,BI,19,4,BI) |
Run that, please, and paste the output. In. The. Code. Tags. |
|
| Back to top |
|
 |
chockalingam_rsp
New User

Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
Hi Bill ,
Please find my spool output .
| Code: |
SYSIN :
OPTION STOPAFT=10
INREC BUILD(1,4,19,4,BI,TO=ZD,LENGTH=9,5)
SORT FIELDS=COPY
OUTFIL INCLUDE=((13,1,CH,GE,C'1'),OR,
(13,1,CH,LE,C'5')),
BUILD=(1,4,14)
WER108I SORTIN : RECFM=V ; LRECL= 10500; CISIZE = 12288
WER073I SORTIN : DSNAME=INPUT.FILE.VB
WER257I INREC RECORD LENGTH = 10513
WER238I POTENTIALLY INEFFICIENT USE OF INREC
WER110I SORTOUT : RECFM=VB ; LRECL= 10504; BLKSIZE= 27998
WER074I SORTOUT : DSNAME=OUTPUT.FILE.EXTRACT
WER405I SORTOUT : DATA RECORDS OUT 10; TOTAL RECORDS OUT 10
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
WER054I RCD IN 10, OUT 10
|
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|