IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

extract records based on Binary field


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Fri May 01, 2015 2:23 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 01, 2015 2:26 am
Reply with quote

BI is a numeric data-type. You are using a character literal. You need to use a numeric literal.
Back to top
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Fri May 01, 2015 2:31 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 01, 2015 4:58 am
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Fri May 01, 2015 6:52 pm
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Fri May 01, 2015 7:15 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Fri May 01, 2015 8:09 pm
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Fri May 01, 2015 8:18 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Fri May 01, 2015 8:48 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Fri May 01, 2015 8:50 pm
Reply with quote

... typo, sorry

Then drop bytes from 81 in the output phase based on the value I the 89th position...

Garry
Back to top
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Fri May 01, 2015 9:39 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 02, 2015 12:39 am
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon May 04, 2015 8:59 pm
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon May 04, 2015 9:13 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 04, 2015 10:00 pm
Reply with quote

Please use the Code tags to preserve space.

You've not coded a comma before the BUILD.

Code:
(9,1,CH,EQ,C'5')),
Back to top
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon May 04, 2015 10:16 pm
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon May 04, 2015 10:20 pm
Reply with quote

How to over come this issue ?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Mon May 04, 2015 10:52 pm
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon May 04, 2015 11:32 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 04, 2015 11:38 pm
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon May 04, 2015 11:50 pm
Reply with quote

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
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue May 05, 2015 12:09 am
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Tue May 05, 2015 12:22 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 05, 2015 12:35 am
Reply with quote

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
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Tue May 05, 2015 12:53 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts Sort based on the record type DFSORT/ICETOOL 1
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
Search our Forums:

Back to Top