Sunday, 11 August 2013

COBOL NUMPROC Compiler Option: PFD, NOPFD, and MIG Migration

A payroll program can compare two packed decimal fields correctly for years, then fail after one upstream file starts sending a non-preferred sign nibble. The NUMPROC compiler option tells Enterprise COBOL how much checking or correction it should do for signs in packed decimal and DISPLAY numeric data.

COBOL NUMPROC compiler option diagram comparing PFD, NOPFD, and MIG sign handling
Check numeric signs.

What is the COBOL NUMPROC compiler option?

NUMPROC controls how Enterprise COBOL treats numeric signs when it generates code for arithmetic, comparisons, and moves involving packed decimal and DISPLAY numeric items. It matters most when old files, hand-built test data, assembler routines, or converted applications can contain signs that do not match the preferred COBOL format.

The settings you will usually discuss are NUMPROC(PFD), NUMPROC(NOPFD), and older NUMPROC(MIG) migration behavior. For Enterprise COBOL 6, IBM documents that NUMPROC(MIG) is not supported the way it was in older compilers. The option is not a general performance switch. It is a data assumption. Pick it based on whether your input data always uses preferred signs.

NUMPROC(PFD), NOPFD, and MIG at a glance

Option Assumption Best fit
NUMPROC(PFD) Numeric data has preferred signs. Clean COBOL-created data where signs have already been verified.
NUMPROC(NOPFD) Signs may need generated code to handle non-preferred forms. Mixed-source data, old feeds, or files touched by non-COBOL programs.
NUMPROC(MIG) Legacy migration behavior from older compiler levels. Old compile decks and migration reviews; not a normal Enterprise COBOL 6 target setting.

What preferred signs mean

A signed packed decimal field stores the sign in the last half-byte. COBOL programs normally write preferred signs, but real production data does not always stay that neat. A file might be produced by assembler, copied from a different platform, repaired manually, or loaded by a utility that did not validate every numeric sign.

01 WS-GROSS-PAY     PIC S9(7)V99 COMP-3.
01 WS-DEDUCTION     PIC S9(7)V99 COMP-3.
01 WS-NET-PAY       PIC S9(7)V99 COMP-3.

If every value in those fields has a valid preferred sign, NUMPROC(PFD) lets the compiler generate shorter paths for many numeric operations. If the signs are not trustworthy, PFD can let bad data pass into comparisons or arithmetic without the extra generated handling you expected.

When NUMPROC(PFD) is a good choice

Use NUMPROC(PFD) when the program owns the data or every input feed has been checked. For example, a payroll calculation program that reads a VSAM file written only by COBOL programs, validates signed fields on input, and rejects bad records can often use PFD.

Do not choose PFD just because it may reduce CPU time. The option is safe only when the numeric data promise is true. One bad sign in a high-value record can be more expensive than a small CPU saving.

When NUMPROC(NOPFD) is safer

NUMPROC(NOPFD) is safer when signed numeric fields arrive from several sources. Common examples include old conversion files, test records copied from production, records updated by assembler, and feeds from distributed systems that were transformed before reaching z/OS.

IF CUSTOMER-BALANCE < ZERO
   PERFORM WRITE-CREDIT-REVIEW
END-IF

That comparison looks simple, but the compiler option decides how much sign handling is generated. If the file has suspect signs, keep the safer setting while you identify the source and clean the data.

Where NUMPROC(MIG) fits

NUMPROC(MIG) is mainly a legacy migration topic. If you find it in an old compile deck, treat that as a sign that the program needs migration review. IBM documents that Enterprise COBOL 6 does not support NUMPROC(MIG); if it is specified, the compiler issues a warning and uses the default NUMPROC setting.

A good migration plan compares compile listings, regression-test results, and records rejected by numeric checking. When the data is clean and test evidence is strong, move the program to the site standard option such as NUMPROC(NOPFD) or NUMPROC(PFD).

Use NUMCHECK during migration

For Enterprise COBOL migration work, NUMCHECK can help find invalid numeric data at run time. It is especially useful when a team wants to prove whether NUMPROC(PFD) is safe for a program. Use it in test or controlled verification runs, then review the records and code paths it reports.

//COBOL.SYSIN DD *
       PROCESS NUMPROC(NOPFD),NUMCHECK
/*

The exact compile syntax and suboptions depend on your compiler level and site defaults. Always check the compiler listing because the listing is the evidence of what the compiler actually used.

Safe review checklist

  • Find signed COMP-3 and DISPLAY numeric fields in the Data Division.
  • List every external file, Db2 extract, MQ message, and copybook feeding those fields.
  • Check whether non-COBOL programs can create or change the data.
  • Run representative test files with numeric checking before moving to NUMPROC(PFD).
  • Compare results for arithmetic, comparisons, and moves after the compile option change.
  • Record the final compiler option in the build standard, not only in one compile job.

Common mistakes

Using PFD because it sounds faster

PFD can generate more efficient code in some cases, but it is safe only when the data has preferred signs. The right question is not "Which option is faster?" The right question is "Can every signed numeric input be trusted?"

Leaving MIG forever

MIG is useful during migration, but a long-term compiler standard should be clear. If a program still needs migration behavior years later, document the reason and the data source that prevents cleanup.

Testing only clean data

A short unit test with perfect values does not prove the production file is safe. Include old records, rejected records, boundary amounts, negative balances, and records created by non-COBOL writers.

Related Mainframe Forum guides

For connected COBOL topics, read COBOL USAGE Clause, COBOL COMP-3 Packed Decimal, COBOL COMPUTE Statement, COBOL ARITH Compiler Option, COBOL OPTIMIZE Compiler Option, and COBOL Data Types.

External references

IBM documents the option in Enterprise COBOL NUMPROC, tuning guidance in NUMPROC migration and performance guidance, numeric checking in Enterprise COBOL NUMCHECK, and removed option behavior in compiler options not available in Enterprise COBOL.

FAQ

What does NUMPROC(PFD) mean in COBOL?

NUMPROC(PFD) tells the compiler to assume signed numeric data uses preferred signs. Use it only when input data has been verified.

Is NUMPROC(PFD) always faster?

No. It can reduce generated sign-handling code in some programs, but the visible performance effect depends on the workload. Correct numeric results come first.

When should I use NUMPROC(NOPFD)?

Use NOPFD when signed numeric data can come from old files, non-COBOL writers, conversions, or any source where signs may not be preferred.

Is NUMPROC(MIG) a permanent setting?

It is a legacy migration setting. In Enterprise COBOL 6, IBM documents that it is not supported and the compiler uses the default NUMPROC setting after a warning.

No comments:

Post a Comment

New In-feed ads