Some questions about MAP Processing and Data Validation



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Some questions about MAP Processing and Data Validation

Postby rogerb » Thu Aug 09, 2018 4:33 am

Hello.
I'm still having the same problem, I cannot make posts with code.

So, I'm going to make this post without code.
First of all, I would like to express my appreciation to everybody who helped me in the previous posts.
In the topic "Problem COBOL - CICS Program gives ABEND AEIP - INVREQ" that was posted in VSAM/SMS, Mr Robert Sample wrote:

The usual way to process maps is to display the map with every field needed, the terminal user keys data into every relevant field, and then when the map is received validate each field sequentially. If the map needs to be resent to fix errors, every error field will be highlighted and can be fixed at one time. Processing the data in the program often takes no more than a few seconds, while the data entry may require several minutes.


He's right, so I've started to change my program to follow these best practices.

My questions are about the MAP processing and validation.
I've studied the essentials of Basic Map Support but now I'see it was the basic.
In the 050-ADD-RECORD, I'm providing the user with the instructions for fulfilling the fields as a series of SEND MAP.
Then I do the SEND MAP with the message field as "PLEASE WRITE IN FIELDS AS INSTRUCTED ABOVE", and after that the RECEIVE MAP.
Then all the map fields are moved to the corresponding variables in the Working Storage and the record is written in the file.
My first question is about the options, until now I'm providing the options as messages in the MESSAGE field of the map.

I've seen some pages in the internet that show printscreens with the CICS program being executed and showing the options directly on the screen, and I believe that is achieved with protected fields, but how do I change the color and aspect of those fields to be diferent from the protected fields ?

In previous COBOL programs I made some validations.
For example in the pseudo-conversational programs I created LEAPYER and LEAPCAL, the program LEAPYER makes the validation of data, and if the data is validated it is passed to the LEAPCAL program.
The Gregorian year must be a positive number and cannot be 0.
The LEAPCAL program calculates if the number of the Gregorian year is a leap year or a common year.

The validation above is a very simple, so the second question is about data validation, in this CARMAP program the date of sale (SALE DATE) is asked as DD-MM-YYYY.
How can I validate that the user inserted DD-MM-YYYY and not DD/MM/YYYY or even worse DD-MM-YY or MM-DD-YYYY ?
Is it possible to define that a field has to be filled with, for example 5 to 10 characters and validate if the user has inserted less (in this example 3) or more (for example 12) ?
If I create a program that asks for a password can I define in my COBOL program the same criteria as I see in some websites and validate it (for example at least 5 characters and it must include at least one Capital letter and a number) ?
What are the good practices in data validation ?


The third question is, assuming that the user leaves a mandatory field blank or the content of that field is incorrect, how do I change the color of the field to show the user the field that needs to be corrected, and how do I show a message in the map to the user, instructing the user to update that field or fields ?

I apologize if it's a lot of questions but they're all related, so, I decided to ask them all in the same topic.

Thank you,
Roger
rogerb
 
Posts: 65
Joined: Sat Jul 28, 2018 9:14 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Some questions about MAP Processing and Data Validation

Postby expat » Thu Aug 09, 2018 11:21 am

[code=mainframe]Ensure that the square brackets are present and it works good[/code]
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: Some questions about MAP Processing and Data Validation

Postby enrico-sorichetti » Thu Aug 09, 2018 12:38 pm

What are the good practices in data validation ?

those required by the application design

the map look can be changed by setting the appropriate field attributes
( color, protection, highligth, ... )

look at the cics manuals to find out the names of the attributes
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Some questions about MAP Processing and Data Validation

Postby NicC » Thu Aug 09, 2018 3:21 pm

I cleaned up (deleted) the first two posts.

All my CICS knowledge comes from:
1 - CICS manuals
2 - other CICS programs and
3 - principally, the book "CICS a how-to for COBOL Programmers" old but relevant and very good.

I suggest that you get that book or any other that you can find.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Some questions about MAP Processing and Data Validation

Postby enrico-sorichetti » Thu Aug 09, 2018 6:43 pm

google for cics primer and You will get the links to the IBM CICS sample application
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Some questions about MAP Processing and Data Validation

Postby rogerb » Thu Aug 09, 2018 9:15 pm

Good afternoon,
Thank you for all your previous answers.
I know I need to study books and manuals, but many manuals, especially the IBM manuals are written with such terminology that makes it difficult for me to understand.
Unfortunately, I haven't had much opportunity to contact with other programs, at least until this forum.
I would like to rephrase at least two of the questions I asked earlier.

Is it possible to use the length of a field to test how many characters were inserted in that field, for exmple in field NAME if NAMEL = 6, 6 characters were inserted, right ?
Is it possible to test the first character entered in the field, to see if that character is a number, a letter, or a special sign (@ -), and do the same for character 2, and character 3... ?

Thank you,
Roger
rogerb
 
Posts: 65
Joined: Sat Jul 28, 2018 9:14 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Some questions about MAP Processing and Data Validation

Postby Robert Sample » Thu Aug 09, 2018 9:59 pm

