View previous topic :: View next topic
Author
Message
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Hi,
I have requirement to check date condition using sort.
Input is
Code:
f1 date1 date2 f2
--- -------- -------- ---
asd 20131209 20131208 dsd
dbd 20130930 20131209 esd
sds 20130923 20131213 fsd
if date1 < 20130930 then i need move date2 to date1
if date1 >= 20130930 then i need to move the fixed date 20130930 to date1
output should be
Code:
asd 20130930 20131208 dsd
dbd 20130930 20131209 esd
sds 20131213 20131213 fsd
I am also working on this, If i complete it i will post the code. Some one already done this, please share it with me.
Regards,
Magesh
Back to top
Nic Clouston Global Moderator Joined: 10 May 2007Posts: 2455 Location: Hampshire, UK
Forget the fact that they are dates! In the format shown they are just numbers and can be directly compared as numeric (or character) fields.
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Hi,
I could get the second condition, could some one help me in getting first condition.
condition 1 : if date1 < 20130930 then i need to move date2 to date1
condition 2 : if date1 >= 20130930 then i need to move the fixed date 20130930 to date1
Code:
//STEP01 EXEC PGM=SORT
//SORTIN DD *
20131209 20131208
20130930 20131209
20130923 20131213
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(1,8,CH,GE,C'20130930'),
OVERLAY=(1:C'20130930'))
/*
Regards,
Magesh
Back to top
Robert Sample Global Moderator Joined: 06 Jun 2008Posts: 8696 Location: Dubuque, Iowa, USA
Have you looked in your copy of the sort manual for the syntax of the OVERLAY statement?
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Thanks got it,
Code:
//STEP01 EXEC PGM=SORT
//SORTIN DD *
ASD 20131209 20131208 DSD
DBD 20130930 20131209 ESD
SDS 20130923 20131213 FSD
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(4,8,CH,LT,C'20130930'),OVERLAY=(4:13,8)),
IFTHEN=(WHEN=(4,8,CH,GE,C'20130930'),
OVERLAY=(4:C'20130930'))
/*
Regards,
Magesh
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Good for getting there yourself.
However.
You give yourself a maintenance problem doing it that way. What if you need to change the date for the test, but you typo/forget one of them?
Code:
//STEP01 EXEC PGM=SORT
//SORTIN DD *
ASD 20131209 20131208 DSD
DBD 20130930 20131209 ESD
SDS 20130923 20131213 FSD
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(4,8,CH,LT,C'20130930'),
OVERLAY=(4:13,8)),
IFTHEN=(WHEN=NONE,
OVERLAY=(4:C'20130930'))
/*
Symbols would also help, but everyone's too busy to save themselves time :-)
Code:
//STEP01 EXEC PGM=SORT
//SYMNAMES DD *
ACCOUNT-ANALYSIS-DATE,4,8,CH
ACCOUNT-START-DATE,13,8,CH
CUTOFF-DATE,C'20130930'
//SYMNOUT DD SYSOUT=*
//SORTIN DD *
ASD 20131209 20131208 DSD
DBD 20130930 20131209 ESD
SDS 20130923 20131213 FSD
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(ACCOUNT-ANALYSIS-DATE,
LT,CUTOFF-DATE),
OVERLAY=(ACCOUNT-ANALYSIS-DATE:
ACCOUNT-START-DATE)),
IFTHEN=(WHEN=NONE,
OVERLAY=(ACCOUNT-ANALYSIS-DATE:
CUTOFF-DATE))
/*
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Thanks Bill,
But My out of the jcl looks different
ASD 20131209 20131208 DSD
DBD 20131200 20131209 ESD
SDS 20131213 20131213 FSD
why it showing 00
output took from spool
Code:
------- ORIGINAL STATEMENTS FROM SYMNAMES -------
ACCOUNT-ANALYSIS-DATE,4,8,CH
ACCOUNT-START-DATE,13,8,CH
CUTOFF-DATE,C'20130930'
------------------ SYMBOL TABLE -----------------
ACCOUNT-ANALYSIS-DATE,4,8,CH
ACCOUNT-START-DATE,13,8,CH
CUTOFF-DATE,C'20130930'
ASD 20131209 20131208 DSD
DBD 20131200 20131209 ESD
SDS 20131213 20131213 FSD
ICE270I 0 PROCESSING SYMNAMES STATEMENTS
ICE280I 1 ORIGINAL STATEMENTS FROM SYSIN FOLLOW
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(ACCOUNT-ANALYSIS-DATE,
LT,CUTOFF-DATE),
OVERLAY=(ACCOUNT-ANALYSIS-DATE:
ACCOUNT-START-DATE)),
IFTHEN=(WHEN=NONE,
OVERLAY=(ACCOUNT-ANALYSIS-DATE:
CUTOFF-DATE))
ICE282I 0 PERFORMING SYMBOL SUBSTITUTION AS NEEDED
ICE143I 0 BLOCKSET COPY TECHNIQUE SELECTED
JCL
Code:
//STEP01 EXEC PGM=SORT
//SYMNAMES DD *
ACCOUNT-ANALYSIS-DATE,4,8,CH
ACCOUNT-START-DATE,13,8,CH
CUTOFF-DATE,C'20130930'
//SYMNOUT DD SYSOUT=*
//SORTIN DD *
ASD 20131209 20131208 DSD
DBD 20130930 20131209 ESD
SDS 20130923 20131213 FSD
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(ACCOUNT-ANALYSIS-DATE,
LT,CUTOFF-DATE),
OVERLAY=(ACCOUNT-ANALYSIS-DATE:
ACCOUNT-START-DATE)),
IFTHEN=(WHEN=NONE,
OVERLAY=(ACCOUNT-ANALYSIS-DATE:
CUTOFF-DATE))
/*
Regards,
Magesh
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Well, I didn't test mine. Did you test yours?
If your sample data is accurate, your start positions are wrong. I just copied those from your Control Cards, I didn't think to check them :-)
Now, what you do is change this:
Code:
ACCOUNT-ANALYSIS-DATE,4,8,CH
ACCOUNT-START-DATE,13,8,CH
to this:
Code:
ACCOUNT-ANALYSIS-DATE,5,8,CH
ACCOUNT-START-DATE,14,8,CH
You can compare to see how many places you'd have had to correct it in your original...
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Oversight error, Sorry, thanks, Now it is fine.
Regards,
Magesh
Back to top
Please enable JavaScript!