View previous topic :: View next topic
|
Author |
Message |
Logeswaran Audhikesavan
New User
Joined: 26 Mar 2013 Posts: 5 Location: INDIA
|
|
|
|
Hi Team - Greetings!
I have a scenario where I need to read a records from file using chunk logic.. I gone through many discussions through this forum and learnt on that. I also tried and created the program but my program is executing infinite loop.. Unable to stop unless I disconnect from mainframe.
Here is the program , It would be great if you could let me know where I am making mistake. Sorry this is my first prg in Rexx..
Trying to read 100 records once and do processing and read another 100 records..
Code: |
DO FOREVER UNTIL(EOF)
"EXECIO 100 DISKR INFILE (STEM TST. FINIS"
IF RC <> 0 THEN EOF = 1
CNT = CNT + TST.0
DO I = 1 TO TST.0
IF INDEX(TST.I,'ENDED AT HALINMA1 MAXCC=',1) > 0 THEN DO
SAY 'AM INSIDE THE LOOP'
k1=jobnm.0 + 1
FIN = JOBNM.0 + 1
JOBNM.k1 = SUBSTR(TST.I,90,8)
RC1 = SUBSTR(TST.I,124,4)
END
END
END |
Result am getting is that -> "Am inside the loop" which is being displayed infinitely.. Where as my input file has just 300 records.
thank you So much for your assistance in advance. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Have you used TRACE
Also, please learn how to use the code tags. I have done it for you this time. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
elementary Dr. Watson
Quote: |
EXECIO .... ( FINIS |
will close the file, and You will be processing over and over the same chunk.
this is the proper way of doing it
Code: |
****** ***************************** Top of Data ******************************
000001 /* rexx */
000002 trace "o"
000003 signal on novalue name novalue
000004 parse arg chunk
000005
000006 Address TSO
000007
000008 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS "
000009
000010 iters = 0
000011 count = 0
000012 do forever
000013 "EXECIO "chunk" DISKR F1 (STEM STEM. "
000014 iters = iters + 1
000015 count = count + stem.0
000016 if stem.0 < chunk then ,
000017 leave
000018 end
000019 "EXECIO 0 DISKR F1 (FINIS "
000020 "FREE FI(F1) "
000021
000022 say count chunk iters
000023
000024 exit
000025 novalue:
000026 say "*********************************"
000027 say "** **"
000028 say "** novalue trapped at line" || right(sigl,4) || " **"
000029 say "** **"
000030 say "*********************************"
000031 exit
****** **************************** Bottom of Data **************************** |
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
but this one is better....
it handles a proper END OF FILE ( RC 2 ) vs an ERROR
Code: |
****** ***************************** Top of Data ******************************
000001 /* rexx */
000002 trace "o"
000003 signal on novalue name novalue
000004 parse arg chunk
000005
000006 Address TSO
000007
000008 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS "
000009
000010 iters = 0
000011 count = 0
000012 do forever
000013 "EXECIO "chunk" DISKR F1 (STEM STEM. "
000014 if RC > 2 then ,
000015 signal error
000016 iters = iters + 1
000017 count = count + stem.0
000018 if RC = 2 then ,
000019 leave
000020 end
000021 "EXECIO 0 DISKR F1 (FINIS "
000022 "FREE FI(F1) "
000023
000024 say count chunk iters
000025
000026 exit
000027
000028 error:
000029 say "EXECIO error :" RC
000030 say "EXECIO error :" count chunk iters
000031 exit
000032 novalue:
000033 say "*********************************"
000034 say "** **"
000035 say "** novalue trapped at line" || right(sigl,4) || " **"
000036 say "** **"
000037 say "*********************************"
000038 exit
****** **************************** Bottom of Data **************************** |
|
|
Back to top |
|
|
Logeswaran Audhikesavan
New User
Joined: 26 Mar 2013 Posts: 5 Location: INDIA
|
|
|
|
Thanks for your valuable suggestions!! WIll surely ensure to use Code tag going fwd.. Also I tried the Trace and it worked fine
Now its reading the value as expected, now am facing issue while writing the identified data into output flat file..
It tripping an error signal at line no 18 which is actualy at allocation of file. I doubt that, when data is being read each time(100) for each occurences, it has something identified and those has to be written in created file.
Can you please help here.
My updated code is
Code: |
000001 /* rexx */
000002 dsname = 'XXXxxx.T.REX.TEST5'
000003 DSE = SYSDSN("'"strip(dsname)"'")
000004 ADDRESS TSO
000005 IF DSE = 'OK' THEN
000006 DO
000007 "DELETE ('"dsname"')"
000008 END
000009
000010 trace "o"
000011 signal on novalue name novalue
000012 parse arg chunk
000013
000014 Address TSO
000015
000016 "ALLOC FI(F1) DS('XXXXXX.LOG.D130408') SHR REUS "
000017
000018 "ALLOC DA('"XXXXXX.T.REX.TEST5"') F(OUTFILE)
000019 DSORG(PS) SPACE(1,1) TRACK LRECL(80) RECFM(F,B) MOD"
000020
000021 JOBNM.=' '
000022 jobnm.0=0
000023 iters = 0
000024 count = 0
000025 do forever
000026 "EXECIO 100 DISKR F1 (STEM STEM. "
000027 if RC > 2 then ,
000028 signal error
000029 iters = iters + 1
000030 SAY 'AM IN' STEM.0
000031 count = count + stem.0
000032
000033 DO I = 1 TO STEM.0
000034 IF INDEX(STEM.I,'ENDED AT HALINMA1 MAXCC=',1) > 0 THEN DO
000035 SAY 'AM INSIDE THE LOOP'
000036 K1 = jobnm.0 + 1
000037 JOBNM.k1 = SUBSTR(STEM.I,90,8)
000038 SAY 'JOBNAME IS ' JOBNM.K1
000039 ADDRESS TSO "EXECIO * DISKW OUTFILE (STEM JOBNM."
000040 END
000041
000042 END
000043
000044 if RC = 2 then ,
000045 leave
000046 end
000047 "EXECIO 0 DISKR F1 (FINIS "
000048 "FREE FI(F1) "
000049
000050 "EXECIO 0 DISKW OUTFILE (FINIS "
000051 "FREE FI(OUTFILE) "
000052
000053 say count iters
000054
000055 exit
000056
000057 error:
000058 say "EXECIO error :" RC
000059 say "EXECIO error :" count iters
000060 exit
000061 novalue:
000062 say "*********************************"
000063 say "** **"
000064 say "** novalue trapped at line" || right(sigl,4) || " **"
000065 say "** **"
000066 say "*********************************"
000067 exit |
Again thank you so much for your suggestions!, I could able to step forward 50%.. |
|
Back to top |
|
|
Logeswaran Audhikesavan
New User
Joined: 26 Mar 2013 Posts: 5 Location: INDIA
|
|
|
|
Thank you All - It worked I made small changes at file creation step..
This is simply great!!!
Code: |
000001 /* rexx */
000002 dsname = 'XXXXX.T.REX.TEST5'
000003 DSE = SYSDSN("'"strip(dsname)"'")
000004 ADDRESS TSO
000005 IF DSE = 'OK' THEN
000006 DO
000007 "DELETE ('"dsname"')"
000008 END
000009
000010 trace "o"
000011 signal on novalue name novalue
000012 parse arg chunk
000013
000014 Address TSO
000015
000016 "ALLOC FI(F1) DS('XXXX.LOG.XXXXX8') SHR REUS "
000017
000018 "ALLOC DA('"DSNAME"') FI(OUTFILE)
000019 DSORG(PS) SPACE(1,1) TRACK LRECL(80) RECFM(F,B) MOD"
000020
000021 JOBNM.=' '
000022 jobnm.0=0
000023 iters = 0
000024 count = 0
000025 do forever
000026 "EXECIO 100 DISKR F1 (STEM STEM. "
000027 if RC > 2 then ,
000028 signal error
000029 iters = iters + 1
000030 SAY 'AM IN' STEM.0
000031 count = count + stem.0
000032
000033 DO I = 1 TO STEM.0
000034 IF INDEX(STEM.I,'ENDED AT HALINMA1 MAXCC=',1) > 0 THEN DO
000035 SAY 'AM INSIDE THE LOOP'
000036 K1 = jobnm.0 + 1
000037 JOBNM.k1 = SUBSTR(STEM.I,90,8)
000038 SAY 'JOBNAME IS ' JOBNM.K1
000039 ADDRESS TSO "EXECIO" K1 " DISKW OUTFILE (STEM JOBNM."
000040 END
000041
000042 END
000043
000044 if RC = 2 then ,
000045 leave
000046 end
000047 "EXECIO 0 DISKR F1 (FINIS "
000048 "FREE FI(F1) "
000049
000050
000051 "EXECIO 0 DISKW OUTFILE (FINIS "
000052 "FREE FI(OUTFILE) "
000053
000054 say count iters
000055
000056 exit
000057
000058 error:
000059 say "EXECIO error :" RC
000060 say "EXECIO error :" count iters
000061 exit
000062 novalue:
000063 say "*********************************"
000064 say "** **"
000065 say "** novalue trapped at line" || right(sigl,4) || " **"
000066 say "** **"
000067 say "*********************************"
000068 exit |
|
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
?? I would expect a continuation error at lines 18 to 19. |
|
Back to top |
|
|
Logeswaran Audhikesavan
New User
Joined: 26 Mar 2013 Posts: 5 Location: INDIA
|
|
|
|
Hi Pedro - Recent code which I posted is working perfectly..
if I use " quotes in 18th line to end that, then its giving error. To make this continued I ensured the quotes has been closed in 19th line.
Code: |
000018 "ALLOC DA('"DSNAME"') FI(OUTFILE)
000019 DSORG(PS) SPACE(1,1) TRACK LRECL(80) RECFM(F,B) MOD" |
|
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Pedro wrote: |
?? I would expect a continuation error at lines 18 to 19.
|
Logeswaran Audhikesavan wrote: |
Hi Pedro - Recent code which I posted is working perfectly..
if I use " quotes in 18th line to end that, then its giving error. To make this continued I ensured the quotes has been closed in 19th line.
Code: |
000018 "ALLOC DA('"DSNAME"') FI(OUTFILE)
000019 DSORG(PS) SPACE(1,1) TRACK LRECL(80) RECFM(F,B) MOD" |
|
The behavior is easily understood. The ALLOC command is passed as a string to the TSO environment; an opening quote on line 18 with a closing quote on line 19 gives a string with a lot of whitespace in it, but a good string nonetheless.
A problem could occur if there's so much whitespace that the length of the string exceeds 250 characters. For that reason, I'd code this as
Code: |
"ALLOC DA('"DSNAME"') FI(OUTFILE)",
"DSORG(PS) SPACE(1,1) TRACK LRECL(80) RECFM(F,B) MOD" |
but the way that the TS did it will work under most circumstances. |
|
Back to top |
|
|
Logeswaran Audhikesavan
New User
Joined: 26 Mar 2013 Posts: 5 Location: INDIA
|
|
|
|
thank you So much! for all the suggestions!! |
|
Back to top |
|
|
|