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
 

 

Insert records inbetween 2 matching keys between 2 files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
VIGNRSH
Warnings : 1

New User


Joined: 18 Mar 2007
Posts: 44
Location: New Jersey,USA

PostPosted: Tue Apr 01, 2008 1:36 am    Post subject: Insert records inbetween 2 matching keys between 2 files
Reply with quote

Hi ,
I have to implement the following logic

Input file1:
Has records which specifies that i have to insert these records after a particular key present in 2 input file.

For Ex:
Input File1:
1110000 xxxxxxxxxxxxxxxxxxxx
1110001 xxxxxxxxxxxxxxxxxxxx
1110002 xxxxxxxxxxxxxxxxxxxx

Input file 2:
1111000 xxxxxxxxxxxxxxxxxxxx
aaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbb
cccccccccccccccc
11110001 xxxxxxxxxxxxxxxxxx
dddddddddddddddddd
eeeeeeeeeeeeeeeeee
ffffffffffffffffffffffffffffffffffff
ggggggggggggggggggggggg
hhhhhhhhhhhhhhhhhhhhhhhhhh

Here INput file2:
I have to insert these records in output file as
aaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbb
cccccccccccccccc
into input file 2 between these matching keys
1111000 xxxxxxxxxxxxxxxxxxxx
.
.


11110001 xxxxxxxxxxxxxxxxxx


Output file:
1110000 xxxxxxxxxxxxxxxxxxxx
111000A aaaaaaaaaaaaaaaaaaaaa
111000B bbbbbbbbbbbbbbbbb
111000C ccccccccccccccccc
1110001 xxxxxxxxxxxxxxxxxxxx
111001A ddddddddddddddd
111001B eeeeeeeeeeeeeeeeee
111001C ffffffffffffffffffffffffffffffffffff
111001D ggggggggggggggggggggggg
111001E hhhhhhhhhhhhhhhhhhhhhhhhhh
1110002 xxxxxxxxxxxxxxxxxxxx
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Tue Apr 01, 2008 2:16 am    Post subject: Reply to: Insert records inbetween 2 matching keys between 2
Reply with quote

VIGNRSH,

can you please answer the following?

1. Does the key in file 2 always start with '1'?
2. What is the LRECL and RECFM of the input files?
3. What is the Criteria to append the alphabets at the end of the key? (A,B,C...)

Quote:

111000A aaaaaaaaaaaaaaaaaaaaa
111000B bbbbbbbbbbbbbbbbb
111000C ccccccccccccccccc
Back to top
View user's profile Send private message
VIGNRSH
Warnings : 1

New User


Joined: 18 Mar 2007
Posts: 44
Location: New Jersey,USA

PostPosted: Tue Apr 01, 2008 2:40 am    Post subject:
Reply with quote

No , it can be anynumeral or alphabet.

for Ex:
if it like 11110000
and next key is 11110010

it should add keys like,
11110000
1111000A
1111000B
1111000c
..

11110010

to make them appear sensible and look sorted too..

Lrecl is 80 for all files....
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Apr 01, 2008 4:20 am    Post subject: Reply to: Insert records inbetween 2 matching keys between 2
Reply with quote

Quote:

No , it can be anynumeral or alphabet.


VIGNRSH,

It is going to be tough given that there is no way to identify the Key record from the other detail records in file 2. Is there an indicator or something in file 2 which identifies the key record? If there is an indicator then the grouping is easy.

Also you append A,B,C,D... to the records from file2, what happens if you have more than 26 records for a single key?

What is the max number of records u can have in file 1?
Back to top
View user's profile Send private message
john george

New User


Joined: 06 Nov 2007
Posts: 2
Location: chennai

PostPosted: Tue Apr 01, 2008 10:54 am    Post subject:
Reply with quote

Yes, I have one idea i n my mind.

for generating the key, in file1, i thought of the following logic,
11110000
.xxxxxxxxxxxxx <--records to be inserted
.yyyyyyyyyyyy <--records to be inserted
.xxxxxxxxxxxxxxx <--records to be inserted
11110001

i thought we can modify the input file first to generate keys
11110000
1111000A xxxxxxxxxxxxx
1111000B yyyyyyyyyyyy
1111000C xxxxxxxxxxxxxxx
11110001
and then do insertion in file 2 , whenever the key matches until the second key match.

For me , i have not come across situations , where i have to insert greater than 26 alphabets.

Could u now solve this?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Apr 01, 2008 9:24 pm    Post subject:
Reply with quote

john george wrote:
Yes, I have one idea i n my mind.
Could u now solve this?


John George,

I am not sure how to generate the keys as the detailed records in the 2nd file are variable. Even if I can generate how am I going to map them to the detail records in file2?

If you know a way please let me know

I have a round about solution which requires 6 passes of data. It can be reduced to half or even less if we have identifier in file 2 for the key record
Back to top
View user's profile Send private message
VIGNRSH
Warnings : 1

New User


Joined: 18 Mar 2007
Posts: 44
Location: New Jersey,USA

PostPosted: Fri Apr 04, 2008 1:56 am    Post subject:
Reply with quote

