Passing the date from JCL to REXX



IBM's Command List programming language & Restructured Extended Executor

Passing the date from JCL to REXX

Postby RahulGaur » Tue Mar 27, 2012 8:09 pm

Hi,

I have a REXX program 'FCHKPRIC' which on executing asks for the date of report as shown below:

Enter date of Report (dd/mm/yy):

I am trying to execute this REXX program from a JCL as follows:
//STEP01   EXEC PGM=IKJEFT01,REGION=800K,
//           PARM='FCHKPRIC'
//SYSEXEC DD DSN=SVY130.RAHUL.REXX.PROGRAMS,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
12/03/12
/*


This is giving MAXCC 12 return code as the date is not accepted by the rexx program. The date in REXX is given as "PULL Repdate" and I also tried by giving it as 'PARSE arg Repdate' but it didn't work. Do i have to make some changes in REXX? Please suggest.
RahulGaur
 
Posts: 2
Joined: Tue Mar 20, 2012 4:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Passing the date from JCL to REXX

Postby Akatsukami » Tue Mar 27, 2012 8:11 pm

Show the relevant code with a trace.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Passing the date from JCL to REXX

Postby NicC » Tue Mar 27, 2012 11:40 pm

I have run what you have shown and got a return code of 0 and the data displayed in SYSTSPRT so what are you not teling us?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Passing the date from JCL to REXX

Postby Pedro » Wed Mar 28, 2012 1:50 am

so what are you not teling us?

He did not show the actual rexx program.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Passing the date from JCL to REXX

Postby RahulGaur » Thu Mar 29, 2012 5:38 pm

please see the REXX code as below:
/****************************** Rexx *********************************/
/* */
/* Before executing this EXEC. Ensure that the SDSNLOAD and SDSNEXIT */
/* Libraries are in the STEPLIB. */
/*********************************************************************/
File.0 = 3
File.1 = "JOB1 M 00.00.00 01.59.59 23456 0"
File.2 = "JOB2 M 02.00.00 13.59.59 23456 0"

SAY "Enter date of Report (dd/mm/yy):"
PULL RepDate
/*********************************************************************/
/* Validate the Input date */
/*********************************************************************/
RC = DATE( , RepDate, 'E' )

DB2Date = SUBSTR(RepDate, 1, 2)'.'SUBSTR(RepDate, 4, 2)
DB2Date = DB2Date'.20'SUBSTR(RepDate, 7, 2)
Today = DATE( 'E' )

/*********************************************************************/
/* SQL Statement for MC004B entries in MC081T table */
/*********************************************************************/
SQLStmt = ,
"SELECT M80.JOB_NAME",
" ,TIME( M80.PROG_START_TS )",
" ,M80.VERARB_MENGE1",
" ,M80.VERARB_DATUM",
" ,M80.PROG_START_TS",
" FROM DB.MC080T M80",
" WHERE DATE(M80.PROG_START_TS) = '"DB2Date"'",
" AND M80.PROG_ID IN( 'MC425B', 'MC422B', 'MC420B', 'MC421B' )",
" AND M80.PROG_ENDE_TS IS NOT NULL",
" ORDER BY M80.PROG_START_TS ASC"

/*********************************************************************/
/* Prepare DB2 environment and execute the SQL Statement */
/*********************************************************************/

ADDRESS TSO 'SUBCOM DSNREXX'

IF RC <> 0 THEN
DO
RetCode = RXSUBCOM( 'ADD','DSNREXX', 'DSNREXX')
If RetCode <> 0 THEN
DO
SAY "Error establishing DSNREXX Environment"
EXIT 9
END
END

ADDRESS DSNREXX "CONNECT" "DB6"
IF( SqlCode <> 0 ) THEN
DO
SAY "Error in CONNECT. SQLCODE: "SqlCode
EXIT 9
END

