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.

31 Dec 2021

Automated Mainframe Testing Can Accelerate COBOL Modernization

  The motivation for modernizing or transforming COBOL for this desire has…

15 May 2023

Five Great Use Cases to Gain the Benefit of zIIPs

The IBM zIIP is a dedicated specialty processor designed to operate asynchronously…

29 Jun 2023

The Role of Mainframe Data in a Hybrid Cloud Environment

More and more organizations are adopting a hybrid approach to their IT…

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