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

Mutiple condtions using REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Mon Jul 07, 2008 2:44 pm
Reply with quote

Hi,

i need to check mutiple conditons using REXX based on the number of variables present
EX: A = 123,B=NH,C=' ',D='2008'
i need to retrieve the records where
A=123,B=NH & D='2008' Must leave out C as the value is blank
like IF (SUBSTR(RC.I,1,3)=A & SUBSTR(RC.I,4,2)=B & SUBSTR(RC.I,8,4)=D)
and this may go in loop so that the IF condition needs to differ based on the varibales having the values. we will not know which field is blank at what time it is also possible to have more than one filed blank.

please let me know your suggestions.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 2:50 pm
Reply with quote

Quote:

please let me know your suggestions.


very humble suggestion icon_sad.gif
try to express Your requirements in a more understandable way,
the issue may be clear to You, but the way You exposed does not make it clear for everybody...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 3:05 pm
Reply with quote

trying to infer something from the info provided

recd is the thing You are trying to analyze
var1, var2, var3 are the variables You need to chek

here is a code snippe


Code:
recd = "var1var2var3var4"
pos1 = 1; len1 = 4; var1 = "var1"
pos2 = 5; len2 = 4; var2 = ""
pos3 = 9; len3 = 4; var3 = ""

NOT_MATCHED = 0
    MATCHED = 1

trace "I"
do 1
    flag = NOT_MATCHED
    if  var1 <> ""  & ,
        substr(recd,pos1,len1) <> var1 then leave
    if  var2 <> ""  & ,
        substr(recd,pos2,len2) <> var2 then leave
    if  var3 <> ""  & ,
        substr(recd,pos3,len3) <> var3 then leave
    flag = MATCHED
end

if flag = MATCHED then ,
   say "MATCHED"
else ,
   say "NOT MATCHED"

exit
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Mon Jul 07, 2008 3:06 pm
Reply with quote

EX: say i have some variables
A=123
B=NE
C=' '
D=2008
my input file has
RECORD1:123,NE,D,2008
RECORD2:123,NE,T,2008
RECORD3:111,HN,U,2007

I Need to fetch all the records having the value A=123,B=NEand D=2008 we dont have condition for C as the value of C=" ' (blank)
the condition will be like
IF ((SUBSTR(RECORD.I,1,3)=A & SUBSTR(RECORD.I,5,2)=B&SUBSTR(RECORD.I,10,4)=D)) This will retrieve me
RECORD1:123,NE,D,2008
RECORD2:123,NE,T,2008

like wise my IF CONDITION needs to be altered as per the fields having values. if A is balnk in then i should leave that fileds and frame the condition with the fields B,C and D.

how can this be done is my question.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 3:17 pm
Reply with quote

then the code snippet given does just that, tested


this new snippet tests for not existing variables or empty variables
Code:
recd = "var1var2var3var4"
pos1 = 1; len1 = 4; var1 = "var1"
pos2 = 5; len2 = 4; var2 = ""
drop var2
pos3 = 9; len3 = 4; var3 = ""

NOT_MATCHED = 0
    MATCHED = 1

trace "I"
do 1
    flag = NOT_MATCHED
    if  symbol('var1') =  "VAR" & ,
      strip(var1)    <> ""    & ,
        substr(recd,pos1,len1) <> var1 then leave
    if  symbol('var2') =  "VAR" & ,
      strip(var2)    <> ""    & ,
        substr(recd,pos2,len2) <> var2 then leave
    if  symbol('var3') =  "VAR" & ,
      strip(var3)    <> ""    & ,
        substr(recd,pos3,len3) <> var3 then leave
    flag = MATCHED
end

if flag = MATCHED then ,
   say "MATCHED"
else ,
   say "NOT MATCHED"

exit
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 3:34 pm
Reply with quote

this snippet is a bit more sophisticated

it builds the variable names dynamically from a list

