2

I am looking at an RPG program. there are some subroutines like this: are there any tools which would create this as a procedure, that could be used in separate process?

C                   Eval      FinQty# = 0                           
C                   Eval      OdCom# = OhCom#                       
C                   Eval      OdOrd# = OhOrd#                       
C     OdKey         Setll     OeOrd1                                
C     OdKey         Reade     OeOrd1                                
C                   Dow       %eof = *off                           
 *                                                                  
C                   If        OdPrt# = OdAls# and                   
c                             %subst(odprt#:1:3) <> 'FRT'           
C                   Eval      FinQty# += OdQty#                     
C                   Endif                                           
 *                                                                  
C     OdKey         Reade     OeOrd1                                
C                   Enddo                                           
 *                                                      
Buck Calabro
  • 7,558
  • 22
  • 25
Adams
  • 195
  • 1
  • 10
  • Asking for a tool is off-topic, although I'm not aware of any off hand. Deconstructing a complete chain from an RPG program would be problematic - what happens when things like table partition aren't known until runtime?. For something like this I'd probably start with a view in SQL. Do you mean an RPG Procedure, or an SQL Stored Procedure? Or a service program? You're probably going to have more luck defining the _intent_ of the original code, and recreating based on that. – Clockwork-Muse Jun 19 '14 at 12:34
  • I've seen that "asking for a tool is off-topic" thrown out before; And I considered it before replying. As far as I can tell the real prohibition is on the subjective "which tool is best". Given the size of the RPG community here and the fact the tools in question are apparently not as well know or as easy to find as they should be. I felt an answer was acceptable. – Charles Jun 19 '14 at 12:43
  • Asking **for** a tool is off-topic, while asking about a problem encountered while using tool is probably on-topic. But the example code doesn't look like something that converts well to a procedure as is. It looks as if it'd be better to replace it with a single SQL SELECT SUM() WHERE... statement and put that into a procedure. – user2338816 Jun 21 '14 at 02:02

2 Answers2

7

Yes, there are tools. I would not use them.

Arguably, the key benefit to subprocedures are local variables and a parameterised interface. No automated tool is going to be able to tease out the interface, and figuring out which global variables should be made into local variables is a daunting task.

For my money then, all an automated tool will do is to convert the syntax from EXSR to CALLP. The 'subprocedure' is still using global variables and the interface is still hidden from the programmer. What's the point?

Buck Calabro
  • 7,558
  • 22
  • 25
  • 1
    +1 Automated tools to take existing code and create new code can be problematic AND they may not create it in the most efficient way. Write it yourself, it doesn't take that long (especially if you copy-paste code). – Mike Wills Jun 19 '14 at 13:44
  • Linoma's tool does indeed just convert EXSR to CALLP...I argue that this is at least a reasonable first step. Also, I think Arcad's can go a step further given the observer module. I don't see how you could possibly convert an entire system in a reasonable time frame without some sort of tool...or an army of consultants; which has it's own set of issues. – Charles Jun 19 '14 at 16:32
  • Although I prefer hand crafted solutions in general, a tool that converts a subroutine into a procedure is a reasonably good first step. Once the subroutine is converted you can manually tweak it to isolate it. – David G May 11 '15 at 12:59
1

Yes

I'm particularly fond of Linoma's RPG Wizard http://www.linomasoftware.com/products/rpgtoolbox/rpgwizard

Arcad has another tool, but it has more functionality and is more $$$. http://www.arcadsoftware.com/products/arcad-transformer-ibm-i-refactoring-tools/

Note that Linoma will convert the syntax from internal subroutine to internal procedure; but it'd be a manual process to move the procedure externally.

Whereas I believe Arcard's toolset can build an external procedure.

Charles
  • 21,637
  • 1
  • 20
  • 44