ADDRESS DSNREXX "EXECSQL SET CURRENT PACKAGESET='DSNREXCS'"
IF( SqlCode <> 0 ) THEN
DO
SAY "Error in SET CURRENT PACKAGESET. SQLCODE: "SqlCode
ADDRESS DSNREXX "DISCONNECT"
EXIT 9
END

ADDRESS DSNREXX "EXECSQL DECLARE C1 CURSOR FOR S1"
IF( SqlCode <> 0 ) THEN
DO
SAY "Error in DECLARE. SQLCODE: "SqlCode
ADDRESS DSNREXX "DISCONNECT"
EXIT 9
END

ADDRESS DSNREXX "EXECSQL PREPARE S1 INTO :OUTSQLDA FROM :SQLSTMT"
IF( SqlCode <> 0 ) THEN
DO
SAY "Error in PREPARE. SQLCODE: "SqlCode
ADDRESS DSNREXX "DISCONNECT"
EXIT 9
END

ADDRESS DSNREXX "EXECSQL OPEN C1"
IF( SqlCode <> 0 ) THEN
DO
SAY "Error in OPEN. SQLCODE: "SqlCode
ADDRESS DSNREXX "DISCONNECT"
EXIT 9
END

/*********************************************************************/
/* Store the result of the SQL Statement in a Array for later */
/* processing */
/*********************************************************************/
OutCtr = 0
DO UNTIL( SqlCode <> 0 )
ADDRESS DSNREXX "EXECSQL FETCH C1 USING DESCRIPTOR :OUTSQLDA"
IF( SqlCode < 0 ) THEN
DO
SAY "Error in FETCH. SQLCODE: "SqlCode
ADDRESS DSNREXX "DISCONNECT"
EXIT 9
END
IF( SqlCode = 0 ) THEN
DO
OutLine = ' '
DO I = 1 To OUTSQLDA.SQLD
OutLine = OutLine OUTSQLDA.I.SQLDATA
END
OutCtr = OutCtr + 1
Output.OutCtr = OutLine
END
END

ADDRESS DSNREXX "DISCONNECT"

RetCode = RXSUBCOM( 'DELETE','DSNREXX','DSNREXX')

/*********************************************************************/
/* Parse the output from the SQL statement */
/*********************************************************************/
DO I = 1 TO OutCtr
PARSE VAR Output.I JobName.I Time.I Recs.I AVK.I Tsp.I
Recs.I = STRIP( Recs.I, , '.' )
/*
Say 'SYSID : 'JobName.I
Say 'FILEID : 'FileId.I
Say 'Records : 'Recs.I
Say 'AVK Date : 'AVK.I
Say 'TimeStmp : 'Tsp.I'--'
*/
End

/*********************************************************************/
/* Process each entry in our list one at a time */
/*********************************************************************/
NoOfFilesExpected = File.0
NoOfFilesRecd = 0
DO I = 1 TO File.0
FileArrived = FALSE
PARSE VAR File.I FJobname Multi FStartTime FEndTime FDays FAVK

/******************************************************************/
/* Check if we retrieved a row from MC081T table for this Job */
/******************************************************************/
DO J = 1 TO OutCtr
IF( FJobName = JobName.J ) THEN

IF( Multi = 'M' ) THEN
DO
IF( Time.J >= FStartTime & Time.J <= FEndTime ) THEN
DO
FileArrived = TRUE
LEAVE
END
END
ELSE
DO
FileArrived = TRUE
LEAVE
END
END

