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

Manipulating set of records.


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

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Fri Mar 21, 2014 1:38 pm
Reply with quote

Hi Guys,

I'm used to sorting for some time now, but I have a new challenge for which I found no compact answer myself. Please can you guys suggest me on how to do this? Below is the problem statement.

I have an input file(VB) as below:
00 Header
10 Account1 Name
20 Flag1 Flag2
30 Amount spent
10 Account2 Name
20 Flag1 Flag2
30 Amountspent2
99 Trailer

10,20,30 are the record types that denote a single account. Some records may have 40 and 50 as well. But 10 is always the starting record for each account.

My condition for extraction is,
If Name = 'XXXX' and Flag1 ='Y' and say the Account 2 matches this condition my output file should have all the records specific to that accout(10,20,30), and not just the matching records(10,20).

Hope I'm clear in explaining my problem. Let me know otherwise.

Any help would be greatly appreciated.
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Fri Mar 21, 2014 1:44 pm
Reply with quote

An information missed above.

The output file is also a VB.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Mar 21, 2014 10:19 pm
Reply with quote

karthickpearl wrote:

Hope I'm clear in explaining my problem. Let me know otherwise.


Not really. Since we are dealing with VB files it is quite important to mention the positions and length of the fields to evaluated. Also does every account (rectype =10) have a corresponding rectype=20 ? can there be any instances where you don't have rectype=20 record?
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Mon Mar 24, 2014 12:35 pm
Reply with quote

Sure. Below are the informations:

Quote:
Since we are dealing with VB files it is quite important to mention the positions and length of the fields to evaluated.


Rectype,Field Name,Field Start pos,Field Length
10,Name,150,4
20,Flag1,110,1
30(Optional),Trantype 50,2
40(Optional),Tranvalue,25,6


Quote:
Also does every account (rectype =10) have a corresponding rectype=20 ? can there be any instances where you don't have rectype=20 record?


Yes, As mentioned in above, Rectype 10 and 20 will always be mandatory, but 30 & 40 is optional. And there are cases where I would need to evaluate a field in 30 or 40 if present.
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 Mar 24, 2014 12:57 pm
Reply with quote

karthickpearl wrote:
[...]

Quote:
Also does every account (rectype =10) have a corresponding rectype=20 ? can there be any instances where you don't have rectype=20 record?


Yes, As mentioned in above, Rectype 10 and 20 will always be mandatory, but 30 & 40 is optional. And there are cases where I would need to evaluate a field in 30 or 40 if present.


You'd better clarify that.
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Mon Mar 24, 2014 1:11 pm
Reply with quote

Hi Woodger,

Every Rectype 10 will have a corresponding Rectype20 record. But other rectypes are optional.

Every Account will start with Rectype10 but may end with any rectype(20/30/40)

Below are the scenarios,
00 Header
10 Account1 Name
20 Flag1 Flag2
10 Account2 Name
20 Flag1 Flag2
30 Amountspent2
99 Trailer


Here Account-1 has rectypes 10 & 20
Account-2 has Rectypes 10,20,30

Are you clear now?
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 Mar 24, 2014 1:21 pm
Reply with quote

Pearl,

Thanks. Sorry, I failed to use Preview and pickled the nested quote.

What I want to know is about the 30/40-type records. If you are going to do something with them, we may need to know, because otherwise you may break a solution, which will waste someone's time.
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Mon Mar 24, 2014 1:27 pm
Reply with quote

Woodger,

If you notice my first post in this thread.

Quote:
10,20,30 are the record types that denote a single account. Some accounts may have 40 and 50 as well. But 10 is always the starting record for each account.


Actually my last explanation is just a variant of this but with the same meaning.

May be I should have tried to present my problem with more apt words.
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: Mon Mar 24, 2014 7:38 pm
Reply with quote

Hello,

Maybe you should post some actual sample input data that covers the various situations that can occur as well as the output you want when the sample input is processed.
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Mon Mar 24, 2014 8:15 pm
Reply with quote

Hi Dick,

Below are the details again.

My input file(VB):

00 header
10 Company1name
20 Company1address
10 Company2name
20 Company2address
30 Company2productdetails
40 Product price
99 Trailer

Explanation of input file:
The input file contains details of companies. The details of each company start at rectype-10 and end before next rectype-10 record.

Rectype10 - Carries companies names
Rectype20 - Carries address details of the company
Rectype30 - Carries details of products.(Note that not all companies will have this detail, since there are companies which just renders services and products arent applicable)
Rectype40 - Carries products price details.(will be available only when rectype 30 is available)

Filtering condition:
Company name = "IBM" & Productname = "Rationalrose"

Output file Needed(VB):
00 header
10 Company2name
20 Company2address
30 Company2productdetails
40 Product price
99 Trailer


Note: My filtering conditions will span across record types. If the conditions are satisfied then the whole set of records available for that company should show up in my output file.

In the above example the conditions are pointed in Rectype 10 and 30. But my output file will have all the record types available for that company when these conditions are matched.
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: Mon Mar 24, 2014 9:26 pm
Reply with quote

Hello,
Quote:

Below are the details again.
OK, but that is not what i requested . . .

Plase post few rows of sample imput data (content, not field names) and the output that should be produced when your process is run.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Mar 24, 2014 10:55 pm
Reply with quote

