View previous topic :: View next topic
|
Author |
Message |
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
Hi
If anyone can help out in the following would be really great...
The LMDLIST is checked for all the datasets listed by it, after the last dataset, it is throwing the RC of 8, so the next all code is not excuting properly.
The code is
WRITELINE:
DO
MIFLAG = " "
STROPT = " "
STROPT = INSERT(DSNAME,STROPT,1)
STROPT = INSERT(ZDLCDATE,STROPT,50)
SAY STROPT
PUSH STROPT
END
DO
ADDRESS ISPEXEC
"LMDLIST LISTID(&ID) OPTION(LIST),
DATASET(DSNAME) STATS(YES)"
END
here the RC is 8 so when the function WRITELINE is called next time, its not excuted properly.
Can anybody help out in tracing, if last dataset then anything. I mean to quit or go back kind of options if available? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
there are two ways of doing things ...
if all the statements in the loop are always executed then You could
Code: |
Address ISPEXEC LMDINIT .....
Address ISPEXEC LMDLIST ....
do while rc = 0
....
.... process
....
Address ISPEXEC LMDLIST ....
end |
but there are cases where is better to wrap things in a function
Code: |
Address ISPEXEC LMDINIT .....
do while LMDfun(.......) = 0
....
.... process
....
if .... then iterate
....
....
end
....
....
exit
LMDfun :
Address ISPEXEC LMDLIST ....
return RC
|
both approaches have been tested and found working as planned |
|
Back to top |
|
|
prafull
New User
Joined: 08 Dec 2006 Posts: 48
|
|
|
|
Hey thanks
it worked
i used the 2nd method to do it |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
that' s my preferred choice in any case, cleaner code |
|
Back to top |
|
|
|