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

Merge two files and sum up the count and in a single trailer


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

New User


Joined: 30 Aug 2018
Posts: 1
Location: india

PostPosted: Thu Sep 06, 2018 10:57 am
Reply with quote

Hi

I have a requirement like there are two files with same layout having header , data records and trailer. The trailer contains record count and a sum total. The requirement is to merge these two files and the output should contain one trailer and the trailer count should be updated along with the sum total.
Header record has 'AAP'
Trailer has 'ZZZ'
count starts from position 7 and is of 6 bytes and sum starts from position 13 and is of 9 bytes
record length is 80
What I require is that the second input files appends at the last data record (no sorting or delete duplicate is required) and one trailer is present at end of file with updated count and sum
for below case - expected count is 8 and sum 033333333
pls Kindly help..

the input file layouts are as follows

Input File 1:
Code:

3AAP290110013067836     
343227183918082900050000
343259623818082900008312
343265328318082900015700
343251122418082901500000
ZZZ   000005011111111   

Input File 2:

3AAP2902100000459004000000000046000045900
3212148397801001 00005000180829
3212557750911012 00002500180829
ZZZ 000003022222222

Required output file is,

Output file:

3AAP290110013067836
343227183918082900050000
343259623818082900008312
343265328318082900015700
343251122418082901500000
3AAP2902100000459004000000000046000045900
3212148397801001 00005000180829
3212557750911012 00002500180829
ZZZ 000008033333333

Please suggest how to do in JCL sort step
_________________
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Sep 06, 2018 12:10 pm
Reply with quote

The very first thing that you need to do is to learn how to use the code tags - see above where I have used the tags on ONE input example and not the other. The tagged area retains any spaces where the non tagged does not. I can now see clearly that column 7 does indeed contain the start of a count field 6 bytes long.

It saves people the trouble of looking at what you have posted and trying to figure out the difference between what you say and what is seen.

This is how you use the code tags, below.

Code:
[code]
Your
   stuff
      goes here
[/code]


Your
stuff
goes here

Can you see the difference between the tagged and untagged examples ???

You mention where counts and totals start, but omit to mention that this is ONLY on the trailer record - I have guessed. You need to explain accurately your problem, and of course any preferred solution - see below.

As you have posted in the JCL & VSAM section of the forum, I for one am totally confused as to how you wish to accomplish this. Maybe you wish to use some JCL to invoke a program that accesses a VSAM file ?

Do you have any particular program / software that you wish to use for this, and if by chance it is a SORT product, is it DFSORT or SYNCSORT and which release level do you have installed. And of course that particular section of the forum is where you SHOULD have posted it if you require a SORT solution, or the COBOL section if you require a COBOL solution, etc. etc.

Other silly little things like the RECFM and LRECL are important to posting a problem.

And the most important thing is for YOU to post what you have tried so far, and where it is going wrong
You have tried something already, haven't you ?

So please tell us exactly what you would like along with the things that you have already tried yourself.
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 Sep 06, 2018 1:14 pm
Reply with quote

Quote:
JCL sort

Why do you want to sort your JCL?

As you can see - we are quite picky. Also, this question has been asked before so you should search the forum, preferably before posting. I will let you do that, find some responses that sort of do what you want, let you play around to try and fit your exact requirements and then you can come back with any problems you encounter or a brief message to say that you have resolved it.

And I won't mention that your data is kept in a data set, not a file. Ooops - just did icon_sad.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Sep 06, 2018 6:11 pm
Reply with quote

preeti6,

Welcome to the forums!

For a beginner in the forums, you have done a good job in providing most of the details regarding your problem (better than many other topic starters who have been around for several years here).
Please pay attention to the suggestions/questions above by expat and Nic and post back when you have any updates. Someone would be around to guide you in the right direction.
Good luck.
Quote:

Please suggest how to do in JCL sort step
Depending on which sort product is used at your site (DFSORT-ICE*** messages in SYSOUT, Syncsort-WER*** messages in SYSOUT), the topic can be moved to the appropriate section of this forum.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Sep 06, 2018 7:49 pm
Reply with quote

Welcome to the forum!
Please read the Forum Rules before you post any new topic since that will save everyone's time (including yours) .

Since this is your first post , I did little research behalf of you and it took me just less than 10 minutes to find a post very close to your problem(though I found many more posts with different solutions I posted this one to try and keep it simple) and all that you got to do is just twist it little bit to add header record from second dataset.
Merging of FIles with Headers and Trailers Next time if you do this exercise your self before blindly posting a new topic , you will learn new stuff for sure.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Fri Sep 07, 2018 12:43 am
Reply with quote

And Rohit knows because he was always being told to read the manual or search the forum or... and now he is a valuable contributor. May you end up the same!
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri Sep 07, 2018 1:50 am
Reply with quote

Spot on Nic icon_biggrin.gif
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 To get the count of rows for every 1 ... DB2 3
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top