View previous topic :: View next topic
|
Author |
Message |
ecsk
New User
Joined: 28 Jun 2010 Posts: 14 Location: Australia
|
|
|
|
I'm writing a rexx loop to read list of dataset levels, then in each level use LMDINIT, LMDLIST loop, LMDFREE to read each dataset in level.
assume dsnlevel stem variable contains these
hlq.2lqa.**.a
hlq.2lqb.**.b
hlq.2lqc.**.c
Code: |
j = 0
do i = 1 to dsnlevel.0
"lmdinit listid("dslid") level("dsnlevel.i")"
if rc = 0 then do
lmdlist_rc = 0
dsnvar = ' '
"lmdlist listid(&dslid) option(list) dataset(dsnvar) stats(yes)"
lmdlist_rc = rc
do while lmdlist_rc = 0
if ZDLMIGR = 'YES' then do
j = j + 1
migrated.j = dsnvar
end
"lmdlist listid(&dslid) option(list) dataset(dsnvar) stats(yes)"
lmdlist_rc = rc
end
end
"lmdfree listid(&dslid)"
end |
Problem is. in first loop of i (dsnlevel.1), everything is working find. start from second iteration (dsnlevel.2), the lmdlist call return rc = 10.
Is there anything wrong with my code ??? |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 735 Location: Denmark
|
|
|
|
off the top of my head:
"lmdinit listid(dslid) level("dsnlevel.i")" - note no quotes around dslid.
then
"lmdlist listid("dslid") ...
I think that the loop is caused by the dslid variable being a number the second time around, and as you don't test the rc (which you really should do) you are not aware that the LMDINIT failed. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
I tried and also had to change the LMDFREE to
"lmdfree listid(dslid)" - removed the &
It then worked OK for me.
Garry. |
|
Back to top |
|
|
ecsk
New User
Joined: 28 Jun 2010 Posts: 14 Location: Australia
|
|
|
|
ah... thanks
the "lmdinit listid(dslid) ............." is the way to go.
"dslid" or &dslid in other lmdlist or lmdfree call work the same. |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 735 Location: Denmark
|
|
|
|
LMDFREE should be "lmdfree listid("dslid")" - note the quotes. I am sure that if you test the RC after your lmdfree, you will see an error. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
ecsk wrote: |
ah... thanks
the "lmdinit listid(dslid) ............." is the way to go.
"dslid" or &dslid in other lmdlist or lmdfree call work the same. |
Never heard that LMDINIT or LMDLIST are able to take parameters in ampersand notation?…
Where it comes from? |
|
Back to top |
|
|
ecsk
New User
Joined: 28 Jun 2010 Posts: 14 Location: Australia
|
|
|
|
sergeyken wrote: |
ecsk wrote: |
ah... thanks
the "lmdinit listid(dslid) ............." is the way to go.
"dslid" or &dslid in other lmdlist or lmdfree call work the same. |
Never heard that LMDINIT or LMDLIST are able to take parameters in ampersand notation?…
Where it comes from? |
From product documentation www.ibm.com/docs/en/zos/2.2.0?topic=e-command-invocation-4
btw, it only work for lmdlist and lmdfree, not lmdinit
I just added a say rc after lmdfree listid(&dslid), it is zero. So it prove both format work fine.
Code: |
"lmdfree listid(&dslid)" |
or
Code: |
"lmdfree listid("dslid")" |
|
|
Back to top |
|
|
ecsk
New User
Joined: 28 Jun 2010 Posts: 14 Location: Australia
|
|
|
|
Garry Carroll wrote: |
I tried and also had to change the LMDFREE to
"lmdfree listid(dslid)" - removed the &
It then worked OK for me.
Garry. |
That, I don't get it , it should not work. |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 735 Location: Denmark
|
|
|
|
re "btw, it only work for lmdlist and lmdfree, not lmdinit"
That is because dslid in the LMDINIT command is the variable name, for the other commands it is the variable value. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
ecsk wrote: |
sergeyken wrote: |
ecsk wrote: |
ah... thanks
the "lmdinit listid(dslid) ............." is the way to go.
"dslid" or &dslid in other lmdlist or lmdfree call work the same. |
Never heard that LMDINIT or LMDLIST are able to take parameters in ampersand notation?…
Where it comes from? |
From product documentation www.ibm.com/docs/en/zos/2.2.0?topic=e-command-invocation-4
|
This is NOT REXX environment syntax!!!!!!
In this example, parameter is passed to LMDINIT by its address (with ampersand), and to LMDLIST by its value (no ampersand)
In REXX, parameter is passed to LMDINIT by its name (inside of the whole command, within outer quotes), and to LMDLIST by its value (outside of outer quotes, with the value substituted by REXX itself) |
|
Back to top |
|
|
ecsk
New User
Joined: 28 Jun 2010 Posts: 14 Location: Australia
|
|
|
|
sergeyken wrote: |
ecsk wrote: |
sergeyken wrote: |
ecsk wrote: |
ah... thanks
the "lmdinit listid(dslid) ............." is the way to go.
"dslid" or &dslid in other lmdlist or lmdfree call work the same. |
Never heard that LMDINIT or LMDLIST are able to take parameters in ampersand notation?…
Where it comes from? |
From product documentation www.ibm.com/docs/en/zos/2.2.0?topic=e-command-invocation-4
|
This is NOT REXX environment syntax!!!!!!
In this example, parameter is passed to LMDINIT by its address (with ampersand), and to LMDLIST by its value (no ampersand)
In REXX, parameter is passed to LMDINIT by its name (inside of the whole command, within outer quotes), and to LMDLIST by its value (outside of outer quotes, with the value substituted by REXX itself) |
To call ispf service in rexx, you always need to either address ispexec before first call, or address ispexec "lmd............." in each call.
address ispexec address ispexec "lmdlist listid(&dslid) .........." syntax works fine.
My rexx already has address ispexec before the loop so "lmdlist listid(&dslid) .........." works Ok.
both &dslid and "dslid" are working Ok. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
I have to repeat my comment in red:
In your original example you presented your call to LMDINIT in REXX syntax, but your parameters presented in non-REXX format.
In your latest response you’ve just skillfully substituted the call to LMDINIT in non-REXX environment format. That’s why it began “working fine”.
It makes sense to use REXX-only formats when coding REXX procedures, but not to mix plenty of different things in the same part of code; there is usually more than enough other mess in the code. |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 735 Location: Denmark
|
|
|
|
@ecsk,
as sergeyken says, you really should stick to REXX syntax.
You are right in saying that using the ampersand works, but only for ISPEXEC calls.
i.e. this works:
dsl='DVL.PP.*'
address ispexec
"lmdinit listid("dslid") level("dsl")"
"lmdlist listid(&dslid) option(list) dataset(dsnvar) stats(yes)"
But this does not:
isfprefix='SDSF'
call isfcalls 'ON'
sp='DA'
address SDSF "ISFEXEC &sp (WAIT PREFIX $da)"
Looking at the LMDLIST description in the ISPF Services manual.
The Command invocation in example 1 is clearly a CLIST:
SET &DSNAME =
ISPEXEC LMDLIST LISTID(&ID) STATS(YES) DATASET(DSNAME) OPTION(LIST)
The example 2 is a REXX, which uses quotes around the variable name:
’LMDLIST LISTID(’listidv’) OPTION(SAVE) GROUP(ISPFSVC)’ |
|
Back to top |
|
|
|