Code:
recd = "var1var2var3var4"
pos1 = 1; len1 = 4; var1 = "var1"
pos2 = 5; len2 = 4; var2 = ""
drop var2
pos3 = 9; len3 = 4; var3 = "var3"

NOT_MATCHED = 0
    MATCHED = 1

vnam_l = "var1 var2 var3 var4"
vpos_l = "1    5    9    13" 
vlen_l = "4    4    4    4" 


trace "I"
flag = MATCHED
do  v = 1 to words(vnam_l)
   vnam = word(vnam_l,v)
    vpos = word(vpos_l,v)
   vlen = word(vlen_l,v)
   vval = value(vnam)
    if  symbol(vnam) <> "VAR" then ,
      iterate

    if  strip(vval) =  "" then ,
      iterate
   
    if  substr(recd,vpos,vlen) <> vval then do
      flag = NOT_MATCHED      
      leave
   end
end

if flag = MATCHED then ,
   say "MATCHED"
else ,
   say "NOT MATCHED"

exit
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Mon Jul 07, 2008 3:36 pm
Reply with quote

Thank you for the suggestions ...

but this one displays me the records even if one varible is present but i dont want it that way
i need to check for the all the varibles having values if it is present in that record and then fetch only that record as i have specified in my example before.

your suggestion on this?
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Mon Jul 07, 2008 3:49 pm
Reply with quote

Thank you so much enrico-sorichetti

This is what i was seraching for its does it and can please tell me why you have used DROP VAR2
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 3:54 pm
Reply with quote

Quote:
i need to check mutiple conditons using REXX based on the number of variables present
EX: A = 123,B=NH,C=' ',D='2008'
i need to retrieve the records where
A=123,B=NH & D='2008' Must leave out C as the value is blank


my samples just do that
if any of the source variables are not defined,or blanks or empty,
the comparison is skipped

written, made better, tested, found working as per quoted requirement, and posted



Quote:
your suggestion on this?


just learn to express Your requirements in a non misleading way, please icon_evil.gif

added multiple records, tested as per original requirement

Code:

recd.0 = 5
recd.1 = "var1var2var3var4"
recd.2 = "var1varxvar3var4"
recd.3 = "var1var2varxvar4"
recd.4 = "var1var2var3varx"
recd.5 = "var1var2var3varx"

var1 = "var1"
var3 = "var3"

NOT_MATCHED = 0
    MATCHED = 1

vnam_l = "var1 var2 var3 var4"
vpos_l = "1    5    9    13" 
vlen_l = "4    4    4    4" 


do  r = 1 to recd.0
   recd = recd.r
   trace "O"
   flag = MATCHED
   do  v = 1 to words(vnam_l)
      vnam = word(vnam_l,v)
      vpos = word(vpos_l,v)
      vlen = word(vlen_l,v)
      vval = value(vnam)
      if  symbol(vnam) <> "VAR" then ,
         iterate
   
      if  strip(vval) =  "" then ,
         iterate
      
      if  substr(recd,vpos,vlen) <> vval then do
         flag = NOT_MATCHED      
         leave
      end
   end
   
   if flag = MATCHED then ,
      say "MATCHED    " r recd.r
   else ,
      say "NOT MATCHED" r recd.r

end

exit

Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Mon Jul 07, 2008 4:09 pm
Reply with quote

Thank you so much for the help provided on this enrico-sorichetti
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 4:21 pm
Reply with quote

the drop statement was to test for no existance of a variable...

there is a glitch in the last snippet

Code:

... before
      vlen = word(vlen_l,v)
      vval = value(vnam)
      if  symbol(vnam) <> "VAR" then ,
         iterate


      if  strip(vval) =  "" then ,
         iterate


Code:

... after
      vlen = word(vlen_l,v)
      if  symbol(vnam) <> "VAR" then ,
         iterate

      vval = value(vnam)
      if  strip(vval) =  "" then ,
         iterate


