Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

extract records based on Binary field
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
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    Post subject: extract records based on Binary field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri May 01, 2015 2:26 am    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri May 01, 2015 4:58 am    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri May 01, 2015 8:09 pm    Post subject:
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    Post subject: Reply to: extract records based on Binary field
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

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri May 01, 2015 8:48 pm    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 990
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri May 01, 2015 8:50 pm    Post subject:
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    Post subject: Reply to: extract records based on Binary field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sat May 02, 2015 12:39 am    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon May 04, 2015 10:00 pm    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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: 331
Location: USA

PostPosted: Mon May 04, 2015 10:52 pm    Post subject: Reply to: extract records based on Binary field
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    Post subject: Reply to: extract records based on Binary field
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon May 04, 2015 11:38 pm    Post subject: Reply to: extract records based on Binary field
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us