View previous topic :: View next topic
|
Author |
Message |
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi,
This is my scenario, Could u plz give me the exact syntax for this.
"Inspect whether the IN-STREET ( A FIELD) contains ?&? or ?/? or ?@?.
If it contains any of these characters, I 'm moving some error messages .
if it doesn't contains any of these characters, i' m calling some utility."
Thanks,
Aravind |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi Aravind Kumar. S,
Quote: |
"Inspect whether the IN-STREET ( A FIELD) contains ?&? or ?/? or ?@?.
If it contains any of these characters, I 'm moving some error messages .
if it doesn't contains any of these characters, i' m calling some utility." |
Code: |
INSPECT VARIABLE TALLYING I FOR ALL "@".
IF I >=1
DISPLAY 'ERROR MESSAGE'
ELSE
PERFORM UTILITY. |
This code will give you number of occurrences of @ in a counter (I here).
& If that counter is 1 or more....you find that char...
Similarly you can do for "&" and "/" too...
Tell me if it is not working....
Regards,
Priyesh. |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi Priyesh,
Thanks for ur reply.
In a single INSPECT command, is it possible to give '/','@','&' ?
one more query ,
I 've to Identify the position of first valid character (Alphabet, Number or Hash) in IN-STREET (Field).
For eg : If IN-STREET = ? 123 MAPLEFIELD ST. APT#34 ?
Then it shud be converted to
IN-STREET = ?123 MAPLEFIELD ST. APT#34 ?
the spaces shud be deleted.
how i can do this.plz help me
Thanks,
Aravind |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi Aravind,
Quote: |
In a single INSPECT command, is it possible to give '/','@','&' ? |
Yes it is possible.
Code: |
INSPECT IN-STREET TALLYING I FOR ALL "@"
J FOR ALL "&"
K FOR ALL "/". |
This will give number of occurrences of @, &, / to i, j, k respectively.
Then by comparing I, J, K you can do as per your requirement.
Quote: |
the spaces shud be deleted. |
Acc to your requirement I assume that you wanna delete initial spaces.
So Try this code...
Code: |
01 Z PIC 99 VALUE 1.
PERFORM MATCH UNTIL Z=0.
DISPLAY 'IN-STREET' IN-STREET.
MATCH.
INITIALIZE IN-STREET.
MOVE IN-STREET-WS TO IN-STREET.
IF IN-STREET(1:1) = ' '
ADD 1 TO P
INITIALIZE IN-STREET-WS
MOVE IN-STREET(P:11) TO IN-STREET-WS
ELSE
MOVE 0 TO Z.
EXIT. |
Let me know ...If remains any thing...
Regards,
Priyesh. |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi Priyesh,
Sorry ! i'm not getting the answer..I make my question more clear...
Consider this Eg.
If IN-STREET =
? ^*%$^#$# 123 MAPLEFIELD ST. APT#34 ?
Then it shud be converted to
IN-STREET = ?123 MAPLEFIELD ST. APT#34 ?
(i.e.) it shud remove leading and embedded sapces and characters other than Alphabet, Number or Hash.
Thanks,
expecting ur reply....
Aravind |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
& what is the lengthg of the field ?
Priyesh. |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Length is 100
aravind.s |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
If IN-STREET =
? ^*%$^#$# 123 MAPLEFIELD ST. APT#34 ?
Then it shud be converted to
IN-STREET = ?123 MAPLEFIELD ST. APT#34 ?
(i.e.) it shud remove leading and embedded sapces and characters other than Alphabet, Number or Hash. |
Then
IN-STREET = ?#$# 123 MAPLEFIELD ST. APT#34 ?
If you remove all initial char except number alpha or hash you will find this string only......Is that fine ?
Because you have given above expected IN-STREET = ?123 MAPLEFIELD ST. APT#34 ?
Priyesh. |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi ,
Sorry Priyesh
IN-STREET = ? @!~)(123 MAPLEFIELD ST. APT#34 ?
IN-STREET = ?123 MAPLEFIELD ST. APT#34 ?
This is the exact thing.
my intention is
it shud remove leading and embedded sapces
or
i can say like this
Identify the position of first valid character (Alphabet, Number or Hash) in IN-STREET. Start extracting characters from this position till no characters are found.
Thanks,
ARavind. S |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi Arvind,
I m making it clear, The code below will check each char in the variable IN-STREET and It'll go up till it finds a number, alpha or a hash.
Once it finds any char like that, It'll copy rest of the string.
I hope it was what you wanna do.
Code: |
PERFORM MATCH UNTIL Z=0.
DISPLAY 'IN-STREET' IN-STREET.
MATCH.
INITIALIZE IN-STREET.
MOVE IN-STREET-WS TO IN-STREET.
IF IN-STREET(1:1) >= 0 AND <=9
MOVE ZERO TO Z
ELSE
IF IN-STREET(1:1) >= 'A' AND <='Z'
MOVE ZERO TO Z
ELSE
IF IN-STREET(1:1) = '#'
MOVE ZERO TO Z
ELSE
ADD 1 TO P
INITIALIZE IN-STREET-WS
MOVE IN-STREET(P:100) TO IN-STREET-WS.
EXIT. |
Still If it is not working acc to your req ....let me know the result ...whatever.........
Regards,
Priyesh. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Aravind,
Seems like this thread's gotten out of hand so I'll ans your orig ques:
Quote: |
"Inspect whether the IN-STREET ( A FIELD) contains ?&? or ?/? or ?@?.
If it contains any of these characters, I 'm moving some error messages .
if it doesn't contains any of these characters, i' m calling some utility."
|
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. XXX.
*AUTHOR. XXX.
ENVIRONMENT DIVISION.
*
CONFIGURATION SECTION.
SOURCE-COMPUTER. S390
OBJECT-COMPUTER. S390
SPECIAL-NAMES. CLASS USING-JUNK-CHARS IS '&' '/' '@'.
*
INPUT-OUTPUT SECTION.
.
.
.
.
PROCEDURE DIVISION.
0000-MAIN.
IF IN-STREET IS USING-JUNK-CHARS
DISPLAY 'ERROR MSG'
ELSE
CALL'utilpgm'
END-IF |
You don't need the src/obj pgm lines or the I/O Sect. I just included them to position the SPEC NAMES pgraph. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi mmwife,
Quote: |
IF IN-STREET IS USING-JUNK-CHARS
DISPLAY 'ERROR MSG'
ELSE
CALL'utilpgm'
END-IF |
It doesn't work for me. My code is going in ELSE part despite having these characters.
Regards,
Priyesh. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Priyesh,
Sorry I didn't get back sooner. Didn't have the time to reseach it till now.
Here's the problem w/my solution:
I had it backwards, sort of. The CLASS has to contain ALL the possible chars that the variable (IN-STREET) in the IF can contain. For example, every char except &, /, or @.
I'll rewrite the code:
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. XXX.
*AUTHOR. XXX.
ENVIRONMENT DIVISION.
*
CONFIGURATION SECTION.
SOURCE-COMPUTER. S390
OBJECT-COMPUTER. S390
SPECIAL-NAMES. CLASS VALID-DATA IS 'A' THRU 'Z'
'0' THRU '9'
'!' ',' '.' '*'.
*
INPUT-OUTPUT SECTION.
.
.
.
.
PROCEDURE DIVISION.
0000-MAIN.
IF IN-STREET IS NOT VALID-DATA
DISPLAY 'ERROR MSG'
ELSE
CALL'utilpgm'
END-IF |
You may have to add other valid chars to the CLASS according to your needs, but that's the basic idea.
I hope this clears it up. Let us know if this works for you.
Thanx and |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi mmwife,
Firstly Thanks for your effort....
Concept of special names is being very confusing for me now......I tried your code it worked well for the requirements started in the thread......
But if you just replace any of the character with @ in your SPECIAL NAMES code it starts behaving otherwsie. As I did in the below code.
Code: |
SPECIAL-NAMES. CLASS VALID-DATA IS 'A' THRU 'Z'
'0' THRU '9'
'@' ',' '.' '*'. |
So is there any restrictions on some characters to be defined in special names.....
Here is the code I tried....with output...
Code: |
SPECIAL-NAMES. CLASS VALID-DATA IS 'A' THRU 'Z'
'0' THRU '9'
'@' ',' '.' '*'.
MOVE SPACES TO WS-XY.
MOVE '@' TO WS-XY.
DISPLAY WS-XY.
IF WS-XY IS VALID-DATA
DISPLAY 'NO JUNK'
ELSE
DISPLAY ' JUNK'.
MOVE SPACES TO WS-XY.
MOVE 'ASDFFA' TO WS-XY.
DISPLAY WS-XY.
IF WS-XY IS VALID-DATA
DISPLAY ' NO JUNK'
ELSE
DISPLAY ' JUNK'. |
output...
Regards,
Priyesh. |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
Priyesh,
The answer lies in the PIC clause that u are defining for WS-XY, if there are extra spaces in WS-XY, then sure the ELSE loop wud execute to display JUNK. If u have
Code: |
SPECIAL-NAMES. CLASS VALID-DATA IS 'A' THRU 'Z'
'0' THRU '9'
'@' ',' '.' '*' ' '.
|
then NO JUNK wud be displayed. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Priyesh,
You don't say what the size of WS-XY is. If it's larger than 6 bytes that may account for the result, since a space(s) will be contained in WS-XY and space was not included in the CLASS.
On the other hand, you may be right about special chars. I'll check that out and let you know. |
|
Back to top |
|
|
somasundaran_k
Active User
Joined: 03 Jun 2003 Posts: 134
|
|
|
|
Hi mmwife
I think the characters A thru Z are not contiguous.There are some printable/non-printable characters in this sequence. So we have to avoid them while checking for the alphabets.
It should be
Code: |
SPECIAL-NAMES. CLASS VALID-DATA IS 'A' THRU 'I'
'J' THRU 'R'
'S' THRU 'Z'
|
Regds
-Som |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Som,
You're right, I got lazy. There are a few printables in there, but with the exception of "\" AND "}" they're rare (only 2 others). To be safe you should code it:
Code: |
'A' THRU 'I' 'J' THRU 'R' 'S' THRU 'Z'
|
|
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi All,
Thanks for the replies....So called prob was with PIC clause as it was defined more than 6 bytes.....But people dont you think as an string operation It should work for less than full length values too.....
May be another way can to define a SPACE too in Valid List...Is It ?
Quote: |
There are a few printables in there, |
Can you please more elaborate on this....
Regards,
Priyesh. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Priyesh,
You can solve it by entering ' ' in the CLASS list, for example:
Code: |
SPECIAL-NAMES. CLASS VALID-CHARS IS '&' '/' '@' ' '. |
|
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi mmwife,
That worked perfact.....
Last doubt.....There has been some discussion on printables in the thread above.....Will any one give an idea...what they are......
Thanks & Regards,
Priyesh. |
|
Back to top |
|
|
somasundaran_k
Active User
Joined: 03 Jun 2003 Posts: 134
|
|
Back to top |
|
|
|