it is wiser to retrieve a variable value after having checked its existence
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Mon Jul 07, 2008 4:54 pm
Reply with quote

Got it thank you
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jul 07, 2008 8:34 pm
Reply with quote

Hi Enrico,

Quote:
there is a glitch in the last snippet

Long ago someone told me that bugs were "sons of glitches". . . .
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 07, 2008 10:35 pm
Reply with quote

Hi Dick,
I hope You will forgive my glitch icon_sad.gif
the snippet was written an tested while answering the TS
( ... can be seen by the messages timestamps )

I promise to be more careful in the future icon_biggrin.gif
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Fri Aug 01, 2008 6:09 pm
Reply with quote

hi enrico,

this one executed fast for few records but my input has billons od records its very slow on doing this is there any way to make it better and faster.

Suggestions on this will be of great help
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Aug 01, 2008 7:16 pm
Reply with quote

billiions of records is considered needed info when talking about rexx. rexx is not a high end i/o utility. you could compile your rexx.

you could build sort control statements
or
write a cobol/pl1/assembler module to process this data.
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Tue Aug 05, 2008 9:47 am
Reply with quote

this rexx consists of panels and rexx codes, where the user input some values i need tovalidate each fields and throw message after validation take the values entered by the user and search if the combination of values entered by the user is present in a file which is going to have billion of records if the combination exists writes it to a file if not pops up an error message as 'Combination not found' and all these will be done online REXX validtions will be the backend so its not possible to put this in a batch mode.Searching of the combinations of field values entered by the user in the file containing billion of records takes me time.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Aug 05, 2008 10:24 am
Reply with quote

Hi,

I can't believe anyone could come up with such a design, how often are these requests run ? how many users can request this ? what is the current time it takes to satisfy one of these requests ?

Surely the values entered by the user can be validated and saved into a file which can then be used in batch.

I would try to capture all requests into one file and run a batch job on a daily basis.

Gerry
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Aug 05, 2008 12:33 pm
Reply with quote

Gerry, stop it will you, coming up with sensible suggestions

What do you think this is, a help forum or something icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 05, 2008 7:54 pm
Reply with quote

Hello,

If the concept has been proven, it would be best to do as DBZ suggests and re-code the process in a better suited language.

REXX may be the worst choice for processing high volumes of data. . .
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Aug 05, 2008 10:00 pm
Reply with quote

Quote:
search if the combination of values entered by the user is present in a file which is going to have billion of records if the combination exists


If this is searched regularly, I think the data is stored in the wrong format. There is not really a good way to search billions of records stored in a sequential format. It should be in a database, where it might take the reading of a few index blocks before finding (or not) the record.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Aug 05, 2008 10:04 pm
Reply with quote

Billions of records, Millions of records I think some of these record estimates are a little off.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Wed Aug 06, 2008 12:48 am
Reply with quote

Quote:
my input has billons od records its very slow on doing this is there any way to make it better and faster.

It is hard to believe that you got to billions of records without first realizing that there were performance problems. When you say 'billions', I am just assuming that you really meant "large number of records".

The way to speed it up is to not use a sequential file. Use VSAM with keyed records. I think you can get tools to process VSAM from rexx. (or as I said earlier, use a real database).
Back to top
View user's profile Send private message
vidyaa

New User


Joined: 02 May 2008
Posts: 77
Location: chennai

PostPosted: Wed Aug 06, 2008 11:05 am
Reply with quote

yes i got your words intially it was thought to be few record and now it has come to billions. This is need to process online to get the user input and validate and throw him error messages. this cannot be changed to a program i guess. the seraching part kills time is there any way to incorporate this searching part in languale like cobol and combine with rexx as this needs to be done online.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Aug 06, 2008 11:11 am
Reply with quote

Hi,

I want to be the user entering the data and waiting for the results. icon_wink.gif


I'll have to find ways of amusing myself.

Gerry
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 -> CLIST & REXX Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top