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

Validate Day thru Syncsort


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Mon Sep 22, 2014 2:23 pm
Reply with quote

Hi All,

I have below requirement

I have to check for the day today in the JCL and throw a specific returned code for each day in a week for example : If it is Monday then my step will return a code of 01 and if it is Tuesday then 02 like that for all the days.

Based on the return code of this step I have to run my rest of the steps ..

I tried searching but could not found a generic way of doing it ..

Is it possible to do thru Sync sort.. Please assist.

Please let me know if I am not clear above... Thanks
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: Mon Sep 22, 2014 2:39 pm
Reply with quote

Have you looked at the possibility of using your Scheduler to run jobs per day-of-week?
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Mon Sep 22, 2014 3:33 pm
Reply with quote

The following little program will return the day of week as a return code that you can use in JCL. It is designed to use the local time as known in your system, which may not be your local time.
Code:
WEEKDAY  TITLE '                         Return Day of Week (0 through >
               6) As A Return Code'
***********************************************************************
*                                                                     *
* Title -- WEEKDAY                                                    *
*                                                                     *
* Function / Operation -- Return day of week as a number from 0       *
*   (Sunday) to 6 (Saturday) as a return code                         *
*                                                                     *
* Status / Change Level --                                            *
*   V1L0 -- July 2011                                                 *
*                                                                     *
* Method of Operation -- Get current time from the hardware time      *
*   of day clock.  Translate the value to days from Janury 1,         *
*   1900, then use that value to determine the current day of week.   *
*                                                                     *
* Attributes -- WEEKDAY is reenterable, refreshable and reusable.     *
*   It operates in TCB mode, in problem state and problem key.        *
*   WEEKDAY uses no external operating system services.  WEEKDAY is   *
*   declared as AMODE 31, RMODE ANY, but it will really run in any    *
*   AMODE that is compatible with the true RMODE of the program and   *
*   the location of the save area passed to WEEKDAY and the           *
*   address passed in register 14.                                    *
*                                                                     *
* Restrictions -- WEEKDAY uses register 0 as a 64 bit register, but   *
*   it does not save and restore the high order 32 bits of the        *
*   register.                                                         *
*                                                                     *
***********************************************************************
         SPACE 5
WEEKDAY  RSECT                     DEFINE PROGRAM CSECT
WEEKDAY  RMODE ANY                 ESTABLISH PROGRAM RMODE
WEEKDAY  AMODE 31                  ESTABLISH PROGRAM AMODE
         PUSH  PRINT
         PRINT NOGEN
         CVT   DSECT=YES           DEFINE THE CVT DATA AREA
         POP   PRINT
         SPACE 1
* DSECT FOR THE REGISTER SAVE AREA SUPPLIED BY THE CALLER.  THIS
* AREA IS USED AS BOTH A REGISTER SAVE AREA AND A WORK AREA
         SPACE 1
SA       DSECT
         DS    A                   RESERVED
