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

Insert a value with JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
danylele74

New User


Joined: 03 Jul 2014
Posts: 28
Location: Italy

PostPosted: Mon Feb 16, 2015 7:14 pm
Reply with quote

Hello,

I have to solve a problem.

I have a file where, for the same key, I removed duplicate records writing in a second file.

After processing the first file (without keys doubles) I need to insert a value in the second file with the same key.


example:


file 1

Code:
Key Value
001
001
001
002
002
003



Removing duplicate keys

file 1
Code:
Key  Value
001
002
003


file 2
Code:
Key Value
001
001
002



File 1 after processing

Code:
Key Value
001 555
002 666
003 777



Output file

Code:
Key Value
001 555
001 555
001 555
002 666
002 666
003 777


I need you help.

Thank you.
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 Feb 16, 2015 7:37 pm
Reply with quote

Your final output just looks like your original file with some extra stuff (source unknown) added to it.
Back to top
View user's profile Send private message
danylele74

New User


Joined: 03 Jul 2014
Posts: 28
Location: Italy

PostPosted: Mon Feb 16, 2015 7:42 pm
Reply with quote

yes. It's the same file but with the "value" field filled after processing
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 Feb 16, 2015 7:47 pm
Reply with quote

OK, but where do the new values come from and how are they applied? You want to do this with your SORT product? Which one do you have?
Back to top
View user's profile Send private message
danylele74

New User


Joined: 03 Jul 2014
Posts: 28
Location: Italy

PostPosted: Mon Feb 16, 2015 8:08 pm
Reply with quote

The "original" file is

Code:

Key               Fied-X
001
001
001
002
002
003



The original file without duplicate key (called NODUP)

Code:

Key               Fied-X
001
002
003



The original file with ONLY duplicate key (called DUP)

Code:

Key               Fied-X
001
001
002



File NODUP after processing (processed by a program)

Code:

Key               Fied-X
001                555
002                666
003                777


The output file (NODUP + DUP)

Code:

Key               Fied-X
001               555
001               555
001               555
002               666
002               666
003               777
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 Feb 16, 2015 8:26 pm
Reply with quote

OK, it would seem to me that the program which puts the new value one should have no real problem with processing the original file: keep a note of key change; if so, add the value, also save it; if not key change, add the saved value.

For what you have ended up with, use MERGE with OPTION EQUALS and IFTHEN=(WHEN=GROUP with KEYBEGIN to PUSH the value from the first record to all records in the group.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Identify Program Insert DB2 7
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
Search our Forums:

Back to Top