Search

Sunday, March 3, 2013

Efficient use of decalartion in COBOL


Efficiently use of alphanumeric and numeric declaration in COBOL


In Working Section:

03  WS-ALPHX.                          
    05  WS-NUM          PIC 9(4).     

We can use this way as alphanumeric as well as to check numeric.

For Eg:

MOVE CAPIN(1:4)      TO WS-ALPHAX

IF WS-ALPHAX (1:1) IS NOT NUMERIC       
   MOVE 0 TO WS-ALPHAX (1:1)
END-IF      
                                  
IF WS-NUM IS NUMERIC                  
   MOVE WS-NUM TO CAPIN2
ELSE                                          
   MOVE 0              TO CAPIN2
END-IF                        

No comments:

Post a Comment