In Built function - SUBSTR clarification.



IBM's Command List programming language & Restructured Extended Executor

In Built function - SUBSTR clarification.

Postby Viswanathchandru » Sat Jun 08, 2013 4:50 pm

Dear all,

I'm trying to list a VSAM file to get the "HI-U-RBA" and the "HI-A-RBA". I'm listing the file and writing it to a PS file. Through EXECIO * DISKR i'm reading it followed by a substr statement to find the required value and it goes as given below. To my surprise it's not capturing the required value. Instead its going for the last line. I tried to find the position still it says the particular string "HI-U-RBA" is not found(Returns 0). Can anyone guide me where do i go wrong please? Here is the code I'm using.

/*REXX*/
PULL DSN
X=OUTTRAP('RET.')                           
DSNF = STRIP(DSN)                         
"LISTC ENT('"DSNF"') ALL"           
X=OUTTRAP=('OFF')                           
"EXECIO * DISKR OUTTR(STEM RET. FINIS"     
DO IX=1 TO RET.0                           
VAR1 =SUBSTR(RET.IX,POS('HI-U-RBA',RET.IX)+14)
VAR2 =SUBSTR(RET.IX,POS('HI-A-RBA',RET.IX)+14)                 
END                                         
SAY VAR1                                   
SAY VAR2
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: In Built function - SUBSTR clarification.

Postby MrSpock » Sat Jun 08, 2013 5:46 pm

Get rid of this line:

"EXECIO * DISKR OUTTR(STEM RET. FINIS"

It's completely unnecessary.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: In Built function - SUBSTR clarification.

Postby enrico-sorichetti » Sat Jun 08, 2013 5:48 pm

what happened when You tried running the script with a Trace ?

and why not proceed in small steps, and after the LISTC

Do i = 1 to YourStemVar.0
    say YourStemVar.i
end

to see what is going on

and why not test the return code after the list ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: In Built function - SUBSTR clarification.

Postby Viswanathchandru » Sat Jun 08, 2013 6:26 pm

Hi Enrico, Thanks for addressing the post.

When I coded this after LISTC

Do i = 1 to RET.0
    say RET.i
end


I was able to get the output of LISTC as usual. The RC says 0.


Mr.Spock. thanks for addressing the post.

I made a mistake while copying the code. There is a DISKW before the DISKR. My apologize for that.
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time

Re: In Built function - SUBSTR clarification.

Postby enrico-sorichetti » Sat Jun 08, 2013 7:07 pm

You are not checking if You are on the good line

VAR1 =SUBSTR(RET.IX,POS('HI-U-RBA',RET.IX)+14)
VAR2 =SUBSTR(RET.IX,POS('HI-A-RBA',RET.IX)+14)   


before assigning the HURBA You should do something like

if pos('HI-U-RBA,RET.IX) = 0 then iterate /* the line does not contain the HURBA */
do whatever

and ...
since the HARBA line comes before the HURBA line
just process them in the right order

and...
when processing the HURBA check that the HARBA has been processed

and ...
since a listc provides the HARBA/HURBA quite a few times
you should check which of which You are dealing with
ALLOCATION or EXTENT
and which association

and...
it would be wise to set some flags to check that You are processing the records in the right order for the right components
LISTC provides things in the proper way, the flags are needed to make sure that YOU are processing things the way they should

the flags might be needed for the cluster, ALLOCATION. association, component extent number...
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
Viswanathchandru (Mon Jun 10, 2013 1:30 pm)
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: In Built function - SUBSTR clarification.

Postby Viswanathchandru » Mon Jun 10, 2013 1:30 pm

Hello Enrico,

Thanks for the detailed explanation and time!!

Regards,
Viswa
Viswanathchandru
 
Posts: 271
Joined: Mon Oct 25, 2010 2:24 pm
Has thanked: 25 times
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post