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

Concatenation logic with DFSORT


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

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Jun 19, 2013 7:33 pm
Reply with quote

Hello,

I have a requirement where I have to update one of the input file with the last date of the current month if the DD parameter is greater than 12. If it is less that 12, last date of the previous month should be assigned.

Consider the date 06/11/2013. Since the DD is less than 12, the input file should be assigned the value 05/31/2013.

Here is sample code:

Current date production file: CURRENT.DATE.FILE --> 06/11/2013
Previous month last date production file: PREVMONT.DATE.FILE --> 05/31/2013
Latest month last date production file: LATESTMT.DATE.FILE --> 06/30/2013
Input file: FINAL.DATE.FILE
Code:

//STEP01 EXEC PGM=DFSORT
//SORTIN DD DSN=LATESTMT.DATE.FILE,DISP=SHR
//SORTOUT DD DSN=FINAL.DATE.FILE,
//          DISP=(NEW,CATLG,DELETE)
//SYSOUT DD SYSOUT=*                                   
//SYSIN DD *
  SORT FIELDS=COPY 
/*
//STEP02 EXEC PGM=DFSORT
//SORTIN DD DSN=CURRENT.DATE.FILE,DISP=SHR
//SORTOUT DD DSN=TEMP.CURRENT.DATE,
//          DISP=(NEW,CATLG,DELETE)
//SYSOUT DD SYSOUT=*                                   
//SYSIN DD *
  SORT FIELDS=COPY
  INCLUDE COND=(4,2,CH,LE,C'12')
/*
//STEP03 EXEC PGM=IDCAMS                                 
//IN DD DSN=TEMP.CURRENT.DATE,DISP=SHR
//SYSPRINT DD SYSOUT=*                                   
//SYSIN DD *
  PRINT INFILE(IN) COUNT(1)                             
/*         
//STEP04 EXEC PGM=IEBGENER,COND=(0,NE,STEP03)                                 
//SYSUT1 DD DSN=PREVMONT.DATE.FILE,DISP=SHR
//SYSUT2 DD DSN=FINAL.DATE.FILE,DISP=(OLD,KEEP,KEEP)
//SYSPRINT DD SYSOUT=*                                   
//SYSIN DD DUMMY
//*


I need to implement a similar logic in a single step using DFSORT. Could you please provide some other alternatives.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 19, 2013 7:47 pm
Reply with quote

Could you please let us know where is DATE is being assigned??
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Wed Jun 19, 2013 7:57 pm
Reply with quote

Your posted code bears no resemblence at all to what you want to do.

You are creating a file in step 1 and then overwriting it in step 4, so why bother wasting the resource to copy in a file which is never used and merely overwritten.

You create a subset of another file and never use it.

I think that you need to explain exactly what is required in much greater detail.

I for one am totally confused by the code you have posted.

Also, please learn to use the CODE tags to make your post more eyeball friendly.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Jun 19, 2013 9:05 pm
Reply with quote

Hi,

I guess the TS is copying the current months last date in advance to the output file. And it is overwritten by previous months last date ONLY if the current date-DD is less than or equal to 12 since the IDCAMS issues RC=0 in this case. Else if DD > 12 the IDCAMS issues RC=4 and the output file remains as it is. ie. with current months last date copied in step1.

So the above 4-step process he needs in one-step-DFSORT.
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Jun 19, 2013 9:22 pm
Reply with quote

Pandora-Box wrote:
Could you please let us know where is DATE is being assigned??


Hi Pandora Box,

The date is present inside the datasets:
CURRENT.DATE.FILE
PREVMONT.DATE.FILE
LATESTMT.DATE.FILE
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Jun 19, 2013 9:27 pm
Reply with quote

expat wrote:
Your posted code bears no resemblence at all to what you want to do.

You are creating a file in step 1 and then overwriting it in step 4, so why bother wasting the resource to copy in a file which is never used and merely overwritten.

You create a subset of another file and never use it.

I think that you need to explain exactly what is required in much greater detail.

I for one am totally confused by the code you have posted.

Also, please learn to use the CODE tags to make your post more eyeball friendly.


Hi Expat,

Since I this was my first post, I was not aware of CODE tags, will follow the same going forward.

Arun Raj has explained the logic mentioned in my code. My requirement is that I need to implement the same logic in a single DFSORT step. Please advise
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Wed Jun 19, 2013 9:29 pm
Reply with quote

Arun Raj wrote:
Hi,

I guess the TS is copying the current months last date in advance to the output file. And it is overwritten by previous months last date ONLY if the current date-DD is less than or equal to 12 since the IDCAMS issues RC=0 in this case. Else if DD > 12 the IDCAMS issues RC=4 and the output file remains as it is. ie. with current months last date copied in step1.

So the above 4-step process he needs in one-step-DFSORT.


Hi Arun,

Any suggestions from your side. Thanks in advance.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Jun 19, 2013 10:52 pm
Reply with quote

Ranjith,

Since you already have the dates in files, one way would be to read PREVMONT.DATE.FILE and LATESTMT.DATE.FILE, create symbols for prev-month last date and current-month last date and use it in the SYMNAMES dd for the next step where the current date file can be read and the required symbol can be written to output based on the current date DD value.

Alternatively you could also have a look at the date arithmetic functions available in DFSORT to achieve the same.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Jun 19, 2013 11:20 pm
Reply with quote

I am not sure about the DFSORT date arithmetic functions, but looks like something like this could be done,

1. Find the current date in yymmdd format.
2. If current date dd <= 12, BUILD output date = current date - current date dd days
Else, BUILD output date = next months first day (current date yymm + 1 month with date hard-coded as 01) - 1 day
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: Thu Jun 20, 2013 1:23 am
Reply with quote

Two date records on separate files. Use JOINKEYS. Extend each record to include a byte with the same value (in JNFnCNTL) on each file. Match on the "value". REFORMAT record to include the dates "side-by-side". In the main-task, compare the dd's and output one or other date record/value, depending on the dd test.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Jun 20, 2013 6:29 am
Reply with quote

Another way just occurred to me after reading Bill's response
Code:
Previous month last date production file: PREVMONT.DATE.FILE --> 05/31/2013
Latest month last date production file: LATESTMT.DATE.FILE --> 06/30/2013
-Concatenate the above two files in SORTIN input, Use WHEN=GROUP with RECORDS=2, and PUSH the date in first record to propogate it to the second record
so that we have both the dates "side-by-side" on record-2.
-Check for current date - dd value using IFTHEN and BUILD output date value accordingly from the dates present in record-2.
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: Thu Jun 20, 2013 11:52 am
Reply with quote

Yes, Arun.

There's also the symbols approach. TS might not like it due it it being more than one step (two) but there'd be a/some symbols with date values that could then be used within any DFSORT step :-)
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Jun 20, 2013 12:00 pm
Reply with quote

Can anyone tell me does TS want last date for a month for a given date?
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Jun 20, 2013 12:14 pm
Reply with quote

Yes Bill, this requirement does not need another step, the Concatenation approach could do in one-step and it does not need any sorting as well. icon_smile.gif

Pandora,

He needs the last date of current month if current day dd > 12.
And last date of previous month if current day dd < or =12
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Jun 20, 2013 12:57 pm
Reply with quote

Thanks for the clarification Arun
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: Thu Jun 20, 2013 1:03 pm
Reply with quote

Well, the symbols would be two steps with the way the TS wants it, but if the symbols were available, perhaps the additional file would not be needed? So it'd be one step. Very small overhead in making use of it later.

However, if the file is not destined for use in SORT steps anyway. the symbols would have less use.

Of course, if it were like that, then the "date file" should contain more than just the "current business/data date", and we wouldn't be looking at all this is the first place... the "no step" solution :-)
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Jun 20, 2013 3:32 pm
Reply with quote

Without symbols, something like this can achieve the same concatenating the last date(current and prev month) files, again one additional file will not be needed here. Input was assumed to be of FB/LRECL=80
Code:
//STEP01   EXEC  PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                       
//SORTOUT  DD SYSOUT=*                                       
//SORTIN   DD DISP=SHR,DSN=PREVMONT.DATE.FILE
//         DD DISP=SHR,DSN=LATESTMT.DATE.FILE
//SYSIN    DD  *                                             
 OPTION COPY                                               
 OUTREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(81:SEQ=1,1,10)),
       IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(92:DATE1))     
 OUTFIL IFOUTLEN=10,INCLUDE=(81,1,ZD,EQ,2),                 
       IFTHEN=(WHEN=(98,2,ZD,LE,12),OVERLAY=(1:82,10))                         
/*                                                           

/*
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Jun 20, 2013 4:54 pm
Reply with quote

Or something like this, if we are to make use of all the 3 files concatenated in the input.
Code:
//STEP01   EXEC  PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTOUT  DD SYSOUT=*                                         
//SORTIN   DD DISP=SHR,DSN=CURRENT.DATE.FILE                   
//         DD DISP=SHR,DSN=PREVMONT.DATE.FILE                   
//         DD DISP=SHR,DSN=LATESTMT.DATE.FILE                   
//SYSIN    DD  *                                               
 OPTION COPY                                                   
 OUTREC IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(81:SEQ=1,1,10))     
 OUTFIL INCLUDE=((85,2,ZD,LE,12,AND,81,1,ZD,EQ,2),OR,           
                 (85,2,ZD,GT,12,AND,81,1,ZD,EQ,3)),BUILD=(1,80)
/*                                                             
Back to top
View user's profile Send private message
Ranjith741

New User


Joined: 04 Jun 2013
Posts: 9
Location: India

PostPosted: Thu Jun 20, 2013 11:16 pm
Reply with quote

Thanks Arun and Bill. The concatenation logic worked fine for me. Cheers 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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts DFSORT - VB file RDW getting overridden DFSORT/ICETOOL 3
Search our Forums:

Back to Top