SAPREV   DS    A                   ADDRESS OF PREVIOUS SAVE AREA
SANEXT   DS    A                   ADDRESS OF NEXT SAVE AREA
SAREG14  DS    A                   CALLER'S REG 14
SAREG15  DS    A                   CALLER'S REG 15
SAREG0   DS    A                   CALLER'S REG 0
SAREG1   DS    A                   CALLER'S REG 1
SAREG2   DS    A                   CALLER'S REG 2
SAREG3   DS    A                   CALLER'S REG 3
SAREG4   DS    A                   CALLER'S REG 4
SAREG5   DS    A                   CALLER'S REG 5
SAREG6   DS    A                   CALLER'S REG 6
SAREG7   DS    A                   CALLER'S REG 7
SAREG8   DS    A                   CALLER'S REG 8
SAREG9   DS    A                   CALLER'S REG 9
SAREG10  DS    A                   CALLER'S REG 10
CLOCK    DS    D
WEEKDAY  RSECT                     RETURN TO PROGRAM CSECT
         USING CVTXTNT2,2          EXTABLISH CVT EXTENSION            ->
                                    ADDRESSABILITY
         USING CVTMAP,3            ESTABLISH CVT ADDRESSABILITY
         USING *,4                 ESTABLISH PROGRAM ADDRESSABILITY
         USING SA,13               DEFINE SAVE AREA ADDRESSABILITY
         SAVE  (14,4),,'WEEKDAY &SYSDATE &SYSTIME'  SAVE REGISTERS
         LR    4,15                COPY ENTRY POINT ADDRESS TO REG 10
         L     3,CVTPTR            LOAD ADDRESS OF THE CVT
         L     2,CVTEXT2           LOAD ADDRSSS OF THE CVT EXTENSION
         STCK  CLOCK               GET THE CURRENT TOD CLOCK
         LG    0,CLOCK             LOAD CLOCK INTO 64-BIT REG 0
         SLG   0,CVTLSO            SUBTRACT LEAP SECONDS
         ALG   0,CVTLDTO           ADD TIMWZONE ADJUSTMENT
         STG   0,CLOCK             STORE ADJUSTED TOD CLOCK
         LM    0,1,CLOCK           LOAD THE CLOCK VALUE
         SRDL  0,12                CONVERT CLOCK VALUE TO             ->
                                    MICROSECONDS FROM JANUARY 1, 1900
* This is the trickiest part: we need a value <= 2**31-1, but large
* enough so that the quotient is <= 2**31-1
         D     0,=A(1000000*60)    CONVERT MICROSECONDS TO MINUTES    ->
                                    SINCE JANUARY 1, 1900
* REGISTER 1 CONTAINS MINUTES SINCE JANUARY 1, 1900
         SR    0,0                 SET REG 0 = 0
         D     0,=A(24*60)         COMPUTE NUMBER OF DAYS SINCE       ->
                                    JANUARY 1, 1900
         AHI   1,1                 ADD FUDGE FACTOR TO REG 1
         SR    0,0                 SET REG 0 = 0
         D     0,=F'7'             DIVIDE DAYS SINCE JANUARY 1, 1900  ->
                                    BY 7 TO GET THE DAY OF WEEK.
* REGISTER 0 CONTAINS THE DAY OF WEEK
         LR    15,0                COPY THE DAY OF WEEK TO REG 15
         RETURN (14,4),T,RC=(15)   RESTORE REGISTERS & RETURN
         DC    0D'0'
         LTORG ,
         DC    0D'0'
         END   WEEKDAY
As Mr. Woodger suggests, your scheduler may be a more viable solution than to use something like this.
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Mon Sep 22, 2014 3:51 pm
Reply with quote

Hi Bill,

Yes .. I checked with them but Since it is a file trigger job hence we can not schedule it like the way We want.. So we have to handle it in JCl only.

Thanks Steve for your response and sharing the code!!
So IF it is running on Mainframe Box in CST then it will say CST right?

Can you show me a way to run it thru JCl please?


Many Thanks !!

Regards
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Sep 22, 2014 4:56 pm
Reply with quote

Quote:
Can you show me a way to run it thru JCl please?

Same way as any other program:
Code:
//STEP EXEC PGM=pgmname given when binding the output of the assembler
//STEPLIB DD DSN=loadlib where the program was placed to after assembly and binding,DISP=SHR
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Mon Sep 22, 2014 5:23 pm
Reply with quote

Thanks Nic.

Does anybody have any other IDEA .. perhaps in sync sort ? Many Thanks in Advance !!
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Mon Sep 22, 2014 5:33 pm
Reply with quote

Should be able to do it very easily in REXX
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Mon Sep 22, 2014 5:44 pm
Reply with quote

Thanks Expat !!

I was wondering if we can do it in SORT .. I have the rexx routine which does this same thing but we are not using rexx in this process for some reason.

I know We can write in cobol as well icon_smile.gif
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Mon Sep 22, 2014 5:56 pm
Reply with quote

Hi Bill/Nic

I am getting below error when compiling ther code you provided

