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

Add record to output without having in input


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

New User


Joined: 22 Nov 2007
Posts: 64
Location: Germany

PostPosted: Fri May 09, 2014 3:00 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri May 09, 2014 3:17 pm
Reply with quote

see if this
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 09, 2014 4:16 pm
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: 792
Location: Pennsylvania

PostPosted: Fri May 09, 2014 5:28 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 09, 2014 5:54 pm
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: 792
Location: Pennsylvania

PostPosted: Fri May 09, 2014 6:05 pm
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: 64
Location: Germany

PostPosted: Sat May 10, 2014 2:40 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat May 10, 2014 3:42 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top