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

Extracting records from a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vijay Subramaniyan

New User


Joined: 06 Jul 2011
Posts: 14
Location: india

PostPosted: Tue Jul 03, 2012 8:35 pm
Reply with quote

Hi all,

Can I have my following requirement done through Sort ?

Reqt :
I/P file records

ABCDEF
Line1
Line2
ENGANVADK | 27187481734718 |
Line3
Line4
ABCDEF
.
.
ABCDEF
Line1
Line2
ENGANVADK | 27187481730348 |
Line3
Line4
Line5
ABCDEF

The sequence repeats like the above .
I want the records to be extracted if I am given an account number
say, for acct no 27187481730348 I want the following records to be
extracted from the file
ABCDEF
Line1
Line2
ENGANVADK | 27187481730348 |
Line3
Line4
Line5
ABCDEF

More Details:
The acct number's position is fixed.
The file is VB . I do not know the length of any line .

[/img]
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jul 03, 2012 9:40 pm
Reply with quote

Vijay Subramaniyan,

Do you have groups of records each starting with 'ABCDEF' and also ending with 'ABCDEF'?

Does the account number always have ENGANVADK at the beginning? What is the position and format of the account number? (include the RDW also as your input is VB file)

How many accounts are going to provide/pull at a time? Can you input your account numbers in a file like this ?
Code:

ENGANVADK | 27187481730348 |
ENGANVADK | 27187481730399 |
ENGANVADK | 27187481730800 |
Back to top
View user's profile Send private message
Vijay Subramaniyan

New User


Joined: 06 Jul 2011
Posts: 14
Location: india

PostPosted: Wed Jul 04, 2012 11:12 am
Reply with quote

Hi Skolusu,

Yes. The group of records start with ABCDEF and end with ABCDEF. The account number will not have always ENGANVADK, but the
account number's position will be fixed . Assume its position is 15 and of 17 bytes long. I need to extract a group of records for an account number. Extracting one set of records may be enough for me.
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: Thu Jul 05, 2012 5:55 am
Reply with quote

The start and end indicators both being the same value was not a good idea. Is there anything else on those first and last records of the group to differentiate them from each other?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jul 05, 2012 8:27 am
Reply with quote

Hi,

here is a way to get this started to differentiate the groups
Code:
//SORT0001 EXEC PGM=SORT               
//SORTIN   DD *                         
ABCDEF                                 
LINE1                                   
LINE2                                   
ENGANVADK | 27187481734718 |           
LINE3                                   
LINE4                                   
ABCDEF                                 
ABCDEF                                 
LINE1                                   
LINE2                                   
ENGANVADK | 27187481730348 |           
LINE3                                   
LINE4                                   
LINE5                                   
ABCDEF                                 
//SYSOUT   DD SYSOUT=*                 
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=(001,6,CH,EQ,C'ABCDEF'),               
                OVERLAY=(41:SEQNUM,1,ZD),HIT=NEXT),         
        IFTHEN=(WHEN=(41,1,CH,EQ,C'1'),OVERLAY=(43:C'$')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'2'),OVERLAY=(43:C'?')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'3'),OVERLAY=(43:C'$')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'4'),OVERLAY=(43:C'?')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'5'),OVERLAY=(43:C'$')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'6'),OVERLAY=(43:C'?')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'7'),OVERLAY=(43:C'$')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'8'),OVERLAY=(43:C'?')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'9'),OVERLAY=(43:C'$')),   
        IFTHEN=(WHEN=(41,1,CH,EQ,C'0'),OVERLAY=(43:C'?'))   
 OUTREC IFTHEN=(WHEN=GROUP,                                 
              BEGIN=(43,1,CH,EQ,C'$'),                       
                END=(43,1,CH,EQ,C'?'),                       
                PUSH=(44:ID=4))                             
