'Is there a way to edit RPGLE program from CL command without opening RPGLE program?

I have a RPGLE program as below which has tags AD11 for date 220318 , but for other dates like 220317 and 220323 there are no tags. Is there any CL command that can insert AD11 tag for other two dates ? Or is there any program that can be written to insert tags if there is no tag present in position 1 to 4, based on the dates fed as input parameter?

Program showing tags AD11 for 220318

enter image description here

Any suggestions/guidance is appreciated.



Solution 1:[1]

CL can't do this specifically but what you could do is embed SQL within CL or just run SQL directly via "STRSQL".

n.b. SQL has no concept of members so if the file containing your RPGLE source member has multiple members you'll need to override to that member before running your script.

An example CL program would look like this;

             PGM                                                             
                                                                         
             /* Override file name "QRPGLESRC" to "MYLIB/QRPGLESRC.SRCMBR" */
             OVRDBF     FILE(QRPGLESRC) TOFILE(MYLIB/QRPGLESRC) +          
                          MBR(SRCMBR) OVRSCOPE(*JOB)                       
                                                                         
             /* Update "MYLIB/QRPGLESRC.SRCMBR" */                           
             RUNSQL     SQL('UPDATE QRPGLESRC +                              
                                SET SRCDTA = ''AD11'' || SUBSTR(SRCDTA,5) +  
                              WHERE SRCDAT = 220408') +                      
                        COMMIT(*NONE)                                        
                                                                         
             /* Remove previous override */                                  
             DLTOVR     FILE(QRPGLESRC) LVL(*JOB)                            
                                                                         
             ENDPGM                                                                

Solution 2:[2]

Since source members are stored in files, you can create a HLL (RPG or COBOL) program to modify the data in the source member.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 David G