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

how to split a file into two files based on a date


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

New User


Joined: 21 Dec 2005
Posts: 7

PostPosted: Tue Feb 14, 2006 3:40 pm
Reply with quote

hi ,

i have a file which has to be split into two files based on a date which is in the format 'mm-dd-yyyy' .. how can i do it??

sree
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Feb 14, 2006 5:36 pm
Reply with quote

can you pls give the details like ,
one file contains the records which matches the given date (date is current date/?) and
the other file contains the records that doesn't match the date.

please let know the exact details


regards,
jai
Back to top
View user's profile Send private message
sreenatha

New User


Joined: 21 Dec 2005
Posts: 7

PostPosted: Tue Feb 14, 2006 8:48 pm
Reply with quote

suppose the contents are as follows in the input file

details date

detail 1 02-12-2006
detail 2 02-01-2006
detail 3 12-10-2005
detail 4 01-04-2006
detail 5 05-02-2005

my requirement is as follows;

all the records which are having date greater than (current date - 3 months) must be seperated from other records


the output will be as fllows ;

detail date

detail 1 02-12-2006
detail 2 02-01-2006
detail 4 01-04-2006

other file should have the remaining records
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Feb 14, 2006 8:57 pm
Reply with quote

I do know enough about DFSORT to know that you will have to provide the value for (current date - 3 months) as a symbolic to DFSORT program via the SYMNAMES DD statement. Will that be possible?
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Tue Feb 14, 2006 8:58 pm
Reply with quote

Hope this link helps.(in this post trying to include the records between the date ranges but your requirement requires omit and include).

ibmmainframes.com/viewtopic.php?t=7537

regards,
jai
Back to top
View user's profile Send private message
pzmohanty

New User


Joined: 17 Feb 2006
Posts: 1
Location: Hyderabad

PostPosted: Fri Feb 17, 2006 1:35 am
Reply with quote

Hi,

Hope this code will solve ur problem


Code:
//*******************************************************
//STEP0010 EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT)     
//*******************************************************       
//STEPLIB  DD  DSN=XXX.YYY.ZZZ,DISP=SHR       
//SYSTSIN  DD  *                                         
  DSN SYSTEM(XXX)                                       
  RUN PROGRAM(DSNTIAUL) PLAN(DSNTIAUL) PARMS('SQL') -   
      LIB ('AAA.BBB.CCC')                 
  END                                                   
/*                                                       
//SYSIN    DD  *                                         
 SELECT CHAR('CUTOFFDATE'),                             
        CHAR(','''),                                     
        SUBSTR(CHAR(CURRENT DATE - 3 MONTHS),7,4) ,     
        SUBSTR(CHAR(CURRENT DATE - 3 MONTHS),1,2) ,           
        SUBSTR(CHAR(CURRENT DATE - 3 MONTHS),4,2) ,           
        CHAR('''') ,                                         
        CHAR(' ',59)                                         
   FROM SYSIBM.SYSDUMMY1;                                     
/*                                                           
//SYSREC00 DD  DSN=&T1,         
//             DISP=(,PASS),                         
//             UNIT=SYSDA,                                   
//             SPACE=(CYL,(250,250),RLSE)                     
//SYSPUNCH DD  DUMMY                                         
//SYSTSPRT DD SYSOUT=*                                       
//SYSPRINT DD SYSOUT=*                                       
//SYSUDUMP DD SYSOUT=*                                       
//*******************************************************
//STEP0200 EXEC PGM=SORT                                     
//*******************************************************
//SYMNAMES DD DSN=&T1,DISP=SHR 
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DSN=DATASET.NAME.INPUT,         
//            DISP=SHR                                       
//SORTOF1  DD DSN=OUTPUT.DATASET.NAME1,               
//         DISP=(NEW,CATLG,DELETE),                               
//         UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),                   
//         DCB=(LRECL=600,RECFM=FB,BLKSIZE=0)                     
//SORTOF2  DD DSN=OUTPUT.DATASET.NAME2,   
//         DISP=(NEW,CATLG,DELETE),                               
//         UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),                   
//         DCB=(LRECL=600,RECFM=FB,BLKSIZE=0)                     
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC FIELDS=(1,600,210,4,204,2,207,2)                           
  OUTFIL FILES=1,INCLUDE=(601,08,CH,GE,CUTOFFDATE),OUTREC=(1,600) 
  OUTFIL FILES=2,SAVE,OUTREC=(1,600)                               
/*                                                                 
//*   


This JCL has 2 steps ,
in Step 1 , we are creating a dataset containg 1 record with following data :
CUTOFFDATE,'CCYYMMDD'

The step 2 is a sort step which uses the dataset created in step 1 as SYMNAMES DD & in SORT card , CUTOFFDATE is replaced by value in the dataset created in STEP 1.
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Fri Feb 17, 2006 4:01 pm
Reply with quote

Hi Mohanthy,

Thanks it helps alot, but before i would like to clarify a question

Suppose in the temp file the record looks as
Cutoffdate , '20051105' that temp file is used in the step0200 with the dd name sysnames.

My question is when i use cutoffdate in the sort control card, will it treat as symbol name or will it take what ever the value that come after cutoffdate that start and end with codes(replaced) in the record in the temp file available at dd name sysnames.
is the sysnames is the predefined dd name.

please clarify

jai
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 17, 2006 9:34 pm
Reply with quote

SYMNAMES (not sysnames) is the ddname used for DFSORT Symbol statements. The Symbol statement:

CUTOFFDATE,'20051105'

tells DFSORT to substitute C'20051105' for CUTOFFDATE wherever CUTOFFDATE is found in DFSORT or ICETOOL control statements.

DFSORT changes:

INCLUDE=(601,08,CH,GE,CUTOFFDATE)

to

INCLUDE=(601,08,CH,GE,C'20051105')

Since the job creates the CUTOFFDATE statement dynamically using the current date, the constant in the CUTOFFDATE statement will change each day.

For complete information on DFSORT Symbols, see Chapter 7 in "z/OS DFSORT Application Programming Guide":

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA10/7.0?DT=20050222160456

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Fri Feb 17, 2006 11:01 pm
Reply with quote

Thanks Frank for the clarification.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top