View previous topic :: View next topic
|
Author |
Message |
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi,
I have a requirement in REXX to find if a record has any of the numbers from 1-9(except 0) in any position
and if the record has characters from A-Z in any position.
Code: |
.................. -valid record
............00000000000.. -valid record
..................... -valid record
//DLDOHI09 JOB CLASS=P,MS -invalid record
00002028BC 1ABC-077 -invalid record
0000000920030111DUMMY FOR -invalid record
0950200908191A 2009081718 -invalid record
110000001 19890 -invalid record
2009082018011900000000000 -invalid record
002006120950P700328GR B45 -invalid record
P188712200908191000020490 -invalid record
A 1 -invalid record
0950008212009505655130352 -invalid record
-valid record
......................... -valid record |
If a record has 1-9 or A-Z in any place then the record has to be flagged invalid.
If a record has ....... or spaces or combination of them, then they have to be considered as valid.
I am trying to test the first record of a list of VSAM files if they have low value records or 000000's.
I tried the below code, but as you can see it is not capable to detecting records like " ....." or "0000...."
Could you please help.
Code: |
TEST_VALUE=SUBSTR(DATAS.1,1,30)
TEST_VALUE2=C2X(TEST_VALUE)
SAY 'TEST_VALUE2 IS ' TEST_VALUE2
IF (TEST_VALUE2 = 0 |,
TEST_VALUE = '000000000000000000000000000000') THEN
DO
Q=Q+1
MAKE.Q=FILE1 ' HAS NULL RECS'
END |
Thanks & Regards, |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
means nothing, it' s just a way for ISPF to tell that the chars are not displayable
so it would be nice to specify better Your requirement |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Oh!.. I missed that point.
By .... i mean only x'000000' .
x'000000' = valid.
other .... hex values are invalid.
Code: |
With HEX on mode..
.............
0000000000000
0000000000000 |
Hex mode:
Code: |
0000000000000...
FFFFFFFFFFFFF000
0000000000000000
|
is also valid.
The bottom line is to, test if a line has 1-9 or A-Z in any position or not.
Pls let me know if you need more information.
Thanks, |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I would TRANSLATE each line.
x'00' > x'00'
x'??' > x'31' where the ?? is everyother character except x'00'
then I would do a POS looking for x'31'.
When 0, then valid
otherwise invalid. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
here is a code snippet that will check for any unwanted chars
Code: |
samp.0 = 3
samp.1 = ",.:;)(/"
samp.2 = "..123"
samp.3 = "ABC.DE"
invchar = "123456789ABCDEF"
do i = 1 to samp.0
if 0 = verify(samp.i,invchar,"M") then ,
say " VALID" samp.i
else ,
say "NOT VALID" samp.i
end
|
|
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi Enrico and DBZ,
Many Thanks for your help. I will cobble with the code given by Enrico.
It is sufficient for the requirement.
Thanks again, |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
It is sufficient for the requirement. |
actually, it is perfect.
I like giving solutions,
because enrico will always provide a more efficient solution.
I image VERIFY is much faster than TRANSLATE, POS. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Quote: |
actually, it is perfect. |
I totally agree.. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
oh, cm' on You wise guys |
|
Back to top |
|
|
|