Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Add record to output without having in input

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

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Fri May 09, 2014 3:00 pm    Post subject: Add record to output without having in input
Reply with quote

Hi folks,

I have an input file containg two fields :
Year/month and a counter :

201202 003
201204 001
201205 004

The output file should contain records like this :

201201 000
201202 003
201203 000
201204 001
201205 004
201206 000

Is it posible to add records to the output file which are missing in the input file using SORT ?

Thanks in advance
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10456
Location: italy

PostPosted: Fri May 09, 2014 3:17 pm    Post subject: Reply to: Add record to output without having in input
Reply with quote

see if this
http://www.ibmmainframes.com/viewtopic.php?t=60704&highlight=sort+missing+records
can be of help
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Fri May 09, 2014 4:16 pm    Post subject: Reply to: Add record to output without having in input
Reply with quote

If you have a limited number of years, with a (naturally) limited number of months, then it would be possibly by generating a file of YYYYMM and then using that file in a JOINKEYS, with JOIN UNPAIRED,F1,F2 (with the generated file as F2).

For unmatched F1, matched F1-F2, output the F1 unchanged. For unmatched F2, output the F2.

If that is not what you have, then your reading of enrico's link will get you to write a program in a general-purpose language, or code-up (manually or generated) a lot of statements and possible multiple passes to do it in DFSORT.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 710
Location: Pennsylvania

PostPosted: Fri May 09, 2014 5:28 pm    Post subject:
Reply with quote

A simpler approach would be create a second input file containing your 'zero' values for each month.

Concatenate the two files together, and sort on your key with sum fields=none.

The zero value file will fill in the gaps.

See example and results:
Code:
//SORT1      EXEC PGM=SORT
//*
//SYSUDUMP   DD SYSOUT=*
//SYSOUT     DD SYSOUT=*
//*
//SORTIN     DD *
201202 003
201204 001
201205 004
/*
//           DD *
201201 000
201202 000
201203 000
201204 000
201205 000
201206 000
/*
//*
//SORTOUT    DD SYSOUT=Z
//*
//SYSIN      DD *
  SORT FIELDS=(01,06,CH,A),EQUALS
  SUM FIELDS=NONE
/*
//*


Results:
Code:
********************************* TOP OF DATA ********
201201 000
201202 003
201203 000
201204 001
201205 004
201206 000
******************************** BOTTOM OF DATA ******
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Fri May 09, 2014 5:54 pm    Post subject: Reply to: Add record to output without having in input
Reply with quote

Yes, Dave, unproblematic with what has been shown.

I'm expecting to discover that it is subordinate to a key, where it is lots of SORT code, or needing to SORT the data, or generating a sizeable file, rather than a simple program.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 710
Location: Pennsylvania

PostPosted: Fri May 09, 2014 6:05 pm    Post subject:
Reply with quote

Bill,

I try to formulate my approach to the facts I have in front of me (I know foolish on this forum).

I do no assuming facts not in evidence.

If the OP ever gets back on, we will see what happens.
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Sat May 10, 2014 2:40 pm    Post subject:
Reply with quote

Bill,

I always consider the actuall year, so the max. number of output records will be twelve. I will try your suggestion, creating a small REXX for generating YYYYMM and following DFSORT with JOINFILE.

Thank you very much for help !
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Sat May 10, 2014 3:42 pm    Post subject: Reply to: Add record to output without having in input
Reply with quote

You can do the generation with SORT as well.

Have a look at REPEAT on OUTFIL. You have 2014 on SYSIN, REPEAT=12, and OVERLAY a SEQNUM which is two digits zoned-decimal.

Do look at Dave's suggestion as well.
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 VSAM - Accessing beyond record size Benchwarmer JCL & VSAM 6 Wed Apr 11, 2018 9:20 pm
No new posts How to build one file from two input ... daniele DFSORT/ICETOOL 5 Tue Feb 27, 2018 6:45 pm
No new posts How to get the output from submit com... Joanna2016 CLIST & REXX 10 Tue Feb 06, 2018 7:26 am
No new posts Copying only first and last word from... chandan.inst SYNCSORT 4 Wed Jan 31, 2018 4:19 pm
No new posts How to select record x+7 or x+2 based... JoAnn Kulcyk SYNCSORT 6 Tue Jan 16, 2018 10:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us