Highlighted
Absent Member.
Absent Member.
2108 views

Using SPZERO in Visual COBOL

Jump to solution

My company currently uses Net Express 3.1 and will be migrating to Visual COBOL within the next several months.  We use the SPZERO compiler directive on majority of the programs we migrated off the mainframe several years ago.  This is due to having spaces in numeric fields on the old mainframe data files.  At the time of migration, it was better to use SPZERO than to modify the files/programs.  I read in the Visual COBOL documentation that SPZERO has been deprecated and is not supported in Visual COBOL.  Is there an alternate way to accomplish the same behavior as SPZERO in Visual COBOL?

Thanks,
Ben

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using SPZERO in Visual COBOL

Jump to solution

I can get your example to work in native code by using the directives:

     $set HOST-NUMMOVE HOST-NUMCOMPARE SIGN-FIXUP

instead of using spzero but it is not working in managed code.

Please open up a support incident for this problem and we will RPI the behavior with development.

Thanks.

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using SPZERO in Visual COBOL

Jump to solution

Actually, what the documentation says is the following:

Note:

  This directive has been deprecated; it is provided for backward compatibility only.
  You should instead use SIGN-FIXUP.
  This directive can adversely affect the performance of generated code.
  This directive is not supported in .NET COBOL.

So the directive still works for native COBOL projects in Visual COBOL but it is not suppported for managed code .NET applications.
You should look at replacing SPZERO with SIGN-FIXUP if using managed code.

I tested the following in a native project in Visual COBOL 2.1 and without SPZERO it gives the incorrect result and with SPZERO it gives the correct result.

Will you be using native code or managed code when you go to Visual COBOL?

     $set spzero
      program-id. Program1 as "testspzero.Program1".
      data division.
      working-storage section.
      01 num-field    pic s9(9).
      01 char-field   redefines num-field pic x(9).
      procedure division.
          move spaces to char-field
          subtract 1 from num-field
          display num-field
          goback.
      end program Program1.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Using SPZERO in Visual COBOL

Jump to solution

We will be using a mix of native and managed code.  I tried your example on native code and it worked - must have missed it the first time.

Can you provide an example of using SIGN-FIXUP as I tried in on managed code without any luck.

Here is the code I used for both native and managed code and covers most of our situations.  The test-file contains spaces.  The results should display zeros as it does in native code with SPZERO.

     $set sign-fixup

      program-id. Program1 as "ConsoleApplication3.Program1".

          select test-file

              assign to "\Temp\Test.txt"

              organization is line sequential.

      data division.

      fd  test-file.

      01  test-rec.

          05 test-field pic 9(3)v99.

      working-storage section.

      01 notFormated pic 9(3)v99.

      01 notFormated2 pic 9(3)v99.

      01 formated pic $9(3).99.

      01 formated2 pic $9(3).99.

      procedure division.

          open input test-file.

          read test-file.

          display "Managed COBOL".

          display " ".    

          display "9(3)v99 field from file - " test-field.

          move test-field to notFormated.

          display "9(3)v99 field - " notFormated.

          move notFormated to notFormated2.

          display "notFormated2 - " notFormated2.

          move notFormated to formated2.

          display "formated2 - " formated2.

          display " ".

          display "9(3)v99 field from file - " test-field.

          move test-field to formated.

          display "$9(3).99 field - " formated.

          move formated to notFormated2.

          display "notFormated2 - " notFormated2.

          move formated to formated2.

          display "formated2 - " formated2.

          close test-file.

          goback.

      end program Program1.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using SPZERO in Visual COBOL

Jump to solution

I can get your example to work in native code by using the directives:

     $set HOST-NUMMOVE HOST-NUMCOMPARE SIGN-FIXUP

instead of using spzero but it is not working in managed code.

Please open up a support incident for this problem and we will RPI the behavior with development.

Thanks.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.