Is it possible to use the length of a field to test how many characters were inserted in that field, for exmple in field NAME if NAMEL = 6, 6 characters were inserted, right ?
What happened when you tried this?
Is it possible to test the first character entered in the field, to see if that character is a number, a letter, or a special sign (@ -), and do the same for character 2, and character 3... ?
Use reference modification on each character of the field. This code would do it for the first byte (you will want to use a variable instead of a constant 1 in your code):
001200      IF  WS-SOURCE-X ( 1 : 1) ALPHABETIC                                
001300      OR  WS-SOURCE-X ( 1 : 1) NUMERIC                                    
001400      OR  WS-SOURCE-X ( 1 : 1) = '@'                                      
001500      OR  WS-SOURCE-X ( 1 : 1) = '-'                                      
001600          DISPLAY ' 1 MATCHED'                                            
001700      END-IF.      
As an alternative you could use the CLASS clause in the CONFIGURATION SECTION to define your own class and not have all the OR clauses in your IF statement.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Some questions about MAP Processing and Data Validation

Postby Robert Sample » Thu Aug 09, 2018 10:23 pm

but how do I change the color and aspect of those fields to be diferent from the protected fields ?
Google bms extended field attribute to find out more about 3270 attributes that you can change. Note that extended field attributes may require system support since the terminal has to be able to handle them.
The Gregorian year must be a positive number and cannot be 0.
The LEAPCAL program calculates if the number of the Gregorian year is a leap year or a common year.
My first comment is that 1 is not a valid Gregorian year -- depending upon the country, nothing less than 1582 is valid for a Gregorian year. My second comment is that you don't need a program to determine leap years -- a single IF statement in COBOL can determine that (although it is not a simple IF statement).
How can I validate that the user inserted DD-MM-YYYY and not DD/MM/YYYY or even worse DD-MM-YY or MM-DD-YYYY ?
The simple answer is you cannot tell in all cases -- 08-09-2018 could be September 8th or August 9th, and there is no way to tell which was meant.
how do I show a message in the map to the user, instructing the user to update that field or fields ?
Define a message field (usually this is done at the bottom of the screen) that starts out blank and is filled with a message if an error occurs. Depending upon the application and the screen size, sometimes more than one line are allocated to messages.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Some questions about MAP Processing and Data Validation

Postby rogerb » Thu Aug 09, 2018 11:10 pm

Good afternoon Mr. Robert Sample.

Thank you for your answers.

Is it possible to use the length of a field to test how many characters were inserted in that field, for exmple in field NAME if NAMEL = 6, 6 characters were inserted, right ?


When I tested this I get the full length of the map field I'm using.

For example if I'm using a map field FIELD with a length of 18, when I do:

MOVE FIELDL to MSGO.
SEND MAP

it shows 18.
So I was wrong, and I assume it.

About the LEAP YEAR, I was just mentioning it an example of a simple data validation that I was already doing in my COBOL programs, to explain that I needed to ask you how to do the more advanced data validation.

I used the following IF statement to define if a year is a leap year or a common year.

Assuming YI is the field where you insert the number of the year:


MOVE YI TO YOUT.
DIVIDE YOUT BY 4 GIVING Q REMAINDER R4.                      00324099
003250     DIVIDE YOUT BY 100 GIVING Q REMAINDER R100.                  00325099
003260     DIVIDE YOUT BY 400 GIVING Q REMAINDER R400.                  00326099
003300     IF R400 = 0                                                  00330099
003610       MOVE "THIS YEAR IS A LEAP YEAR !" TO WS-MESSAGE            00361099
003620       ELSE                                                       00362099
003621       IF R100 NOT = 0 AND R4 = 0                                 00362199
003622         MOVE "THIS YEAR IS A LEAP YEAR !" TO WS-MESSAGE          00362299
003624     ELSE                                                         00362499
003630       MOVE "THIS YEAR IS A COMMON YEAR !" TO WS-MESSAGE          00363099
003640     END-IF.                                                      00364099
003704     MOVE WS-MESSAGE TO MESSAGEO.                                 00370499
003710     MOVE MESSAGEO TO MSGO.                                       00371099
004310     EXEC CICS                                                    00431099
004320     SEND MAP('LEAPMA') MAPSET('LEAPMAP')                         00432099
 


Thanks,
Roger
rogerb
 
Posts: 65
Joined: Sat Jul 28, 2018 9:14 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Some questions about MAP Processing and Data Validation

Postby Robert Sample » Thu Aug 09, 2018 11:47 pm

IF  YOUT = YOUT / 400 * 400
OR  (YOUT = YOUT / 4 * 4  
     AND YOUT NOT EQUAL YOUT / 100 * 100 )
    MOVE "THIS YEAR IS A LEAP YEAR !" TO WS-MESSAGE
ELSE
    MOVE "THIS YEAR IS A COMMON YEAR !" TO WS-MESSAGE
END-IF
as long as YOUT is defined PIC 9(04) then this code takes advantage of the way COBOL handles intermediate results.
When I tested this I get the full length of the map field I'm using.

For example if I'm using a map field FIELD with a length of 18, when I do:

MOVE FIELDL to MSGO.
SEND MAP

it shows 18.
So I was wrong, and I assume it.
IIRC (and it has been a number of years since I worked with BMS maps), your results partly depend upon how you defined the map and what you do with it in your program. If you move LOW-VALUES to the map before sending it, you should get back the length of just the characters input in the field. If you move SPACES to the map before sending it, you'll get back the length of the field since spaces would count as characters. Also, if an attention identifier is used then you may not get data in any field. You'll also need to consider the MDT (modified data tag) since fields without the MDT set will not have their data transmitted. You may want to use COPY DFHBMSCA in your code to bring in the BMS attributes known to CICS.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post