Apparently, when an RPG ILE program executes a call to
QCMDEXC, which executes a command; if the command cannot be
executed interactively, then regardless of the mode in which
the program was executed the command will fail.
I'm new to RPG ILE and I couldn't manage to think of a way
to redefine the external format, that's why the file is an
internally described file.
FBUCKETS UF A F 2001 DISK
D qcmdexc PR extpgm('QCMDEXC')
D cmd 200A options(*varsize) const
D len 15p 5 const
D bkts DS 2001
D fldb 29 dim(69)
D WORK DS 29
D PKD 9P 0
D ABR 12
D DAY 3
D MON 3
D DOW 1
D DOY 3
D WOY 2
D ISO S d datfmt(*iso)
D mdy S 6A
D mdyn S 6S 0
D alt S D datfmt(*mdy)
D today s d datfmt(*mdy)
D rtvdat c 'rtvdat &mdy abrvdate(&abr)
day3u- D (&day) mth3u(&mon)
dayofweek(&dow) - D
dayofyear(&doy) weekofyear(&woy)' Ibuckets aa
I 1 2001 flda
* main
C READ buckets
01 C 0 DO 34 A 3
0 C EXSR DTSR
C ENDDO
* there's a buckets record
C *IN01 IFEQ *OFF
C UPDATE buckets bkts
* there's not a buckets record
C else
C write buckets bkts
C ENDIF
C MOVE *ON *INLR
* first
C *INZSR BEGSR
C *mdy move udate today
C ENDSR
* date calculation process
C DTSR BEGSR
C clear work
C A ADD 1 b 3 0
C A ADD 35 c 3 0
C SELECT
C A WHENEQ 32
C today adddur 60:*d iso
C A WHENEQ 33
C today adddur 90:*d iso
C A WHENEQ 34
C today adddur 120:*d iso
C OTHER
C today adddur a:*d iso
C ENDSL
C move iso pkd
C move iso alt
C move alt mdyn
C move mdyn mdy
C callp qcmdexc(rtvdat:%size(rtvdat))
C eval fldb(b) = work
C clear work
C A IFNE *ZERO
C SELECT
C A WHENEQ 32
C today subdur 60:*d iso
C A WHENEQ 33
C today subdur 90:*d iso
C A WHENEQ 34
C today subdur 120:*d iso
C OTHER
C today subdur a:*d iso
C ENDSL
C move iso pkd
C move iso alt
C move alt mdyn
C move mdyn mdy
C callp qcmdexc(rtvdat:%size(rtvdat))
C eval fldb(c) = work
C ENDIF
C ENDSR
FBUCKETS UF A F 2001 DISK
D rtvdat PR extpgm('TAADATDC')
D date 6
D dayname 9
D mthname 9
D fulldate 17
D abrdate 12
D day3u 3
D day3l 3
D mth3u 3
D mth3l 3
D dayofweek 1
D dayofyear 3
D weekofyear 2
D yymmd 6
D cyymmdd 7
D fullyear 4
D cent 1
D bkts DS 2001
D fldb 29 dim(69)
D WORK DS 29
D PKD 9P 0
D ABR 12
D D3U 3
D M3U 3
D DOW 1
D DOY 3
D WOY 2
D iso S d datfmt(*iso)
D mdy S 6A
D mdyn S 6S 0
D dnm S 9
D mnm S 9
D fdt S 17
D d3l S 3
D m3l S 3
D ymd S 6
D cyy S 7
D fyr S 4
D cen S 1
D alt S d datfmt(*mdy)
D today s d datfmt(*mdy)
Ibuckets aa
I 1 2001 flda
* main
C READ buckets
01 C 0 DO 34 A 3
0 C EXSR DTSR
C ENDDO
* there's a buckets record
C *IN01 IFEQ *OFF
C UPDATE buckets bkts
* there's not a buckets record
C else
C write buckets bkts
C ENDIF
C MOVE *ON *INLR
* first
C *INZSR BEGSR
C *mdy move udate today
C ENDSR
* date calculation process
C DTSR BEGSR
C clear work
C A ADD 1 b 3 0
C A ADD 35 c 3 0
C SELECT
C A WHENEQ 32
C today adddur 60:*d iso
C A WHENEQ 33
C today adddur 90:*d iso
C A WHENEQ 34
C today adddur 120:*d iso
C OTHER
C today adddur a:*d iso
C ENDSL
C move iso pkd
C move iso alt
C move alt mdyn
C move mdyn mdy
C callp rtvdat(mdy:dnm:mnm:fdt:
C abr:d3u:d3l:m3u:
C m3l:dow:doy:woy:
C ymd:cyy:fyr:cen)
C eval fldb(b) = work
C clear work
C A IFNE *ZERO
C SELECT
C A WHENEQ 32
C today subdur 60:*d iso
C A WHENEQ 33
C today subdur 90:*d iso
C A WHENEQ 34
C today subdur 120:*d iso
C OTHER
C today subdur a:*d iso
C ENDSL
C move iso pkd
C move iso alt
C move alt mdyn
C move mdyn mdy
C callp rtvdat(mdy:dnm:mnm:fdt:
C abr:d3u:d3l:m3u:
C m3l:dow:doy:woy:
C ymd:cyy:fyr:cen)
C eval fldb(c) = work
C ENDIF
C ENDSR
i do not know the RTVDAT command, but i found in QUSRTOOLs QATTINFO that it
had been removed for V3R6M0. The description says "Retrieve date command
description".
As it is a retrieve command, you cannot enter it on a command line, nor can
you execute it with QCMDEXC. If you really want to use it, you'll had to
call the command processing program, which you can find out with DSPCMD
TAATOOL/RTVDAT. Look for the CL-source for parameters.
You might also write a little CL that runs the command and returns you the
desired values.
You can change a command with CHGCMD and you can change the environments in
which this command is allowed, but for a retrieve command this is not
working. There is no direct interface between RPG and Commands. Full support
is included for program and procedure calls, as you already do.
Hope this helps
Anton Gombkötö
Gombkoetoe@nospam@ASsoft.com
AS Software
Vienna, Austria, Europe
All opinions are mine, not necessarily those of my employer, AS Software.