As any program (and REXX is no exception) lumbers along, it's often a good idea to keep track of what's happening, so that if something goes south later, you'll have some idea of where that happened. A log-file is a good way to cover that. Ideally, you want to have a separate file for each execution of the program so that if multiple users are banging away, each one has their activity logged to a unique spot. That implies the log files will have different names, probably with a timestamp. Here's the technique I use with great success:
parse value Date("S") Time("S") Time("N") with, yyyymmdd sssss hhmmss . parse var yyyymmdd 4 yrdigit 5 mm 7 dd /* 9 12 14 maybe */ if Pos(yrdigit,"13579") > 0 then mm = mm + 12 /* mm=24 */ logtag = Substr("ABCDEFGHIJKLMNOPQRSTUVWX",mm,1) /* logtag=X */ subid = logtag""dd""Right(sssss,5,0) /* X1423722 ? */
The initial "parse" snags coherent date-and-time information. Doing this on a single statement guarantees that the time will be proper for the date. The second "parse" peels off the one-digit year ( '3' in 2013 ) so that we can determine whether it is odd ( if Pos(yrdigit,"13579") > 0 ). If it is, we add 12 to the month value ( mm = mm + 12 ). Next, we grab the mmth value from the string of the first 24 letters of the alphabet. We are now ready to form the unique part of the log file's dataset name:
logdsn = "LOG."exec_name"."subid".LIST"
Put the exec's name as part of the log file's name. If a routine calls a subroutine which also generates a log file, you don't want to cause a conflict.
Now all you have to do is allocate the dataset with a proper DCB and start filling it with progress notes.