coboljcl

How to process non formatted numeric variable from SYSIN DD from JCL in COBOL


I coded a very simple COBOL program that should take data from sysin dd * and put it in my WORKING-STORAGE variable, but it doesn’t work as expected.

The problem is when I try to pass a value of 10 to a pic 9(10) variable, coded like this in jcl:

//SYSIN    DD  *
10
/*

I get 1000000000 instead of 0000000010. Is there a simple way to make it work without changing the input data?

Thanks in advance :)


Solution

  • The simple way would be to do a MOVE FUNCTION NUMVAL (ALPHANUMERIC-SYSIN) TO NUMERIC-VAR, possibly followed by a check that the result is not zero (which would be the case for invalid and empty data, as well as an actual zero.
    Depending on the version of the compiler (that information is missing in the question) you may be able to use FUNCTION TEST-NUMVAL (ALPHANUMERIC-SYSIN) to do a separate validation - or do it yourself completely.