IF( FileArrived = TRUE ) THEN
DO
NoOfFilesRecd = NoOfFilesRecd + 1
SAY FJobname" has run at "Time.j
/***************************************************************/
/* Check if AVK date was correct */
/***************************************************************/
/***************************************************************/
/* Add or subtract the number of days from the RepDate */
/***************************************************************/
FAVK = STRIP( FAVK )
BaseDays = DATE( 'B', RepDate, 'E' )
SELECT
WHEN( SUBSTR( FAVK, 1, 1 ) = '+' ) THEN
BaseDays = BaseDays + SUBSTR( FAVK, 2 )
WHEN( SUBSTR( FAVK, 1, 1 ) = '-' ) THEN
BaseDays = BaseDays - SUBSTR( FAVK, 2 )
OTHERWISE
BaseDays = BaseDays
END
AVKDate = DATE( 'E', BaseDays, 'B' )
AVKDateFormated = SUBSTR( AVKDATE, 1, 2 )'.'
AVKDateFormated = AVKDateFormated''SUBSTR( AVKDATE, 4, 2 )'.20'
AVKDateFormated = AVKDateFormated''SUBSTR( AVKDATE, 7, 2 )
IF( AVKDateFormated <> AVK.J ) THEN
DO
SAY " **** WARNING ****"
SAY " **** WARNING **** File Processed with wrong AVK date"
SAY " **** WARNING ****"
END

/***************************************************************/
/* Check if file could have been empty */
/***************************************************************/
IF( Recs.J < 4 ) THEN
DO
SAY " **** WARNING ****"
SAY " **** WARNING **** Check the no. of Records in file"
SAY " **** WARNING ****"
END
END
ELSE
DO
/***************************************************************/
/* If file has not arrived, check if it was expected on the */
/* RepDate */
/***************************************************************/
Dow = GetDow( )
IF( POS( Dow, FDays ) > 0 ) THEN
FileExpected = TRUE
ELSE
DO
FileExpected = FALSE
NoOfFilesExpected = NoOfFilesExpected - 1
END

IF( FileExpected = TRUE ) THEN
DO
/************************************************************/
/* If file was expected and did not arrive, */
/* On current day check if the file is delayed */
/************************************************************/
IF( RepDate <> Today ) THEN
DO
SAY "**** WARNING ****"
SAY "**** WARNING **** "FJobname" did NOT Run between ",
FStartTime" and "FEndTime
SAY "**** WARNING ****"
END
ELSE
DO
CurTime = SUBSTR( TIME( ), 1, 5 )
IF( CurTime > FEndTime ) THEN
DO
SAY "**** WARNING ****"
SAY "**** WARNING **** "FJobname" is DELAYED"
SAY "**** WARNING ****"
END
END
END
END
END
EXIT

GetDow:
Day = DATE( 'W', RepDate, 'E' )
SELECT
WHEN( Day = 'Monday' ) THEN Return '1'
WHEN( Day = 'Tuesday' ) THEN Return '2'
WHEN( Day = 'Wednesday' ) THEN Return '3'
WHEN( Day = 'Thursday' ) THEN Return '4'
WHEN( Day = 'Friday' ) THEN Return '5'
WHEN( Day = 'Saturday' ) THEN Return '6'
WHEN( Day = 'Sunday' ) THEN Return '7'
OTHERWISE Return 'X'
END
RahulGaur
 
Posts: 2
Joined: Tue Mar 20, 2012 4:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Passing the date from JCL to REXX

Postby Akatsukami » Thu Mar 29, 2012 7:09 pm

RahulGaur wrote:please see the REXX code as below:

And the trace?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Passing the date from JCL to REXX

Postby enrico-sorichetti » Thu Mar 29, 2012 8:36 pm

GetDow:
Day = DATE( 'W', RepDate, 'E' )
SELECT
WHEN( Day = 'Monday' ) THEN Return '1'
WHEN( Day = 'Tuesday' ) THEN Return '2'
WHEN( Day = 'Wednesday' ) THEN Return '3'
WHEN( Day = 'Thursday' ) THEN Return '4'
WHEN( Day = 'Friday' ) THEN Return '5'
WHEN( Day = 'Saturday' ) THEN Return '6'
WHEN( Day = 'Sunday' ) THEN Return '7'
OTHERWISE Return 'X'
END


are You aware that ( DATE("B") // 7 ) + 1 is the proper way to get what You want?

so the simple subroutine would be just a ...
GetDow:
    return ( DATE("B"', RepDate, 'E') // 7 ) + 1


read the in REXX manual the different formats handled by the DATE function
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3002
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post