Hi Skolusu ,
I had got it confimed that , those records that have to be inserted can be prefixed with key like ADD.
File1:
Input File1:
1110000 xxxxxxxxxxxxxxxxxxxx
1110001 xxxxxxxxxxxxxxxxxxxx
1110002 xxxxxxxxxxxxxxxxxxxx

Input file 2:
11110000 xxxxxxxxxxxxxxxxxxxx
~~add~~ aaaaaaaaaaaaaaaaaaaaa
~~add~~ bbbbbbbbbbbbbbbbb
11110001 xxxxxxxxxxxxxxxxxx

But it should insert only if key s are matching in two files!
11100000 matches both files
11110001 matches both files
so only those records inbetween them has to be inserted .

So now my output should be,
Output file:
11100000 xxxxxxxxxxxxxxxxxxxx
1110000A aaaaaaaaaaaaaaaaaaaaa
1110000B bbbbbbbbbbbbbbbbb
11100001 xxxxxxxxxxxxxxx


can u guide me to fix this now?Thanks in Advance!
Back to top
View user's profile Send private message
VIGNRSH
Warnings : 1

New User


Joined: 18 Mar 2007
Posts: 44
Location: New Jersey,USA

PostPosted: Fri Apr 04, 2008 2:24 am    Post subject:
Reply with quote

HI ,
Forgot to add. The inserted records should have sequence number in the pos 60 just to determine how many times it has been updated.

for Ex.
Output file:
11100000 xxxxxxxxxxxxxxxxxxxx 132123
1110000A aaaaaaaaaaaaaaaaaaaaa a00006
1110000B bbbbbbbbbbbbbbbbb a00006
11100001 xxxxxxxxxxxxxxx 132124

Here probably we can generate the Seqnum intialised by first searching the input file for the most recent value and write to a file and then start
1110000 xxxxxxxxxxxxxxxxxxxx 132123
1110001 xxxxxxxxxxxxxxxxxxxx 132124
1110002 xxxxxxxxxxxxxxxxxxxx 132125
111002A xxxxxxxxxxxxxxxxxxxx a00005
1110003 xxxxxxxxxxxxxxxxxxxx 132125
our seq num generation from that.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Apr 04, 2008 3:12 am    Post subject:
Reply with quote

VIGNRSH wrote:
Hi Skolusu ,
I had got it confimed that , those records that have to be inserted can be prefixed with key like ADD.
can u guide me to fix this now?Thanks in Advance!


Vignrsh,

Here is a DFSORT/ICETOOL JCL which will give you the desired results. However I dont understand the count part as you show different results. You need to explain it in detail as to what you want clearly

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN1      DD *                                             
11110000 XXXXXXXXXXXXXXXXXXXX                               
11110001 XXXXXXXXXXXXXXXXXXXX                               
11110002 XXXXXXXXXXXXXXXXXXXX                               
//IN2      DD *                                             
11110000 XXXXXXXXXXXXXXXXXXXX                               
~~ADD~~ AAAAAAAAAAAAAAAAAAAAA                               
~~ADD~~ BBBBBBBBBBBBBBBBB                                   
11110001 XXXXXXXXXXXXXXXXXX                                 
~~ADD~~ CCCCCCCCCCCCCCCCC                                   
~~ADD~~ DDDDDDDDDDDDDDDDD                                   
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                                               
  COPY FROM(IN1) USING(CTL1)                                 
  SPLICE FROM(IN2) TO(T1) WITHALL KEEPNODUPS -               
      ON(81,8,CH) WITH(01,80) USING(CTL2)                     
  SORT FROM(T1) USING(CTL3)                                   
/*                                                           
//CTL1CNTL DD *                                               
  OUTFIL FNAMES=T1,BUILD=(01,80,1,8)                         
/*                                                           
//CTL2CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,                                   
       OVERLAY=(81:SEQNUM,8,ZD)),                             
        IFTHEN=(WHEN=(1,7,CH,NE,C'~~ADD~~'),                 
       OVERLAY=(81:SEQNUM,8,ZD,1,8)),                         
        IFTHEN=(WHEN=NONE,                                   
       OVERLAY=(89:SEQNUM,8,ZD,                               
                81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))         
                                                             
  OUTFIL FNAMES=T1,                                           
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(89,8))),
  IFTHEN=(WHEN=INIT,OVERLAY=(81:81,1,ZD,ZDC,LENGTH=1)),       
  IFTHEN=(WHEN=INIT,BUILD=(89,7,81,1,8,72,89,8))             
/*                                                           
//CTL3CNTL DD *                                               
  OPTION EQUALS                                               
  SORT FIELDS=(81,8,CH,A)                                     
  OUTFIL FNAMES=OUT,BUILD=(01,80)                             
/*                                                           


The output from the above job is

Code:

11110000 XXXXXXXXXXXXXXXXXXXX         
1111000A AAAAAAAAAAAAAAAAAAAAA       
1111000B BBBBBBBBBBBBBBBBB           
11110001 XXXXXXXXXXXXXXXXXXXX         
1111000A CCCCCCCCCCCCCCCCC           
1111000B DDDDDDDDDDDDDDDDD           
11110002 XXXXXXXXXXXXXXXXXXXX         
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Matching with Key at different postions. rajatbagga DFSORT/ICETOOL 12 Wed Nov 09, 2016 10:58 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm


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