Summary -

In this topic, we described about the below sections -

Fixed insertion editing inserts the symbols at the beginning or end of the item. Fixed insertion editing is valid only for numeric-edited items. The length of the edited PICTURE clause may not be same as source PICTURE clause. The symbols used in fixed insertion editing are minus (-), plus (+), credit (CR),Debit (DB) and dollar ($).

In fixed insertion editing, only one currency symbol (cs) and one editing-sign control symbol (+ - CR DB) can be specified in a PICTURE character-string. The fixed insertion symbols are counted in the size of the item.

Plus and minus symbols -

These symbols must appear in the leftmost or rightmost character positions. They must be the first or last character in the PICTURE string.

Minus (-) -

If the value is negative, a minus sign is printed. If the value is positive, a space is printed instead. Used to highlight negative values only.

Plus (+) -

If the value is negative, a minus is printed. If the value is positive, a plus is inserted. Used to highlight the sign of the value.

CR and DB -

When CR or DB is used as a symbol, it must define as the rightmost two-character positions in the character-string. They only appear in the rightmost position. Both characters (CR or DB) are printed only if the item is negative. Otherwise two spaces are printed.

The currency symbol ($) -

The currency symbol must be the leftmost character.It may be preceded by a plus or a minus sign.

Practical Example -

Scenario - Below example describes how the fixed insertion editing used in COBOL programming.

Code -

Fixed Insertion Editing Program Code
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. FIXINEDT.                                            
       AUTHOR. MTH.                                                     
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
       01 WS-VARS.                                                      
          05 WS-VAR          PIC S9(5).                                 
          05 WS-FIE-VAR1     PIC -9(5).                                 
          05 WS-FIE-VAR2     PIC +9(5).                                 
          05 WS-FIE-VAR3     PIC 9(5)-.                                 
          05 WS-FIE-VAR4     PIC 9(5)+.                                 
          05 WS-FIE-VAR5     PIC -9(5).                                 
          05 WS-FIE-VAR6     PIC 9(5)CR.                                
          05 WS-FIE-VAR7     PIC 9(5)CR.                                
          05 WS-FIE-VAR8     PIC 9(5)DB.                                
          05 WS-FIE-VAR9     PIC 9(5)DB.                                
          05 WS-FIE-VAR10    PIC $9(5).                                 
          05 WS-FIE-VAR11    PIC $ZZZZZ.                                
          05 WS-FIE-VAR12    PIC $ZZZZ9.                                
       PROCEDURE DIVISION.                                              
           MOVE -247         TO  WS-VAR                                 
           MOVE +1047        TO  WS-FIE-VAR5                            
           MOVE -1147        TO  WS-FIE-VAR7                            
           MOVE  1547        TO  WS-FIE-VAR10.                          
           MOVE  ZEROES      TO  WS-FIE-VAR11                           
           DISPLAY "WS-VAR:          " WS-VAR.                          
           DISPLAY "WS-FIE-VAR1:     " WS-FIE-VAR1.                     
           DISPLAY "WS-FIE-VAR2:     " WS-FIE-VAR2.                     
           DISPLAY "WS-FIE-VAR3:     " WS-FIE-VAR3.                     
           DISPLAY "WS-FIE-VAR4:     " WS-FIE-VAR4.                     
           DISPLAY "WS-FIE-VAR5:     " WS-FIE-VAR5.                     
           DISPLAY "WS-FIE-VAR6:     " WS-FIE-VAR6.                     
           DISPLAY "WS-FIE-VAR7:     " WS-FIE-VAR7.                     
           DISPLAY "WS-FIE-VAR8:     " WS-FIE-VAR8.                     
           DISPLAY "WS-FIE-VAR9:     " WS-FIE-VAR9.                     
           DISPLAY "WS-FIE-VAR10:    " WS-FIE-VAR10.                    
           DISPLAY "WS-FIE-VAR11:    " WS-FIE-VAR11.                    
           DISPLAY "WS-FIE-VAR12:    " WS-FIE-VAR12.                    
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Fixed Insertion Editing Program Output