Search code examples
mainframejcl

JCL - Get count of non space chars in a given area (mainframe)


I need to prepare some input data to run through a program, the data should be in the following format.

 UID (1-11)|TxtLen (12-16)| Text (17-62)

I can use sort to position the fields properly and get the UID and text fields. The ‘TxtLen’ is should contain the number of chars from the start of the text field to the last char in the text field.

i.e. “Hello”’s TxtLen is 5, “Hel lo”’s TxtLen is 6, “Hello World”’s TxtLen is 11, etc...

I want to know if there is a way of getting the TxtLen through JCL only, or is a program required to do this?

-Thanks


Solution

  • You will need a program.

    I see a fair number of mainframe questions on Stack Overflow asking if something is possible with "JCL only." Keep in mind that JCL is mostly a means of executing programs, and actually does very little other than that. For instance, when you say

    I can use sort to position the fields properly and get the UID and text fields

    sort is a program. It happens to be a program found on most systems (though there are different vendors' implementations, IBM has one, SyncSort has one, CA has one, etc.) There are plenty of other programs commonly found on mainframe systems.

    And just to be pedantic, JCL doesn't actually do anything, JES does the work as it interprets JCL.

    For your particular situation you could create a SORT exit, or process your data in Rexx, or you could use some of the Unix System Services commands and execute those via BPXBATCH or COZBATCH.