as of V5R4 -
DCL supports the STG (storage) keyword, which lets you designate how a variable's storage is to be allocated. STG(*DEFINED) tells the compiler that a variable overlays all or part of another variable. You'll also need to use the DEFVAR (defined on variable) keyword to tell which variable this new variable is part of. DEFVAR takes two values--the name of the variable that is overlaid and the starting position for the overlay. The default starting position is one
http://www.itjungle.com/fhg/fhg020806-story01.html
I tried to use it and it happens that if the variable is defined only in CL it works OK, but if the variable is a parameter it does not work.
No only it does not work, but it gives crazy results:
here is the CL program:
PGM &FILLIB
DCL VAR(&FILLIB) TYPE(*CHAR) LEN(20)
DCL VAR(&FIL) TYPE(*CHAR) STG(*DEFINED) LEN(10) +
DEFVAR(&FILLIB 1)
DCL VAR(&LIB) TYPE(*CHAR) STG(*DEFINED) LEN(10) +
DEFVAR(&FILLIB 11)
? CPYF FROMFILE(&LIB/&FIL) TOFILE(&LIB/&FIL)
MONMSG CPF0000
SNDUSRMSG MSG(&LIB *TCAT '/' *TCAT &FIL) MSGTYPE(*INFO)
ENDPGM
I am doing the following command:
CALL PGM(TESTDS2) PARM('FIL4567890LIB4567890')
and here is the surprise: on the CPYF command it displays both variables (&FIL and &LIB) just from position 11 of the passed parameter, but on the SNDUSRMSG it displays it in the proper way.
Copy File (CPYF)
Type choices, press Enter.
From file . . . . . . . . . . . > LIB4567890
Library . . . . . . . . . . . > LIB4567890
To file . . . . . . . . . . . . > LIB4567890
Library . . . . . . . . . . . > LIB4567890
From member . . . . . . . . . . *FIRST
To member or label . . . . . . . *FIRST
Replace or add records . . . . . *NONE
Create file . . . . . . . . . . *NO
Print format . . . . . . . . . . *CHAR
Display Program Messages
LIB4567890/FIL4567890
Software/Hardware used:
ASKED:
September 7, 2008 10:55 AM
UPDATED:
September 14, 2008 5:33 AM
The problem was fixed – PTF 5722SS1-SI27953