Summary -

In this topic, we described about the Simple Insertion Editing with detailed example.

Simple insertion editing is inserting a character(s) in the PICTURE string. Simple insertion editing doesn't affect the PICTURE clause value and just changes the display of the data.

When a value is moved into the edited item, the insertion characters are inserted into the item at the specified position in the PICTURE. The comma (,), the blank (B), the zero (0) and the slash (/) are the simple insertion editing symbols.

Simple insertion editing item length counted as number of characters displayed or printed which includes editing characters. Each insertion symbol represents the position within the item where the equivalent character is to be inserted.

The comma (,) symbol -

  • The comma symbol (,) specifies the computer to insert a comma at the symbol ',' specified.
  • The comma symbol counts as the size of the displayed or printed item. The comma symbol cannot be the first character in the PICTURE string.

The space or blank (B) symbol -

  • A space is inserted at the position where the symbol 'B' specified in the PICTURE clause.

The slash(/) and zero(0) symbols -

  • A slash is inserted at the position where the symbol '/' specified in the PICTURE clause.
  • A zero is inserted at the position where the symbol '0' specified in the PICTURE clause.
Note! The length of the edited PICTURE clause may or may not be same as source PICTURE clause.

Practical Example -

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

Code -

Simple Insertion Editing Program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. SIMINEDT.                                            
       AUTHOR. MTH.                                                     
                                                                        
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
                                                                        
       01 WS-VARS.                                                      
          05 WS-VAR          PIC 9(7).                                  
          05 WS-SIE-VAR1     PIC 9,999,999.                             
          05 WS-SIE-VAR2     PIC 9,9(3),9(3).                           
          05 WS-SIE-VAR3     PIC Z,ZZZ,ZZZ.                             
          05 WS-SIE-VAR4     PIC *,***,***.                             
          05 WS-SIE-VAR5     PIC 9900990099.                            
          05 WS-SIE-DATE1    PIC 99B99B9999.                            
          05 WS-SIE-DATE2    PIC 99/99/9999.                            
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
           MOVE 001234       TO  WS-VAR                                 
                                 WS-SIE-VAR1                            
                                 WS-SIE-VAR2                            
                                 WS-SIE-VAR3                            
                                 WS-SIE-VAR4                            
                                 WS-SIE-VAR5.                           
                                                                        
           MOVE 07072021     TO  WS-SIE-DATE1                           
                                 WS-SIE-DATE2.                          
                                                                        
           DISPLAY "WS-VAR:          " WS-VAR.                          
           DISPLAY "WS-SIE-VAR1:     " WS-SIE-VAR1.                     
           DISPLAY "WS-SIE-VAR2:     " WS-SIE-VAR2.                     
           DISPLAY "WS-SIE-VAR3:     " WS-SIE-VAR3.                     
           DISPLAY "WS-SIE-VAR4:     " WS-SIE-VAR4.                     
           DISPLAY "WS-SIE-VAR5:     " WS-SIE-VAR5.                     
                                                                        
           DISPLAY "WS-SIE-DATE1:    " WS-SIE-DATE1.                    
           DISPLAY "WS-SIE-DATE2:    " WS-SIE-DATE2.                    
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Simple Insertion Editing Program Output