Code:
ASMA034E Operand DFHEILL beyond active USING range by -20 bytes
** ASMA034E Operand DFHEILL beyond active USING range by -20 bytes       
** ASMA435I Record 151 in SYS5C.CICT.CICS680.SDFHMAC(DFHEIRET) on volume: AAAA


Looks like it is throwing this error when expanding the below instrunction

Code:
DC    0D'0'



Can you assist please.. This is my first assembler program icon_smile.gif
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: Mon Sep 22, 2014 7:21 pm
Reply with quote

The return-codes you can get out or SORT are very limited, so you can't do what you've decided to do using SORT.

Neither Nic not I provided the code, that was kindly provided by Mr Myers. I suspect you are not Assembling it correctly. It is not a CICS program.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Mon Sep 22, 2014 8:19 pm
Reply with quote

Please show us the JCL you used to assemble the program. As Mr. Woodger indicated, this is not a CICS program.

To some extent, Assembler is column dependent. A DC Assembler instruction starting in column 1 as you appeared to show will always cause an Assembler error, though not the one you provided.

As for JCL,
Code:
//TESTPROC PROC
//A       EXEC PGM=WEEKDAY
//          IF A.RC=0 THEN
//B       EXEC PGM=WTO,PARM='IT''S SUNDAY'
//        ELSE
//          IF A.RC=1 THEN
//C       EXEC PGM=WTO,PARM='IT''S MONDAY'
//        ELSE
//          IF A.RC=2 THEN
//D       EXEC PGM=WTO,PARM='IT''S TUESDAY'
//        ELSE
//          IF A.RC=3 THEN
//E       EXEC PGM=WTO,PARM='IT''S WEDNESDAY'
//        ELSE
//          IF A.RC=4 THEN
//F       EXEC PGM=WTO,PARM='IT''S THURSDAY'
//        ELSE
//          IF A.RC=5 THEN
//G       EXEC PGM=WTO,PARM='IT''S FRIDAY'
//        ELSE
//          IF A.RC=6 THEN
//H       EXEC PGM=WTO,PARM='IT''S SATURDAY'
//        ELSE
//I       EXEC PGM=WTO,PARM='I DON''T KNOW WHAT THE WEEK DAY IS!'
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//       ENDIF
//        PEND
//JOBLIB   DD  DISP=(SHR,PASS),DSN=your-library
//A       EXEC TESTPROC
The WTO program in the JCL is non-standard, though many installations have something similar

As Expat indicated, you can do something similar using Rexx using the DATE built in function. Since I don't normally use Rexx, I cannot assist you in any way. Similarly, I'm sure you can do something similar in Cobol using Language Environment functions. The standard C library provides methods to obtain the day of week for a date, so you can do something similar in C or C++
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Mon Sep 22, 2014 8:32 pm
Reply with quote

Rexx would seem very straightforward, perhaps you could start using it in this process.

Alternatively your scheduler could probably assist even if it is event triggered. What scheduler do you use?
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Mon Sep 22, 2014 8:44 pm
Reply with quote

I did in two lines using TWS and it could potentially be just one line if you have it set to SCAN by default. I'm sure other schedulers have similar functionality.

Code:
//*%OPC SCAN                               
//STEP01   EXEC PGM=EQQRETWM,PARM=RC&ODAY. 
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Sep 23, 2014 12:54 am
Reply with quote

Would you like to have something like below?
1)
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                                 
A                                               
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  SORT FIELDS=COPY                             
  INREC BUILD=(WKDAY)                           
  OUTFIL NULLOFL=RC4,INCLUDE=(1,3,CH,EQ,C'MON')
//*                                             
//STEP0200 EXEC PGM=????,COND=(4,EQ,STEP0100) 


2)
Code:
//S1 EXEC PGM=SORT           
//SYSOUT DD SYSOUT=*         
//SYMNAMES DD *               
CURDAY,S'&LWDAY'             
//SORTIN DD *                 
RECORD                       
//SORTOUT DD SYSOUT=*         
//SYSIN DD *                 
  OPTION COPY                 
  INREC BUILD=(CURDAY)   

output:
Code:
MON

