Why modernization is hard? – Series 2

Conditional handling in COBOL is quite tricky to replicate in newer languages for a few reasons.

1. The character comparisons use EBCDIC codepage which has different collating sequence than ASCII/UTF-8. The non-equal comparison operators viz. >, >=, <, <= can result in different results when compared with EBCDIC collating sequence as against ASCII/UTF-8. e.g. String compare of literals viz.‘123ABC’ > ‘ABC123’ on mainframe will be flagged as True while it will be exact opposite in ASCII/UTF-8.

2. Comparing two different variables (PIC X(nn)) of different sizes are padded with SPACES (hexadecimal 40) and then compared. This can cause a difference in results if not handled correctly. Business rules depend on this kind of conditional handling.

77 WS-LONG-CHAR PIC X(10).

77 WS-SHORT-CHAR PIC X(7).

IF WS-LONG-CHAR IS EQUAL WS-SHORT-CHAR

The above condition requires that WS-SHORT-CHAR to be padded with three EBCDIC space characters.

3. A variable with DISPLAY Numeric can behave either as a number or as a character field and this causes extra complex conditional handling. Especially if one side of the condition is DISPLAY Numeric and other side is a Character or a Literal.

The following example will not work if WS-NUM PIC 9(2) has value 9.

IF WS-NUM IS EQUAL ‘9’ or equivalent character variable – PIC X(nn)

4. I have also seen many Multi level Nested IF / ELSE scope abruptly ends with a period or dot in COBOL. This could cause LLM to completely misunderstand the business rule.

Example below abruptly ends all levels of nested IF/ELSE with a period.

5. I have also seen some strange behavior from AI such as (real business cases):

IF WS-STR( I, J, K)( A -B – C : D -E) = FUNCTION LOWER-CASE ( WS-X-VAL ( A -B -C: D -E) THEN

Confuses the LLM as below

IF WS-X-VAL = ‘AB””CD”EF”’ THEN changed the actual literal to hide the real business case

Confuses the LLM as below

Summary

What I have highlighted above represents just a small subset of the real issues encountered during legacy modernization. Understanding the actual business intent behind COBOL conditional logic can be a lengthy process unless you have a robust toolset like CloudFrame.

13 Dec 2023

Fortune 500 Financial Services Firm collaborates with CloudFrame to explore…

Fortune 500 Financial Services Firm collaborates with CloudFrame to explore a tool-assisted…

09 Jan 2024

Large Credit Card Company Successfully Migrates Two COBOL Applications with…

Large Credit Card Company Successfully Migrates Two COBOL Applications With Over 200 Batch…

16 Dec 2022

Understanding COBOL Cross-Compile

CloudFrame’s Relocate product is used to cross-compile COBOL systems in executable Java…

Written by

Venkat Pillay

Venkat is a true technology visionary, serial entrepreneur, strategist, deep generalist, and architect. With over 25 years of experience and a passion for innovation, his expertise ranges from Legacy to emerging technology and company building.

Founder and CEO