Numeric field accepting characters in cics map

2019-09-02 01:17发布

I have 4 fields in my map which are 9(6),9(3),9(3),9(3). I wrote validation code like this:

IF ROLLNUM IS NOT NUMERIC                          
MOVE DFHRED TO ROLLNUMC                         
MOVE 'INVALID DATA' TO RESMSGO                  
MOVE ROLLNUMI TO ROLLNUMO                       
PERFORM SEND-MAP THRU SEND-MAP-EXIT             
PERFORM KEY-VALIDATION THRU KEY-VALIDATION-EXIT.

But I am not getting any kind of error while inserting the values like A12AK into the database from cics. It is replacing A with 1, B with 2, and so on... Why is this happening? And how to avoid this

标签: db2 cobol cics
3条回答
仙女界的扛把子
2楼-- · 2019-09-02 02:06

Add ATTRB=(UNPROT,NUM,FSET,IC) to the DFHMDF fields of the BMS mapset for the numeric fields.

You'll also need JUSTIFY=(RIGHT,ZERO).

查看更多
别忘想泡老子
3楼-- · 2019-09-02 02:21

CICS also offers the BIF DEEDIT option.

查看更多
Explosion°爆炸
4楼-- · 2019-09-02 02:22

Gilbert is giving you good advice on fixing your CICS map. Take it!

Let me try to explain the "strange" values...

When a character (PIC X) is placed in a PIC 9 data item the upper 4 bits of the byte representing the character value are overwitten with 'F'x. The lower 4 bits are left as-is.

At this point it might be useful to look at an EBCDIC character chart

Notice that the hex representation of an 'A' is 'C1'x and 1 is 'F1'x. When an 'A' is moved to a PIC 9 field it becomes a 1 (the upper 4 bits, 'C'x, are replaced with 'F'x, the lower 4 bits are left as-is). Similar type of thing for all letters of the alphabet. Notice that the EBCDIC character sequence for 'A' through 'Z' is not contiguous (there are gaps when the lower 4 bits roll into the 'A'x - 'F'x range). This is why you will always get a 'valid' digit when moving a letter from an 'X' type to a '9' type field.

The result is a valid numeric value after a move from an 'X' to '9' type data item when only digits, letters and SPACE are involved. This will then pass an IF NUMERIC test.

The root of your problem is that your CICS map allows for non numeric data entry, when that value is transferred to your working storage item defined as PIC 9 it is converted as described above. Not what you want! As Gilbert pointed out, if you define the CICS map field as 'NUM' the only valid characters the user can enter are digits, which solves your problem.

Finally, notice that some non alpha characters, such as '@' will not coherse into a valid digit.

查看更多
登录 后发表回答