3) Use OPC related variables e.g.,
Code:
//*%OPC BEGIN ACTION=INCLUDE,COMP=(&ODAY..EQ.1)

1---> Monday
publib.boulder.ibm.com/tividd/td/TWS/SC32-1263-00/en_US/HTML/EQQR1MST327.htm#idx1323
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Fri Sep 26, 2014 3:42 pm
Reply with quote

Thank you So much all for your great Help and Valuable time ..

I really appreciate the suggestions and help I got on this .

Finally I have used the below way .. I use 3 steps instead of one

1- Take the current date in the file thru Sort

Code:
SORT FIELDS=COPY           
INREC OVERLAY=(DATENS=(4MD))


2- Take the Day on the date we got in previous step

Code:
SORT FIELDS=COPY                       
INREC OVERLAY=(15:1,8,Y4T,WEEKDAY=CHAR9)


3- I created a file having All the day except Saturday.. So If it do not find Saturday then it will through RC=04 and accordingly we will handle the Functionality.


Thanks Again to All of you for the 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 Sep 26, 2014 5:00 pm
Reply with quote

Now that you've change the requirement ("not Saturday" and RC=04) it can easily be done in one step with SyncSORT. See Rohit's post.
Back to top
View user's profile Send private message
thesumitk

Active User


Joined: 24 May 2013
Posts: 156
Location: INDIA

PostPosted: Sat Sep 27, 2014 3:50 pm
Reply with quote

HI Bill,

My apologies for not being clear on my requirement but as of now my actual requirement is liek this only that I have to run a job from Monday to Sunday but different JCL on Saturday and the job is file triggered so we cannot handle it byCA7 as well.

HOw ever I proactively wanted to create a generic proc to throw the return code on behalf of the day that's why I asked for the same ..

Coming to the Rohit's post

What I will use in place of wkday in below statement ?

INREC BUILD=(WKDAY)


I actually could not follow the code.. Can you please put some light on that?
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 Sep 27, 2014 4:09 pm
Reply with quote

It is Rohit's first example you want to look at.

You can get an RC (look in your documentation for the limits) with NULLOFL (OUTFIL) or NULLOUT (SORTOUT) when the job completes with no records on that dataset. If you have a dayname generated from a source-date (hopefully not system-date) and, for instance, OMIT those which are SUN, then you will get, for instance, RC/CC of 4 when a Sunday, and zero for all the other days.

Take Rohit's first example and experiment with it. His second example is producing a day-name, in case that was what you needed to get further.

EDIT:

Noticing that you have SyncSORT, if your release is up-to-date enough you can even set a (limited) RC/CC when a file contains data.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sun Sep 28, 2014 7:17 pm
Reply with quote

You should be able to schedule by run-day AND file creation - check with your schedulers.

And nothing gets "thrown" on the mainframe - displayed, issued, generated (in this case) etc but not thrown.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Tue Sep 30, 2014 7:07 pm
Reply with quote

This is just 'JCL' right?

Code:
//GENER0   EXEC PGM=IEBGENER
//SYSPRINT DD DUMMY
//SYSIN    DD DUMMY
//SYSUT1   DD *
TODAY = DATE('W')
UPPER TODAY
DAYRC = 'MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY'
RCODE = WORDPOS(TODAY,DAYRC)
SAY TODAY RCODE
EXIT (RCODE)
/*
//SYSUT2   DD DSN=&&TEMP0(DOW),UNIT=SYSALLDA,
//            SPACE=(TRK,(1,1,2),RLSE),
//            DISP=(NEW,PASS),DCB=(LRECL=80,
//            BLKSIZE=1600,DSORG=PO,RECFM=FB)
//DOW1     EXEC PGM=IRXJCL,PARM='DOW'
//SYSEXEC  DD DSN=&&TEMP0,DISP=OLD
//SYSTSPRT DD SYSOUT=Z
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts DFSORT/SYNCSORT/ICETOOL JCL & VSAM 8
No new posts Syncsort "Y2C" Function SYNCSORT 1
No new posts Need to validate the field using cobol COBOL Programming 4
Search our Forums:

Back to Top