IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

LMDINIT/LIST/FREE Looping problem


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ecsk

New User


Joined: 28 Jun 2010
Posts: 14
Location: Australia

PostPosted: Wed Aug 04, 2021 12:35 pm
Reply with quote

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
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 495
Location: Denmark

PostPosted: Wed Aug 04, 2021 2:37 pm
Reply with quote

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
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1111
Location: Dublin, Ireland

PostPosted: Wed Aug 04, 2021 3:50 pm
Reply with quote

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
View user's profile Send private message
ecsk

New User


Joined: 28 Jun 2010
Posts: 14
Location: Australia

PostPosted: Wed Aug 04, 2021 5:31 pm
Reply with quote

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
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 495
Location: Denmark

PostPosted: Wed Aug 04, 2021 8:50 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

PostPosted: Thu Aug 05, 2021 12:17 am
Reply with quote

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
View user's profile Send private message
ecsk

New User


Joined: 28 Jun 2010
Posts: 14
Location: Australia

PostPosted: Fri Aug 06, 2021 9:06 am
Reply with quote

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
View user's profile Send private message
ecsk

New User


Joined: 28 Jun 2010
Posts: 14
Location: Australia

PostPosted: Fri Aug 06, 2021 9:15 am
Reply with quote

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. icon_rolleyes.gif
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 495
Location: Denmark

PostPosted: Fri Aug 06, 2021 1:36 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

PostPosted: Fri Aug 06, 2021 6:05 pm
Reply with quote

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
View user's profile Send private message
ecsk

New User


Joined: 28 Jun 2010
Posts: 14
Location: Australia

PostPosted: Mon Aug 09, 2021 4:39 am
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

PostPosted: Mon Aug 09, 2021 7:11 am
Reply with quote

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
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 495
Location: Denmark

PostPosted: Mon Aug 09, 2021 1:27 pm
Reply with quote

@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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Problem while sending special charact... JCL & VSAM 3
No new posts Create table from List CLIST & REXX 8
No new posts DATA SET LIST UTILITY screen TSO/ISPF 6
No new posts how to list the number of backup data... JCL & VSAM 3
No new posts problem in select max when executing ... IMS DB/DC 6
Search our Forums:

Back to Top