Here is a cobol pgm that interacts with tso thru REXX. I will post the COBOL pgm first, then rex code to execute it interactively. (it does some minor edits)
identification division.
program-id. daysdiff.
*************************************************
**** returns number of days between two dates.
*************************************************
environment division.
data division.
working-storage section.
77 w-d1 pic x(08).
77 w-d2 pic x(08).
77 n-d1 pic 9(08).
77 n-d2 pic 9(08).
77 w-i1 pic 9(09).
77 w-i2 pic 9(09).
77 w-days pic 9(09).
procedure division.
display ' '
display ' '
display ' '
display ' '
display ' '
display 'enter valid first date yyyymmdd and press enter'
accept w-d1 from sysin
if w-d1 not numeric
display ' first date not numeric '
move 1 to return-code
goback
end-if
move w-d1 to n-d1
if (n-d1 > 99991231)
display ' date must be less than 99991232'
move 3 to return-code
goback
end-if
if (n-d1 < 16010101)
display ' date must be greater than 16010100'
move 3 to return-code
goback
end-if
display 'enter valid second date yyyymmdd and press enter'
accept w-d2 from sysin
if w-d2 not numeric
display 'second date not numeric '
move 2 to return-code
goback
end-if
move w-d2 to n-d2
if (n-d2 > 99991231)
display ' date must be less than 99991232'
move 4 to return-code
goback
end-if
if (n-d2 < 16010101)
display ' date must be greater than 16010100'
move 4 to return-code
goback
end-if
compute w-i1 = function integer-of-date(n-d1)
compute w-i2 = function integer-of-date(n-d2)
compute w-days = w-i1 - w-i2
display 'the number of days between ' w-d1 ' and '
w-d2 ' is ' w-days
move 0 to return-code
goback
.
Here is the Rexx code, (you have to put your load library name in the place of LOAD.LIB.NAME)
/* REXX */
"ALLOCATE F(SYSOUT) DA(*) SHR REUSE"
"ALLOCATE F(SYSIN) DA(*) SHR REUSE"
"CALL 'LOAD.LIB.NAME(DAYSDIFF)' "
"FREE FILE(SYSOUT SYSIN)"
EXIT