Homemade versioner

Hi guys.

I’m currently working on a project where the guys like to maintain some manual versions of the modules. I created this program and I’d appreciate if you guys could take a look and see if there’s a more automatic way to make it happen.

here we use the following pattern:

CIP77512

CI - stands for the system. CI, CP, KP, SE, SZ, etc.
P/N/S/M/H/L/A/G - stands for the SET TYPE module.
12345 - free zone, following each system menu standards.

What the guys here do to
They download the program from the production environment to the development environment using the company archaic system. It basically copies the source code between the environments.

Once the program is in the dev library (here there is no personal library), they remove the system from the program name and add a counter from 01 to 99 in the end, to know which version was changed. In the above example, would be P77512##
The task is:

  1. LIST P77512*
  2. look in the list for the last version
  3. rename CIP77512 P77512## → this is so they wont lose the CAT date track
  4. edit P77512##
  5. save CIP77512

Since I get really bored with useless work, I decided to make a program to do it automatically since you pass only the program name as parameter to the input data.
Below is the code:


DEFINE DATA LOCAL                              
1 #PGM1  (A8)                                  
1 #NUM   (N2)                                  
1 #PGM   (A6)                                  
1 REDEFINE #PGM                                
  2 #BYTE1 (A1)                                
  2 #BYTE5 (A5)                                
1 #PGMX  (A8)                                  
1 #OP (A1)                                     
END-DEFINE                                     
*                                              
REPEAT                                         
  INPUT '******************************'       
    / '1 - LIST VERSIONS'                     
    / '2 - CREATE VERSION'                   
    / 'X - EXIT'                               
    / '******************************'         
    / 'SELECT OPTION:' #OP                    
  IF *PF-KEY EQ 'PF3'                          
    STOP                                       
  END-IF                                             
  DECIDE ON FIRST VALUE OF #OP                       
    VALUE 'X' , '.' STOP                             
    VALUE '1' PERFORM LIST-VERSIONS                  
    VALUE '2' PERFORM CREATE-VERSION                       
    NONE VALUE REINPUT 'NOTHING TO SEE HERE! KEEP WALKING'      
  END-DECIDE                                         
END-REPEAT                                           
DEFINE LIST-VERSIONS                                 
********************                                 
INPUT 'MODULO:'#PGM1                                 
MOVE SUBSTRING (#PGM1,3,6) TO #PGM                   
IF #BYTE1 EQ '4'                                     
  #BYTE1 := 'M'                                      
END-IF                                               
WRITE '=' #PGM                                       
COMPRESS #PGM '*' INTO #PGMX LEAVE NO SPACE          
STACK TOP COMMAND 'RUN' *PROGRAM                     
STACK TOP COMMAND 'LIST' #PGMX                       
STOP                                                 
*                                                                  
END-SUBROUTINE                                                     
***************                                                    
DEFINE CREATE-VERSION                                                    
***************                                                    
INPUT 'PROGRAMA:'#PGM1 'SEQUENCIA:'#NUM                            
  / '*************************************************************'
  / 'ONCE EDIT APPEARS, YOU MUST HIT PF3 TO QUIT. THIS IS THE BACKUP VERSION.'
  / '*************************************************************'
*                                                                  
IF #PGM1 EQ ' ' REINPUT 'MISSING PROGRAM ' MARK *#PGM1 END-IF       
IF #NUM  EQ  0  REINPUT 'MISSING SEQUENCE' MARK *#NUM  END-IF       
MOVE SUBSTRING (#PGM1,3,6) TO #PGM                                 
IF #BYTE1 EQ '4'                                                   
  #BYTE1 := 'M'                                                    
END-IF                                                             
COMPRESS FULL #PGM #NUM INTO #PGMX LEAVE NO SPACE                  
WRITE '=' #PGMX                                                    
STACK TOP COMMAND 'EDIT' #PGM1                                     
STACK TOP COMMAND 'SAVE' #PGM1                                          
STACK TOP COMMAND 'EDIT' #PGMX                                          
STACK TOP COMMAND 'RENAME' #PGM1 #PGMX                                  
STOP                                                                    
END-SUBROUTINE                                                          
END                                                                     

What is killing me, is that I tried to capture the data from the list command, but couldn’t find a way to do it.
I tried to to force a rename into a program that already exists and set ON ERROR to try to loop into 0082 until I find a valid sequence. No success either.

If you guys have any way to improve this, you are welcome :slight_smile:

Now I’m working on a version that stores the new entries into a database, so if this particular module is changed again, it will be automatic, but if I can do it without storing data, would be much better, because our development databases sometimes gets ‘accidentaly’ erased.