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



IBM's Command List programming language & Restructured Extended Executor

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

Postby Mann_B » Thu Jul 08, 2010 1:40 pm

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
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

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

 

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

Postby MrSpock » Thu Jul 08, 2010 4:16 pm

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
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

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

Postby expat » Thu Jul 08, 2010 4:21 pm

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.
expat
 
Posts: 383
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 1 time

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

Postby Mann_B » Fri Jul 09, 2010 10:40 am

Can u pls let me know what is SORT (using the SS function)?

ThankYou
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby MrSpock » Fri Jul 09, 2010 6:52 pm

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'
/*
//*
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

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

Postby Mann_B » Fri Jul 16, 2010 10:35 am

Hi

Thank you for your reply .

I will try this ..n let know if I still find any issues
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby Mann_B » Thu Jul 22, 2010 7:18 pm

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
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby NicC » Thu Jul 22, 2010 7:27 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2702
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

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

Postby dick scherrer » Thu Jul 22, 2010 11:37 pm

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. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

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

Postby NicC » Fri Jul 23, 2010 2:13 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2702
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post