/*


Gerry
Back to top
View user's profile Send private message
Vijay Subramaniyan

New User


Joined: 06 Jul 2011
Posts: 14
Location: india

PostPosted: Thu Jul 05, 2012 10:36 am
Reply with quote

Bill,

Actually the start and end indicators are different . It was my mistake.

The actual bound values would be as below :

ABCDEF
Line1
Line2
ENGANVADK | 27187481730348 |
Line3
Line4
Line5
PQRSTU


The actual problem lies in the fact that the account number is present in
the third line . Had it been in the first line , the task would have been much simpler by coding (WHEN=GROUP, PUSH ) statement .
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jul 05, 2012 11:22 am
Reply with quote

Hi,

try this, this will assist in selecting which group of records you need to extract

Code:
//SORT0001 EXEC PGM=SORT                   
//SORTIN   DD *                           
ABCDEF                                     
LINE1                                     
LINE2                                     
ENGANVADK | 27187481734718 |               
LINE3                                     
LINE4                                     
PQRSTU                                     
ABCDEF                                     
LINE1                                     
LINE2                                     
ENGANVADK | 27187481730348 |               
LINE3                                     
LINE4                                     
LINE5                                     
PQRSTU                                     
//SYSOUT   DD SYSOUT=*                     
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  SORT FIELDS=COPY                                                     
  INREC  IFTHEN=(WHEN=GROUP,                                           
              BEGIN=(1,6,CH,EQ,C'ABCDEF'),                             
               PUSH=(44:ID=4))                                         
  OUTFIL INCLUDE=(13,14,CH,EQ,C'27187481730348'),                       
         BUILD=(44,4)                                                   
//*                                                                     



Gerry
Back to top
View user's profile Send private message
Vijay Subramaniyan

New User


Joined: 06 Jul 2011
Posts: 14
Location: india

PostPosted: Thu Jul 05, 2012 11:35 am
Reply with quote

Thank you much gcicchet . This would give me the group that the account number belongs to . Is there a way to do this without any manual intervention ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Jul 05, 2012 1:18 pm
Reply with quote

What manual intervention?
Back to top
View user's profile Send private message
Vijay Subramaniyan

New User


Joined: 06 Jul 2011
Posts: 14
Location: india

PostPosted: Thu Jul 05, 2012 1:29 pm
Reply with quote

Hi Nic,

We need to find out the group number to which the account number belongs to and then extract the records based on the group number . correct ? Would it not need two steps ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 6:35 pm
Reply with quote

Hello,

If the input has multiple account numbers and you want to extract the group of only one, how can this be done without specifying the account number "manually" icon_confused.gif

What do i not understand?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Jul 05, 2012 7:46 pm
Reply with quote

It's OK Dick - I had forgotten thaty he wanted to extract the details for a particular account. Yes there would have to be some sort of intervention, depending on how the acoount number is arrived at. Seems as though SYMNAMES is the candidate here.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 8:22 pm
Reply with quote

Hi Nic,

Yup, SYMNAMES sounds good, but how to provide the account number "automagically"?

Is this to be a user-initiated, on-request process or something that will run regularly only with a different account specified each time?

The more we know, the better suggestions can we make.

d
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: Thu Jul 05, 2012 8:28 pm
Reply with quote

Gerry,

I missed your post earlier. A nice idea. Perhaps the shortest way of expressing it would be with MOD.

However, things move on and we file it away for another time.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jul 05, 2012 11:47 pm
Reply with quote

Vijay Subramaniyan,

The following DFSORT/ICETOOL JCL will give you the desired results. I assumed the following.

1. Your account number to extracted starts in position 17 for a length of 14 bytes. This based on the sample input you provided. Your sample key starts at position 13, but your input is VB so the actual position of the field is 17 ( first 4 bytes is the RDW)

2. The Account number is always the 4th record from the header in a group and you atleast 1 record after the account number belonging to the same group.


The key you need to extract need to be passed via Parm using the JP1 format.

Code:

//STEP0100 EXEC PGM=ICETOOL,PARM='JP1"27187481730348"'         
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN       DD DSN=Your Input VB file,DISP=SHR                                 
//OUT      DD SYSOUT=*                                         
//TOOLIN   DD *                                                 
  SELECT FROM(IN) TO(OUT) ON(5,12,CH) HIGHER(5) USING(CTL1) 
//*   
//CTL1CNTL DD *                                                 
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,12X,5)),                   
  IFTHEN=(WHEN=GROUP,BEGIN=(17,6,CH,EQ,C'ABCDEF'),             
  PUSH=(5:ID=8,SEQ=4)),                                         
  IFTHEN=(WHEN=GROUP,BEGIN=(13,4,ZD,EQ,4,AND,29,14,CH,EQ,JP1), 
  PUSH=(13:13,4)),                                             
  IFTHEN=(WHEN=(13,4,ZD,LT,4),OVERLAY=(13:C'0004'))             
                                                               
  OUTFIL BUILD=(1,4,17)                                         
//*                                                             
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top