Language Migration - COBOL to JAVA converion - Help required in mapping ???
842438Feb 24 2011 — edited Feb 24 2011Hi All, Im looking for an idea or suggestion on the COBOL group variable conversion to equivalent conversion approach in Java equivalent:
Background: The conversion tool currently im working on demands the tool to convert COBOL programs to .NET platform wherein all COBOL code needs to have an equivalent code in JAVA language. Inspite of find almost all the equivalent, I'm currently stuck in COBOL group variable declaration and redefine feature of COBOL equivalent in C# and Java programming.
Example:
I have a COBOL code as follows:
This is a COBOL declaration which occupies 30 bytes in memory. I'm looking for an equivalent declaration in JAVA program. The point to be noted here is the group variable at 01 level WS-NAME represents all the 30bytes on the whole whereas the sub level variables within the group (05 levels) can be used in the program individually representing 10 bytes each of their own.
The problem spans more when I have multiple redefines as mentioned below
01 WS-NAME
05 WS-FIRST-NAME
07 WS-TITLE PIC X(2).
07 WS-FNAME PIC X(8).
05 WS-MIDDLE-NAME PIC X(10).
05 WS-LAST-NAME
07 WS-SURNAME PIC X(8).
07 WS-SUFFIX PIC X(2).
Please note that the program can use any of the individual variables declared here in and the group variables of the higher level will be able to access them as a whole.
Example:
MOVE 'MR' TO WS-TITLE.
MOVE 'ALFRED' TO WS-FNAME.
MOVE 'ALEX' TO WS-MIDDLE-.
MOVE 'SANDOU' TO WS-SURNAME.
MOVE 'JR' TO WS-SUFFIX.
DISPLAY WS-NAME ==> will display MR ALFRED ALEX SANDOU JR.
DISPLAY WS-FIRST-NAME ==> will display MR ALFRED
DISPLAY WS-LAST-NAME ==> will display SANDOU JR.
DISPLAY WS-SUFFIX ==> will display JR.
Any changes to the above variables of any level will change the entire group accordingly..
e.g.: MOVE 'SR' TO WS-SUFFIX and DISPLAY WS-LAST-NAME ==> will display SANDOU JR and DISPLAY WS-NAME ==> will display MR. ALFRED ALEX SANDOU SR.
This problem spans more when I have a group redefine.
01 WS-RNAME REDEFINES WS-NAME.
05 WS-RFNAME PIC X(15).
05 WS-RLNAME PIC X(15).
In Redefines with COBOL both the variables share the same memory and hence the changes to the WS-RNAME in the given example actually changes the WS-NAME values and vice versa.
Example:
DISPLAY WS-RNAME ==> in the current scenario will display MR. ALFRED ALEX SANDOU SR.
MOVE 'ALFRED' TO WS-RFNAME.
MOVE 'SANDOU' TO WS-LNAME.
DISPLAY WS-RNAME ==> will display ALFRED SANDOU
DISPLAY WS-NAME ==> will also display ALFRED
SANDOU
Basically both share the same memory location and changes to any of the field in the program gets replicated on the usage of other variable. This happens implicit in COBOL as we have a two named memory location for the same memory location of 30 bytes. I'm looking for an equivalent in JAVA programming.
NOTE :
1. The changes are expected to be handled implicitly. No explicit assignment is entertained whenever a change happens to any of the variables belonging to the group.
2. There is a possibility of having more multiple redefines and more multiple sub grouping allowed in COBOL which makes the problem more tougher.
Please help me on this. Having different classes declared and assigning objects to each class will not help as whenever a change happens to any field will require an explicit way of calling get() or set() methods every time. I'm looking for an implicit change to happen like COBOL.