View previous topic :: View next topic
|
Author |
Message |
santoshkumarmanilakkoju
New User
Joined: 24 Nov 2009 Posts: 37 Location: Don't know
|
|
|
|
Hi, I have requirement to populate a Error messae when user enters data on CICS Screen. Filed is defined as Alphanumeric and length of 3 bytes.
Conditions-
1) User cannot enter Special charaters;
2) User can enter data which is not case sensitive;
3) User cannot enter few specific codes;
Code: |
IF FIELD-L = 0
IF FIELD-A = EOF-KEY
NEXT SENTENCE
END-IF
ELSE
IF FIELD-L > 0
IF FIELD = 'CCL' OR 'NET' OR
'ACC' OR 'OIU' OR 'PIE' OR 'OTH'
MOVE 'A' TO LS-ERROR-TYPE
MOVE 'A' TO FIELD-A
MOVE -1 TO FIELD-L
ELSE
MOVE FIELD
TO FIELD2
MOVE 'Y' TO TRAILER-X
MOVE 'A' TO FIELD-A
END-IF
ELSE
NEXT SENTENCE
END-IF
END-IF. |
Is there a way to handle Special characters in the ELSE part? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This is an excellent example for implementation of the EVALUATE Statement.
Do that and your problem is solved. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes.
Firstly, don't use NEXT SENTENCE. Replace with CONTINUE. This won't help with your requirement, but will help if someone ever removes the fullstop/period on your final END-IF. This also applies to any IF you or anyone at your site or anyone anywhere has ever coded.
Since the advent of Cobol II, around about the end of the Cretaceous Period, NEXT SENTENCE is nothing but "an accident waiting to happen". Not bothering with fullstops/periods at all except to precede a procedure-name, END-PROGRAM, end of the program and to end the PROCEDURE DIVISION statement might take longer to sink in, but it'll only help in the "long run" (I mean for coding future, not for execution times of steps).
Why don't you use an 88 on FIELDD? Can be made a descriptive name and makes the code much tidier and easier to maintain (as it has a name).
Why is FIELDD, and for that matter FIELDD2, called that? Can't it be something more descriptive? Helps to understand/maintain the program and reduces stupid coding errors.
To your requirement, how about telling is what is "valid" in the field, rather than that you want to reject something called "special characters" which only means whatever any person says at any given time? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
silly of me to preach without practicing:
Code: |
EVALUATE TRUE
WHEN FIELD-L < 1
PERFORM NO-DATA-ROUTINE
WHEN FIELD-IS-A-K-L-R-S-Z-0-9
CONTINUE
(As Bill says, make these 88's = 'CCL' OR 'NET' OR 'ACC' OR 'OIU' OR 'PIE' OR 'OTH'
WHEN FIELD-IS-CLASS1
MOVE 'A' TO LS-ERROR-TYPE
MOVE 'A' TO FIELD-A
MOVE -1 TO FIELD-L
WHEN ......
END-EVALUATE
|
2 WHEN's (compares) and acceptable data is moving on in the program.
the remaining WHEN's isolate individual error conditions. |
|
Back to top |
|
|
|