View previous topic :: View next topic
|
Author |
Message |
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
Please look at my query and guide me in this.
I have variable A of declaration A PIC X(12) and other variable B as
B PIC 9(9)v99.
I am receiving value in A from user using CICS screen which is alphanumeric and need to convert it into Numeric and stored into B.
For this I used NUMVAL function as COMPUTE B = FUNCTION NUMVAL (A).
Now, What’s the problem is , if user is going to enter some value in A without clearing the previous value of A on CICS screen then the value in A will be like this [....14....20] and if I perform NUMVAL function it ABENDS with ABEND code AB U4038, since NUMVAL function not accept it.
Now I have to handle this error, If this case occurs I have to make B = ZERO.
Will anybody please guide me how to handle this error, OR is there any other way so that I can Identify whether user is entered single value(cleared previous one and entering only numeric value).
Also I have to handle if User enters value like 12C, i.e. combination of numbers and Alphabets (ALPHANUMERIC).
Please help me in this scenario, if anybody wants some more clarification regarding my problem please let me know.
Thanks in advance,
Yogesh |
|
Back to top |
|
|
Help-Me-Out
New User
Joined: 09 Dec 2006 Posts: 56 Location: Pune
|
|
|
|
y don't u clear the field as soon as you porcess the NUMVAL function. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
1.) What Help-Me-Out recommended
2.) Check that field by using INSPECT for blanks or whatever.
3.) Make it compatible by own code to the use of the numval-function.
Regards, UmeySan |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Usually at any reasonably established IT development site
there are general use subroutines/functions/call_them_anything_you_want
to carry on various data checking..
for numerics, for a date, pattern driven , application dependent, ...
check with application development support if there are such things available |
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
Thanks all for your reply...
I got some solution for it. I used INSPECT,REFERENCE MODIFICATION and UNSTRING for this purpose.
The test program is shown Below , Please let me know whether this is correct way or not. Also if you have any other solution please post the same.
*************************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. CLASS VALID-DATA '0' THRU '9'
' '
'.'.
**** I used this for checking whther ALphabets/Symbols are present in A.
INPUT-OUTPUT SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC X(12).
01 B PIC 9(9)V99.
01 C PIC X(12).
01 D PIC X(12).
01 E PIC X(12).
01 F PIC ZZZZZZZZZ.99.
01 CHARCOUNT PIC 99 VALUE 00.
PROCEDURE DIVISION.
MOVE ' 3523A 18.9' TO A.
IF A IS VALID-DATA
***Checking for Alphabets/Symbols
NEXT SENTENCE
ELSE
DISPLAY 'NOT VALID DATA '
GO TO EXIT-PARA.
INSPECT A TALLYING CHARCOUNT FOR LEADING SPACES
MOVE A(CHARCOUNT + 1:12 - CHARCOUNT) TO C.
**** Removing Leading Spaces in A
DISPLAY 'ORIGINAL VALUE OF A -> ' A.
DISPLAY SPACES.
DISPLAY 'NO. OF LEADING SPACES PRESENT - > ' CHARCOUNT.
DISPLAY SPACES.
IF CHARCOUNT = 12
DISPLAY 'NOT VALID DATA '
GO TO EXIT-PARA
ELSE NEXT SENTENCE.
**** Checking if A is Blank
DISPLAY 'AFTER REMOVING LEADING SPACES OF A -> ' C.
DISPLAY SPACES.
MOVE 0 TO CHARCOUNT.
UNSTRING C DELIMITED BY SPACES INTO D COUNT IN CHARCOUNT
END-UNSTRING.
*** Seprating two values entered in A using UNSTRING and Reference *** Modification
DISPLAY 'COUNTER ' CHARCOUNT.
DISPLAY SPACES.
IF C NOT = D
MOVE C(CHARCOUNT + 1: ) TO E
DISPLAY 'ERROR -> USER ENTERED TWO VALUES '
DISPLAY SPACES
GO TO EXIT-PARA
ELSE
NEXT SENTENCE.
*** Checking whether User entered two values in A
MOVE D TO E.
DISPLAY 'SINGLE VALUE ENTERED '
DISPLAY SPACES
COMPUTE B = FUNCTION NUMVAL(D).
**** Alphanumeric to Numeric Conversion
DISPLAY 'CONVERTED INTO NUMERIC -> ' B.
DISPLAY SPACES.
COMPUTE F = 1.2 + B.
DISPLAY ' AFTER ADDITION OF 1.2 - >' F.
EXIT-PARA.
EXIT.
DISPLAY SPACES.
INSPECT D REPLACING ALL SPACES BY 'B'.
INSPECT E REPLACING ALL SPACES BY 'B'.
DISPLAY 'D ' D.
DISPLAY SPACES.
DISPLAY 'E ' E.
STOP RUN.
*************************************************************
o/p
***************************************************************** IF A IS ' 3523A 18.9'
*************************************************************
NOT VALID DATA
D ............
E ............
***************************************************************** IF A IS ' 23.45 18.9'
*************************************************************
ORIGINAL VALUE OF A -> 23.45 18.9
NO. OF LEADING SPACES PRESENT - > 01
AFTER REMOVING LEADING SPACES OF A -> 23.45 18.9
COUNTER 05
ERROR -> USER ENTERED TWO VALUES
D 23.45BBBBBBB
E BB18.9BBBBBB
***************************************************************** IF A IS ' 23 '
*************************************************************
ORIGINAL VALUE OF A -> 23
NO. OF LEADING SPACES PRESENT - > 01
AFTER REMOVING LEADING SPACES OF A -> 23
COUNTER 02
SINGLE VALUE ENTERED
CONVERTED INTO NUMERIC -> 00000002300
AFTER ADDITION OF 1.2 - > 24.20
D 23BBBBBBBBBB
E 23BBBBBBBBBB
*************************************************************
If you have any comments please let me know. |
|
Back to top |
|
|
|