Dot Net Fluke: Getting by on C# for iSeries RPG Developers

Useful tutorials on C# and .NET for RPG iSeries AS/400 developers. Brought to you from the folks at AranRock Consulting

8/5/08

Converting RPG code to C# automatically?

What if you could take  your RPG programs and hey presto! have them converted into .NET and instantly sell your product to the rest of the world.   This would be a boon to AS/400 vendors locked into the small(ish) AS/400 market.   The advantage is that the original product is likely  a mature business proven system which can provide a critical edge against the deluge of competition once in the new windows space.  While  webfacing does provide a web front end to applications and is great for hosted models it does not help customers who are windows only and want windows only software.

Granted companies need to migrate on the competition level . However, all the supposed advantages such as performance, cost savings, availability of talent etc sounds hollow to long time AS/400 owners. Anecdotally we know that the uptime for the AS/400 is absolutely stunning compared to windows.  It's super stable and extremely reliable. At windows only shops instead of maintaining one iSeries server  and a handful of windows server you end  up maintaining 20-30 windows servers for a small organization.  But like I said, it's about getting your product out to a bigger market.
A big issue with migration products is that often your migrated solution will not be able to operate without them. Yikes! 

I'll be doing a review of these migration products once I get my hands on them but in the meantime here's an overview. Click the title to go to the product website.

TranSoft ML-Impact 
Well, the boys and girls at TranSoft claim that they can convert your old F-specs, c-specs to .NET .   I would love to see the code generated (post a sample  in comments pleez). They claim that CL and RPG will be converted to C#. Not only that they can take the DB2 tables and migrate them to SQL server. Not everything can be converted directly of course and the end result looks much like a 5250 application.
Without having the product available to me I can't give it the thumbs up or down  but if you have any experience with this tool, please drop a comment.

ADC Austin
Remember Synon? The hot product of 20 years ago is now trying to be cool.  They have jiggered a way to migrate from CA2E (Synon)  to Plex which uses .NET.   Sounds complicated. If you've tried it, drop me a line.

ASNA Monarch and AVR for .NET
ASNA monarch is a code converter that  creates RPG for .NET while AVR is a Visual Studio add-in that allows RPG  for .NET (an ASNA creation) development and compiles as a .net app.   Seems like these two products have the same product base.  The only feedback I've seen on this product is that there is no code completion, no automatic layout and ctl-z doesn't work.  Your comments pls.

Lansa Ramp and the rest
There are a bunch of other sticky migration tools out there that are designed to keep you using their applications. While the products above are somewhat sticky you can still migrate off them.  Products like the Lansa Ramp platform is a staged migration solution that requires you to develop a an application framework using their tools, prototype it, then recreate your screens in that framework. However the end product is a Lansa architecture that you have to stick with for the rest of eternity. 

Labels: , , ,

1/18/08

Comparing RPG code to C# : The For Loop

There are similarities between free format RPGIV and C#. In the example below I show a small program that accomplishes the same task in both languages. The task is to find the first blank character in a string from the end to the beginning. I'm well aware there is a single method available for this on String in C# but the purpose here is to show the similarities.
RPG is below:


















Now C#:
























You can see some basic similarities:
  • Statements end with a ';' ,

  • the For loop is similar.

  • 'Leave' gets you out of an RPG loop while 'Break' exits a C# loop.

  • Assigning values is the same in both.

  • Declaring variables in RPGIV requires both type and how many characters (you can declare varying length variables but do define an initial length). To define a variable you must put values in fixed positions in a special kind of statement block called 'Definition Specifications' or D-specs. In C# you simply declare the type. The type of the index 'i' is denoted by a zero in the decimal placess position.

  • C# requires a 'Main' method. RPG just executes from the first executable line.

  • C# variables are local by default. I can't access that 'i' variable outside of that For loop - the program wouldn't even compile. RPG variables are global unless used in procedures.


  • C# requires a class definition, namespace and you define what other namespaces in .Net you want to refer to in your program with the 'Using' statements. The using just means you don't have to refer to the full name like 'System.Console.Readline()'.


  • C# doesn't need 'EndFor' or 'EndIf'. Coding is accomplished in blocks between curly braces '{' and '}'.


  • The biggest difference is that C# strings and objects have a multitude of methods and properties on the string itself - not part of the language. RPGIV is pretty good at string manipulation too but can never approach the flexibility of C# as the RPG designers would have to create a new keyword when it needs to perform a function on a string that it doesn't already have. In C# there are only a handful of keywords - most actions are accmplished by methods on the objects themselves. For instance in the above example you access the length of a string by examining its property. e.g. 'field.length' returns an integer value whereas in RPG I chose to use the built-in-function %len to do the same thing.
    To find the first non-blank in a string starting from the end you can use field.IndexofLast(' ') . RPGers note how the methods and properties are on the string 'field' which I defined. As soon as you define a variable it creates a copy of the string object so you have full access to a huge amount of manipulation techniques. Adding new methods and properties to strings and other types isn't a major change in the language.
RPG Output below





























C# Output:

Labels: , , , , ,