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
 

 

Program logic to validate invalid fields
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Fri Aug 19, 2005 4:23 pm    Post subject: Program logic to validate invalid fields
Reply with quote

Dear Firends

Quote:

I have 17 fields to validate and with the conditioin that if any one of them is found to be invalid then no need for further processing.How could i implement the logic.


Thanks and regards
Chandra
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Aug 19, 2005 4:29 pm    Post subject: Re: program logic
Reply with quote

Hi Chandra,

Quote:
I have 17 fields to validate and with the conditioin that if any one of them is found to be invalid then no need for further processing.How could i implement the logic.

I assume you are talking about a COBOL prog....

What do you mean by VALID & INVALID here....Is there any specific format or range of values you are concerned about....

Better if you can show some examples...

Regards,

Priyesh.
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Fri Aug 19, 2005 7:00 pm    Post subject: Re: program logic
Reply with quote

Quote:
Validate each field as specified below. If an invalid field is identified set #-ERROR-MSG to the error message text as shown below against each validation. Once an invalid condition has been identified, no further validation is required.
ex. #-MRGR-CTRL-ENTY - Must be populated
(Error message: ?Control Entity not present?)
Like this more fields are there which test diff condition.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Aug 19, 2005 7:13 pm    Post subject: Re: program logic
Reply with quote

Hi Chandra,

What I understand as of now...There are 17 fields in your Input File to the program... You want to check each & every firld based on some validity conditions.

If any of the 17 fields failed in your validity check...you want to flash some error message & Stop processing.

Now... It is still not clear what is the definition of VALID or INVALID here for your fields....

correct me if you find this assumption not suited on your requirements.

Regards,

Priyesh.
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Fri Aug 19, 2005 7:18 pm    Post subject:
Reply with quote

Lets take an example: Suppose the field contain no value

Thanks
Chandra
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Aug 19, 2005 7:26 pm    Post subject: Re: program logic
Reply with quote

Quote:
Suppose the field contain no value


we assume checking for field starting from column# 11 to 20

READ your Input file in the INPUT RECORD STRUCTURE

Code:
READ INPUT-FILE INTO INPUT-REC
AT END                         
    SET INPUT-FILE-END-YES TO TRUE.

IF INPUT-REC(11:10) = NULL
DISPLAY 'ERROR MESSAGE'
PERFORM 'WHAT EVER YOU WANT TO DO'.


you can implement logic to check for each field like this.

Any thing which is required to be more explained...Please get back.

Regards,

Priyesh.
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Fri Aug 19, 2005 7:35 pm    Post subject:
Reply with quote

Thanks priyesh
But i want to to make you more clear


The input rec is in CSV format.First i have to untrsing it in into different variable and then validate.Also i have to take care of the condition that after any one of the field is found to be invalid then i have to skip the furthut processing.
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 436
Location: chennai, India

PostPosted: Fri Aug 19, 2005 7:48 pm    Post subject:
Reply with quote

Assuming that you have 17 conditions.
After satisfying all the 17 conditions you need to perform an action.

If it is so you can use the logical operator AND to perform such conditional operation.

reply back if the assumption is not correct.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Fri Aug 19, 2005 8:03 pm    Post subject: Re: program logic
Reply with quote

Quote:
The input rec is in CSV format.First i have to untrsing it in into different variable and then validate.Also i have to take care of the condition that after any one of the field is found to be invalid then i have to skip the furthut processing.


Now AIR seems more clear....Well, another query ...Are you having comma in a fixed position...that will help you determining length of the string.

Code:
UNSTRING INPUT-STRING DELIMITED BY ','
INTO STRING-1, STRING-2....STRING-17


Then as per radhakrishna said, you can give an IF cond with AND operators to check for all the 17 fields. & if cond satisfied PERFORM ACTION else STOP RUN.

If you want to display some error message for the perticular INVALID Field ..In that case IF Cond with AND wont work....NESTED IF will do in this case....

Put your thoughts now.....

Regards,

priyesh.
Back to top
View user's profile Send private message
bonniem

New User


Joined: 09 Aug 2005
Posts: 67

PostPosted: Sat Aug 20, 2005 11:17 am    Post subject:
Reply with quote

Hi,

See if this helps

Code:

PERFORM 1000-PARA VARYING WS-SUB FROM 1 BY 1
     UNTIL WS-SUB > 17 OR WS-INVALID-DATA
          EVALUATE WS-SUB
                 WHEN 1
                           PERFORM 1001-VALIDATE-FIELD-1
                 WHEN 2
                           PERFORM 1002-VALIDATE-FIELD-2
                  .
                  .
                  .

                 WHEN 17
                           PERFORM 1017-VALIDATE-FIELD-17
         END-EVALUATE
END-PERFORM

1001-VALIDATE-FIELD-1

IF FIELD-1 IS VALID <Check all the validity conditions>
    CONTINUE
ELSE
    SET WS-INVALID-DATA TO TRUE
    DISPLAY <Message for field1>
END-IF

.
.
.

Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 436
Location: chennai, India

PostPosted: Sat Aug 20, 2005 11:57 am    Post subject:
Reply with quote

chandra,
If you are validating depending upon a variable (may be from a file) then the above said EVALUATE condtion can be used.

pls do get back...
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Sat Aug 20, 2005 5:26 pm    Post subject:
Reply with quote

