Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Mutiple condtions using REXX
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
vidyaa

New User


Joined: 02 May 2008
Posts: 70
Location: chennai

PostPosted: Mon Jul 07, 2008 2:44 pm    Post subject: Mutiple condtions using REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 2:50 pm    Post subject: Reply to: Mutiple condtions using REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 3:05 pm    Post subject: Reply to: Mutiple condtions using REXX
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: 70
Location: chennai

PostPosted: Mon Jul 07, 2008 3:06 pm    Post subject: Reply to: Mutiple condtions using REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 3:17 pm    Post subject: Reply to: Mutiple condtions using REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 3:34 pm    Post subject: Reply to: Mutiple condtions using REXX
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: 70
Location: chennai

PostPosted: Mon Jul 07, 2008 3:36 pm    Post subject: Reply to: Mutiple condtions using REXX
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: 70
Location: chennai

PostPosted: Mon Jul 07, 2008 3:49 pm    Post subject: Reply to: Mutiple condtions using REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 3:54 pm    Post subject: Reply to: Mutiple condtions using REXX
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: 70
Location: chennai

PostPosted: Mon Jul 07, 2008 4:09 pm    Post subject: Reply to: Mutiple condtions using REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 4:21 pm    Post subject: Reply to: Mutiple condtions using REXX
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: 70
Location: chennai

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

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

Site Director


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

PostPosted: Mon Jul 07, 2008 8:34 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Jul 07, 2008 10:35 pm    Post subject: Reply to: Mutiple condtions using REXX
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: 70
Location: chennai

PostPosted: Fri Aug 01, 2008 6:09 pm    Post subject:
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    Post subject:
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: 70
Location: chennai

PostPosted: Tue Aug 05, 2008 9:47 am    Post subject:
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: 1703
Location: Australia

PostPosted: Tue Aug 05, 2008 10:24 am    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Tue Aug 05, 2008 12:33 pm    Post subject:
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

Site Director


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

PostPosted: Tue Aug 05, 2008 7:54 pm    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us