karthickpearl wrote:


My condition for extraction is,
If Name = 'XXXX' and Flag1 ='Y' and say the Account 2 matches this condition my output file should have all the records specific to that accout(10,20,30), and not just the matching records(10,20).

Hope I'm clear in explaining my problem. Let me know otherwise.



karthickpearl wrote:
Hi Dick,

Filtering condition:
Company name = "IBM" & Productname = "Rationalrose"



Seriously ? I am not sure how a 1 byte flag can contain the word 'Rationalrose'

And you haven't even provided the position and length of the field which contains the product name. oh well here is a jcl which will give you the desired results based on your initial post. I assumed that your company name is 'xxxx' and the flag ='y'
Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//INA      DD DISP=SHR,DSN=Your Input VB file
//INB      DD DISP=SHR,DSN=Same Input VB file once again
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  OPTION COPY                                                 
  JOINKEYS F1=INA,FIELDS=(5,4,A)                             
  JOINKEYS F2=INB,FIELDS=(5,4,A)                             
  REFORMAT FIELDS=(F1:1,4,5)                                 
  INCLUDE COND=(5,4,CH,EQ,C'XXXX',AND,                       
                9,1,CH,EQ,C'Y')                               
                                                             
  INREC BUILD=(1,4,10)                                       
//*                                                           
//JNF1CNTL DD *                                               
  OMIT COND=(5,2,SS,EQ,C'00,99')                             
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,4X,C'Y',5)),             
  IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),PUSH=(5:155,4))
//*                                                           
//JNF2CNTL DD *                                               
  INCLUDE COND=(5,2,SS,EQ,C'10,20')                           
  INREC IFOUTLEN=10,IFTHEN=(WHEN=INIT,BUILD=(1,4,4X,2Z,5)),   
  IFTHEN=(WHEN=GROUP,BEGIN=(11,2,CH,EQ,C'10'),PUSH=(5:156,4)),
  IFTHEN=(WHEN=(11,2,CH,EQ,C'20'),OVERLAY=(9:116,1))         
  SUM FIELDS=(9,2,BI)                                         
//*
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Tue Mar 25, 2014 4:06 pm
Reply with quote

Dick/Kolusu,

Sorry, I missed stating the field position and length earlier.

I have a restriction and hence could not share the data that I have. I've created an equivalent scenario.

Inputfile(VB):
Code:

0025/03/2014
101001IBM         
2040  clarie street   Branford   Florida 32008
30rationalrose
30DB2
30IMS
101002CISCO
20170 West Tasman Dr. San Jose   CA      95134
30webex
30IPS
101003ACCENTURE
2099  Mccullum street hyderabad  AP      553001
9925/03/2014011


Code:

Copybook for rectype00
05 REC00.                                 
      10 REC00-ID                     PIC  9(02).
      10 REC00-DATE                   PIC  X(10).
     
Copybook for rectype10
05 REC10.
      10 REC10-ID                     PIC  9(02).
      10 REC10-COMPANY-CODE           PIC  9(04).
      10 REC10-COMPANY-NAME           PIC  X(12).

Copybook for rectype20
05 REC20.
      10 REC20-ID                     PIC  9(02).
      10 REC20-COMPANY-ADDR           PIC  X(50).
         15 REC20-COMPANY-ADDR1           PIC  X(04).
         15 REC20-COMPANY-ADDR2           PIC  X(16).
         15 REC20-COMPANY-ADDR3           PIC  X(11).
         15 REC20-COMPANY-ADDR4           PIC  X(08).
         15 REC20-COMPANY-ADDR5           PIC  X(11).
      
Copybook for rectype30
05 REC30.
      10 REC30-ID                     PIC  9(02).
      10 REC30-PRODUCTNAME            PIC  X(20).
    
Copybook for rectype99
05 REC99.                                 
      10 REC99-ID                     PIC  9(02).
      10 REC99-DATE                   PIC  X(10).
      10 REC99-RECCOUNT               PIC  9(03).


Filtering conditions:
company name='IBM' and one of its products is 'DB2'
(OR)
ADDR5 = '95134'

Output file(VB):
Code:

0025/03/2014
101001IBM         
2040  clarie street   Branford   Florida 32008
30rationalrose
30DB2
30IMS
101002CISCO
20170 West Tasman Dr. San Jose   CA      95134
30webex
30IPS
9925/03/2014009
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Mar 25, 2014 11:15 pm
Reply with quote

KarthickPearl,

It is tough to provide a solution for a moving target. Earlier you wanted to validate just record type 10 & 20. Now you also need to evaluate record type 30 and you need the header and trailer too ?

Oh well You already have a sample and you need to modify it.

Hint : Using IFTHEN statement validate the fields you wanted to check and update 2 flags in JNF2CNTL and you are all set.

Good luck
Back to top
View user's profile Send private message
karthickpearl

New User


Joined: 13 Apr 2010
Posts: 35
Location: Chennai

PostPosted: Fri Apr 11, 2014 6:03 pm
Reply with quote

Hi Kolusu,

Thanks for your help. I managed to get my requirement done with your valuable suggestions.

I could not post my code due to some regulations. Hope anyone who views our conversation can get the knowledge.

Thanks once again.
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 only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top