Thanks bonniem
But still i have aproblem.for this i have to code 17 section and this is one out of six condition for which i have to code.if i code like this then including this i have to code more then 100 section as some have more then 25 condintions.

Hence the no section goes up to more then 100.

Then suggest me to go ahed with this or is there any other way ?
Back to top
View user's profile Send private message
bonniem

New User


Joined: 09 Aug 2005
Posts: 67

PostPosted: Sat Aug 20, 2005 6:23 pm    Post subject:
Reply with quote

Quote:
as some have more then 25 condintions.


1) Is it like for one field you have 25 validations? Then you could do all those in one paragraph, no need for separate paragraphs for it.

2) Then one suggestion to reduce number of paragraphs is to group together fields which have same validations. For example if field1 and field2 is having same validation, you could use the same paragraph for both.

Could you elaborate on
Quote:
this is one out of six condition for which i have to code

Quote:
some have more then 25 condintions
.

We might be able to help you better if we have a clear idea of your requirement.

And also I dont think 100 paragraphs is a big number if it is coded in a readable manner.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 236
Location: Cincinnati OH USA

PostPosted: Sat Aug 20, 2005 11:52 pm    Post subject:
Reply with quote

Just an observation, but it makes no sense to stop validation of other fields in the real world unless subsequent fields valid values are indeterminate if a prior field is invalid.

Someone responsible for correcting such data would certainly want to be able to fix all the errors at one time. This is true of batch and online.

This sounds like a classroom exercise.


Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Aug 21, 2005 2:12 am    Post subject:
Reply with quote

I agrre w/Dave. However, CSV files are a lot trickier than the comma (,) may indicate.

Suppose the field contains a comma. Well, the field is usually enclosed in quotes (").

Suppose the field also contains quotes. Well, that quote is becomes a double quote ("").

And it goes on...
Back to top
View user's profile Send private message
bonniem

New User


Joined: 09 Aug 2005
Posts: 67

PostPosted: Sun Aug 21, 2005 10:36 am    Post subject:
Reply with quote

I disagree to this statement.

Quote:
it makes no sense to stop validation of other fields in the real world unless subsequent fields valid values are indeterminate if a prior field is invalid


It is not true in all cases. It is always better to correct errors and proceed rather than validating all fields all the time. For example in an application you are entering country code and zip code to get all the stores in that region. If you are entering an invalid country code how will you validate the zip code?

also
Quote:
This sounds like a classroom exercise.


I thought this site was for everyone to clear their doubts.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 236
Location: Cincinnati OH USA

PostPosted: Sun Aug 21, 2005 7:14 pm    Post subject:
Reply with quote

Quote:
disagree to this statement.

Quote:
it makes no sense to stop validation of other fields in the real world unless subsequent fields valid values are indeterminate if a prior field is invalid


It is not true in all cases. It is always better to correct errors and proceed rather than validating all fields all the time. For example in an application you are entering country code and zip code to get all the stores in that region. If you are entering an invalid country code how will you validate the zip code?


bonniem, it appears that you actually agree as the example you give fits quite well with 'unless subsequent fields valid values are indeterminate if a prior field is invalid'


Reagarding ' classroom exercise': I have no problem with academic questions if stated as such as they can be answered given the implicit limited scope of the question without consideration of the myriad of possibilities. Real world requires much additional info in this case as validation means 'within a range of values', 'within a list of values', 'a certain datatype', 'exists in a dataset', etc. In this case the specifics were omitted and people are guessing as to how respond.


Dave
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Mon Aug 22, 2005 9:40 am    Post subject:
Reply with quote

Hi Dave
I don't Mind how you take this question as an class room exercise or real world problem.
In my case if i found any one of the field invalid then i set a error-message field ,set the error type to a specific value .This indicate invalid record.
May be it happened that i am unable to express my problem clearly so that you feel it as class rom exercise.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Aug 22, 2005 11:12 am    Post subject: Re: program logic
Reply with quote

Hi Learnmf,

If your all fields (in the 17) having a different structure or Validity Check Logic..... Then Is there any other choice coding different section.

If the fields in between having some similar kind of check like "Checking NULL" or "Checking SPACES" ....a separate PARA can be coded & called at the time of each concerned field.

The prob is more or less a circuit of IF-THEN logic, question is to minimise the coding part or optimizing code.

So make it more clear in terms of validation logic & Data format. May be any of us can help you better.

Regards,

Priyesh.
Back to top
View user's profile Send private message
senti

New User


Joined: 18 Aug 2005
Posts: 19

PostPosted: Mon Aug 22, 2005 11:43 am    Post subject: Re: program logic
Reply with quote

Hi learnmf,

I think, Maybe using GO TO will help the code look cleaner.

Have a separate section to check the validity of all 17 fields.

A100-check-validity.

IF Filed-1 = 'X'
display ' X'
ELSE
GO TO A100-exit.

............................

IF Filed-16 = 'Z'
display ' Z'
ELSE
GO TO A100-exit.


A100-exit. Exit.


Though we can always do away with GOTOs, i think in cases like this it will be helpful as it makes the code look more neater & simpler compared to clumpsy IF-ELSE loops.

Any comments folks..? icon_question.gif

Regds, Senti
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts Need points to tune IMS Checkpoint Pr... satish.ms10 IMS DB/DC 2 Fri Sep 30, 2016 4:12 pm
No new posts ISPF program to set SCRNAME prino TSO/ISPF 5 Fri Sep 30, 2016 2:18 pm


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