Reputation: 2527
How do I pass library and dataarea name as a parm(s) into RTVDTAARA command in IBM i CL? Like this operating system is truncating value at 10 characters.
DCL VAR(&LIB_DTA) TYPE(*CHAR) LEN(21)
DCL VAR(&CPY) TYPE(*CHAR) LEN(3)
RTVDTAARA DTAARA(MYLIB/MYDTA (1 5)) RTNVAR(&DUMMY) // parm as values works
CHGVAR VAR(&LIB_DTA) VALUE('ARDTA' *TCAT &CPY *TCAT '/MYDTAARA')
RTVDTAARA DTAARA(&LIB_DTA (1 5)) RTNVAR(&DUMMY) // but pass as variable does not
RTVDTAARA DTAARA(%TRIM(&DTA)/%TRIM(&LIB)) RTNVAR(&DUMMY) // ...nor does this
Upvotes: 0
Views: 156
Reputation: 2483
use %scan
and %sst
built in functions to split the qualified library and dtaara name into two distinct variables.
PGM
dcl &vlu *char 80
DCL VAR(&LIB_DTA) TYPE(*CHAR) LEN(21)
dcl &fx *int
dcl &lx *int
dcl &bx *int
dcl &name *char 10
dcl &lib *char 10
CHGVAR VAR(&LIB_DTA) VALUE('*LIBL' *TCAT +
'/steve')
/* split qualified library and dtaara name. */
chgvar &fx %scan('/' &lib_dta )
chgvar &lx (&fx - 1)
chgvar &lib %sst(&lib_dta 1 &lx)
chgvar &bx (&fx + 1)
chgvar &name %sst(&lib_dta &bx 10)
/* read the dtaara using qualified library and dtaara name. */
RTVDTAARA DTAARA(&LIB/&name) RTNVAR(&vlu)
sndpgmmsg &vlu
endpgm
Upvotes: 2