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
 

 

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: 10202
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: 7235

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: 645
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: 7235

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: 645
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: 7235

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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 22 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am


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