View previous topic :: View next topic
|
Author |
Message |
kudamala
New User
Joined: 12 Sep 2008 Posts: 51 Location: Bangalore
|
|
|
|
Hi
I need to validate a CICS field created using SDF2. My validation is; the field should accept atleast 2 characters, if I enter 1 character, it should throw an error message.
Can you please let me know how can I check the number of characters in the filed? I tried to check with field attribute L. for ex:
IF FILEDL < 2
But it is not working
Thanks in advance
Ravi |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hi Ravi,
Welcome to forum..
validate Field+I attribute using referential modification
like
IF (FIELDI(1:2) IS NOT EQUAL TO SPACES
DO SOMETHING
ELSE
.........
END-IF.
Hope it helps you |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
the field should accept atleast 2 characters, if I enter 1 character, it should throw an error message. |
Quote: |
IF (FIELDI(1:2) IS NOT EQUAL TO SPACES |
How will that code ensure there are 2 characters entered?
Please post only suggestions that have been tested and proven to work as needed. |
|
Back to top |
|
|
Earl Haigh
Active User
Joined: 25 Jul 2006 Posts: 475
|
|
|
|
When using length field of BMS map copybook for input editing.
IF FILEDL < 2
be careful, attribute byte on the previous send has to be
set to NOFSET |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hello,
Quote: |
How will that code ensure there are 2 characters entered? |
What is this code for
Code: |
IF (FIELDI(1:2) IS NOT EQUAL TO SPACES |
Code: |
FIELDI(1:2) represent 2 bytes starting from position 1.
| |
| Length Field
|
Position |
We are validating whether this fields are equal to spaces, If it spaces throw an error msg.
Quote: |
the field should accept atleast 2 characters, if I enter 1 character, it should throw an error message. |
You can same way as said,
ie
Quote: |
IF FIELDI(1:2) > spaces and
FIELDI(1:1) > spaces and
FIELDI(2:1) > Spaces
do something
ELSE
.....
END-IF |
The above validating first 2 bytes for character, if it not there it will throw error
Quote: |
Please post only suggestions that have been tested and proven to work as needed. |
I Coded same type for my previous project, it works fine for me.
Any suggestion are welcomed |
|
Back to top |
|
|
kudamala
New User
Joined: 12 Sep 2008 Posts: 51 Location: Bangalore
|
|
|
|
Hi Raghu
Thanks for your solution. In fact the complete validity is as follows:
The field shoudl accept SPACE or ALPHANUMERIC. If ALPHANUMERIC is entered, that should have atleast 2 characters.(may be anywhere in the field)
I am able to check for ALPHANUMERIC, but unable to check the number of characters in the map field.
Thanks in advance |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hi Ravi,
But you have mentioned only 2 bytes of information from map..
ok, Please post Map field actual length and actual length of Data passing through that map fields...
I suggest you to use this code in case if you are passing data like this..
I assuming;
Actual length of fields = 10 byets
The data entered in that map fields at a position of say 8
Consider a MAP FIELD
X - represent blank space
AB - character
Then Use Put it in loop with Referential modifiction like
Code: |
Perform verying ws-i from 1 by 1 until FIELDI(ws-i:1) > spaces or ws-i > 10
move ws-i to ws-count
end-if. |
after executing above gives the counter(ie position of character in a map field)
That is WS-COUNT will become 8 but still ws-i is having value which represent the position of character in that field
Code: |
perform verying ws-i from 1 by 1 until FIELDI(ws-i:1) is equal to spaces
move ws-i to ws-cnt
end-if |
On executing above code will give number of character which is in that field(ws-cnt)
OR
Use INSPECT VERB for to calculate number of character in that field
Then validate
Code: |
IF ws-count < 10 - means there will be some records in that field
IF FIELD(ws-count:ws-cnt) > spaces
do some thing
else
trow error msg
else
throw error msg
end-if |
Hope you got some idea |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Code: |
IF (FIELDI(1:2) IS NOT EQUAL TO SPACES |
is wrong for the original posted requirement. This is not an opinion, it is a fact.
The requirement has been changed from the initial post and i believe could use a bit more clarification.
Quote: |
If ALPHANUMERIC is entered, that should have at least 2 characters.(may be anywhere in the field) |
Must there be at least 2 consecutive characters or is it all right to have embedded spaces. Are either of these valid (" a b" or "a b c")? |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hello,
Quote: |
IF (FIELDI(1:2) IS NOT EQUAL TO SPACES
is wrong for the original posted requirement. This is not an opinion, it is a fact. |
What did you mean, It won't work, have you tried this if it wrong how you will going to validate that field
Please come with sample code |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
revel, read the original post again. Where, exactly, in there does it mention a need to check for spaces? Furthermore, when sending a map out it is initialized to LOW-VALUES per the Programming Guide. So if the MDT is set and the field comes back into the program without the user entering any data into the field, your IF test would be true since LOW-VALUES are not SPACES, even though the user entered no data into the field.
As Dick said, your post is completely, irrevocably wrong for the question posed by the original message. |
|
Back to top |
|
|
Earl Haigh
Active User
Joined: 25 Jul 2006 Posts: 475
|
|
|
|
Robert,
initializing a field to low values on a send does not ensure you
will receive low values on the receive.
the standard solution is to test length of a field after a receive.
However, you must perform
move an NOFSET (MDT OFF) attribute to FIELDA
Before:
EXEC CICS SEND MAP
Then:
EXEC CICS RECEIVE MAP
IF FIELDL less than 1
* Then no data was entered by user
IF FIELDL less than 2
* then only 1 character was entered by user |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hi Earl,
Thats True, we can validate whether the data were entered in Map field either by FIELD+L(length of data entered) or FIELD+I(using referential modification).
See, I have used this it, It work for me fine, thats why i suggest him to do so.. |
|
Back to top |
|
|
Earl Haigh
Active User
Joined: 25 Jul 2006 Posts: 475
|
|
|
|
Hi Revel,
your code works for your situation, but it does not resolve the
original post.
Quote: |
>> Can you please let me know how can I check the number of characters in the filed? I tried to check with field attribute L. for ex:
IF FILEDL < 2
But it is not working |
Solution is
move an NOFSET (MDT OFF) attribute to FIELDA
Before:
EXEC CICS SEND MAP |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hi Earl,
Small clarification,
Why we need this
Quote: |
move an NOFSET (MDT OFF) attribute to FIELDA |
What is the use of terminal hardware pgm then, I hope you are aware of Terminal monitor pgm.
suggestion are welcomed |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Sorry,
Its not
Quote: |
Terminal monitor pgm |
it is
Terminal hadware pgm |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
What is the use of terminal hardware pgm then, I hope you are aware of Terminal monitor pgm. |
Quote: |
it is . . Terminal hadware pgm
|
Even with the correction, it is not clear what you are asking or saying.
Do you have some doubt about the 3270-emulator program that is running on your desktop or is your question about some mainframe component? |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Dear Dick,
the MDT gets set by the hardware (or PC emulator) whenever a field us updated. This is part of the 3270 specification, and nothing to do with CICS. It's been that way for almost 40 years.
MDT set to 0 when user is not entered any data
MDT set to 1 when user entered data
The length data value fieldL shows that data has been entered in the field (i.e. modified) if it is > 0.
So i suggest him to validate fieldL or FieldI for his requirement.
Suggestion are welcomed, see we are all here for learning |
|
Back to top |
|
|
Earl Haigh
Active User
Joined: 25 Jul 2006 Posts: 475
|
|
|
|
Quote: |
move an NOFSET (MDT OFF) attribute to FIELDA |
you need this to set the field (or fields) to a NOT modifief state (MDT OFF)
before sending map to the screen.
This will provide the capability to check the true length of the number
of characters entered for a particular field.
Standard BMS stuff.
Quote: |
What is the use of terminal hardware pgm |
please clarify>>>> terminal hardware pgm
; |
|
Back to top |
|
|
|