Page 1 of 2

To get records having same value for a field but at diff pos

PostPosted: Thu Jul 08, 2010 1:40 pm
by Mann_B
Hi

I have a requirement like ..in a file there are many records which are of different fileds and values .But all the records have field , Trans-id but at different positions.Now i need to get all the records which are having same trans-id(which is not uniq....like for that perticular transaction ID so many records will get created with different information)

Input file:
LRECL:4096
Record format:VB

name     id1           area        address
age     desing         id2          work
exp     company       sal            id1
name    id2             area        address
age     desing         id1          work
exp     company        sal          id2


Like this there will be so many record with different ID's(few records having same Ids but at different positions)
Now in o/p file ,if I specify one ID ...I shuold get all the records having that perticulat ID.
I cannot go for SORT because there will be so many records having same ID at different positions.I cannot give all the positions IN OR condition.

I heard we can do so in REXX.
Please help me if u have any idea on this.

Thank U

Re: To get records having same value for a field but at diff pos

PostPosted: Thu Jul 08, 2010 4:16 pm
by MrSpock
If I understand you correctly, you want to look for a specific value on each record and, if found, copy that record to the output. Correct?

If so, you CAN easily do that with SORT (using the SS function), but using REXX you can try the POS function:

Read a record.
Use the POS (Position) function to find the field:

...
Parse Pull rec
fnd = POS('id1',rec)
If fnd <> 0 Then
Do
... write the record
End

Re: To get records having same value for a field but at diff pos

PostPosted: Thu Jul 08, 2010 4:21 pm
by expat
I would go for the SORT option as REXX is probably one of the most inefficient methods for I/O with a large record volume.

Re: To get records having same value for a field but at diff pos

PostPosted: Fri Jul 09, 2010 10:40 am
by Mann_B
Can u pls let me know what is SORT (using the SS function)?

ThankYou

Re: To get records having same value for a field but at diff pos

PostPosted: Fri Jul 09, 2010 6:52 pm
by MrSpock
This worked for me with DFSORT:
//STEPXXXX EXEC PGM=SORT
//SORTIN   DD   DSN=VB/4096....
//SORTOUT  DD   DSN=NEW VB/4096 ....
//SYSOUT   DD   SYSOUT=*
//SYSIN    DD   *
  INREC OVERLAY=(4097:X)
  OPTION COPY
  OUTFIL INCLUDE=(5,4090,SS,EQ,C'id1'),
    BUILD=(1,4,5,4092),VLTRIM=X'40'
/*
//*

Re: To get records having same value for a field but at diff pos

PostPosted: Fri Jul 16, 2010 10:35 am
by Mann_B
Hi

Thank you for your reply .

I will try this ..n let know if I still find any issues

Re: To get records having same value for a field but at diff pos

PostPosted: Thu Jul 22, 2010 7:18 pm
by Mann_B
Hi MrSpock

Sory for my late reply.
I tried the JCL n its working fine.

The Id that I need to search will be in packed form in the input file .So we give X'id' in search criteria.
But when am trying to give multiple Ids..am getting an error.
I read that we can give multiple Ids like this:

INCLUDE COND=(106,5,SS,EQ,C'BIOL ,HIST ,BUSIN,PSYCH')
from
http://publibz.boulder.ibm.com/cgi-bin/ ... 0223112358

So i have tried giving like this:

INREC OVERLAY=(4097:X)
OPTION COPY
OUTFIL INCLUDE=(5,4090,SS,EQ,X'id1,id2')
BUILD=(1,4,5,4092),VLTRIM=X'40'


But am getting an eror:

SYSIN :
INREC OVERLAY=(4097:X)
OPTION COPY
OUTFIL INCLUDE=(5,4090,SS,EQ,X'233ADB25,233DE01D')
*
BUILD=(1,4,5,4092),VLTRIM=X'40'
*
WER251A INCLUDE/OMIT INVALID SELF DEF TERM
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE


Please correct me if the way that I understood is wrong and pls help me in how to give mutiple ids in search.


Thank You

Re: To get records having same value for a field but at diff pos

PostPosted: Thu Jul 22, 2010 7:27 pm
by NicC
Unfortunately you are using Syncsort so I would check the manual for that product and see what you can find out. Although SYCSORT and DFSORT are more or less compatible in function and syntax they can differ and this may be one of those occasions when they differ.

Re: To get records having same value for a field but at diff pos

PostPosted: Thu Jul 22, 2010 11:37 pm
by dick scherrer
Hello,

Unfortunately you are using Syncsort. . .
We do not want editorial comments. . . :(

OUTFIL INCLUDE=(5,4090,SS,EQ,X'233ADB25,233DE01D')
One cannot "make up" syntax. . .

I'm not able to test this, but you might try:
OUTFIL INCLUDE=(5,4090,SS,EQ,L(X'233ADB25',X'233DE01D'))

If this does not work for you, you can always specify the 2 values in 2 INCLUDEs with an OR between them. . .

Re: To get records having same value for a field but at diff pos

PostPosted: Fri Jul 23, 2010 2:13 am
by NicC
We do not want editorial comments. . . :(


Sorry Dick - you mis-read my comment - maybe 'misunderstood' is a better word. I have never used SYSNCSORT and have no opinion about it. What I was saying was that the answer that had previously been given was presumably for DFSORT as DFSORT had already been mentioned but the error messages indicated that OP was using SYNCSORT. No editorialising was meant or intended.