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
 

 

Need to validate CICS field with atleast 2 characters

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
kudamala

New User


Joined: 12 Sep 2008
Posts: 51
Location: Bangalore

PostPosted: Tue Sep 16, 2008 11:14 am    Post subject: Need to validate CICS field with atleast 2 characters
Reply with quote

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
View user's profile Send private message

revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Tue Sep 16, 2008 11:26 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Sep 16, 2008 7:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Tue Sep 16, 2008 10:59 pm    Post subject:
Reply with quote

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
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Wed Sep 17, 2008 11:41 am    Post subject:
Reply with quote

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
View user's profile Send private message
kudamala

New User


Joined: 12 Sep 2008
Posts: 51
Location: Bangalore

PostPosted: Wed Sep 17, 2008 12:32 pm    Post subject: Need to validate CICS field with atleast 2 characters
Reply with quote

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
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Wed Sep 17, 2008 3:49 pm    Post subject:
Reply with quote

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

Code:
XXXXXXX[b]AB[/b]X


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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Sep 17, 2008 10:20 pm    Post subject:
Reply with quote

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
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Sep 18, 2008 2:45 pm    Post subject:
Reply with quote

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 icon_razz.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Thu Sep 18, 2008 5:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Thu Sep 18, 2008 7:17 pm    Post subject:
Reply with quote

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
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Sep 19, 2008 9:05 am    Post subject:
Reply with quote

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
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Fri Sep 19, 2008 10:17 am    Post subject:
Reply with quote

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
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Sep 19, 2008 11:06 am    Post subject:
Reply with quote

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 icon_wink.gif
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Sep 19, 2008 11:07 am    Post subject:
Reply with quote

Sorry,

Its not
Quote:

Terminal monitor pgm
it is

Terminal hadware pgm
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: Fri Sep 19, 2008 11:22 am    Post subject:
Reply with quote

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
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Fri Sep 19, 2008 11:36 am    Post subject:
Reply with quote

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 icon_wink.gif
Back to top
View user's profile Send private message
Earl Haigh

Active User


Joined: 25 Jul 2006
Posts: 475

PostPosted: Fri Sep 19, 2008 8:45 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CICS START AND CANCEL blayek CICS 1 Wed Dec 07, 2016 3:27 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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