© 2012 Mainframestechhelp.com
Mainframes Tech Help
Help for all Mainframe technical needs
Its our planet.. Go Green
For any Queries/Suggestions/Issues, Send a mail to Support@mainframestechhelp.com
Next
COBOL Tutorial Conti...
Data type JUSTIFICATIONS: Justification only applies to Numeric, Alphabetic and Alpha-numeric among the 5 data types. Numeric data type is right justified. Alphabet & alphanumeric data types are left justified. Numeric Examples:    Case 1)  Input is larger than the output variable. 01 S PIC 9(3) MOVE 12345 TO S DISPLAY S.      ==> Output is:   345. Input: Output: 1 2 3 4 5 3 4 5 Last three bytes of data will be moved to output because of the right Justification Case 2)  Input is smaller than the output variable. 01 S PIC 9(7). MOVE 12345 TO S DISPLAY S.      ==> Output is:  0012345. Input: Output: 1 2 3 4 5 0 0 1 2 3 4 5 Five bytes of data will be moved to the output from the right side because of the right justified. Remaining two bytes will be filled with zeroes if the output variable is properly initialized. Alpha-Numeric/Alphabetic Examples: Case 1)  Input is larger than the Output variable 01 S PIC X(4) MOVE ‘MAINFRAMES’ to S. DISPLAY S.   ==> Output is:   MAIN Input: Output: M A I N F R A M E S M A I N First four characters will be moved to the output because of the left justification. Case 2) Input is smaller than the output variable. 01 S PIC X(12) MOVE ‘MAINFRAMES’ to S DISPLAY S.     ==> Output is:   MAINFRAMES  Input:    Output: M A I N F R A M E S    M A I N F R A M E S Total input is moved to the output variable starting from the left because of the left justification and the last two bytes of the output variable left as blank/un used.
If any questions on the above, post your queries on Cobol Discussion forum
Previous Home Forums Tutorials Tools About Us Contact us Login Interview questions