How to Write COBOL Logic for DB2 VARCHAR Field

The Varchar column in DB2 has significant benefits in DB2. You can save a lot of space and add variable-length data. Brief information sharing with you to know what is VARCHAR.


VARCHAR(n): Varying-length character strings with a maximum length of n bytes. n must be greater than 0 and less than a number that depends on the page size of the table-space.

  • The maximum length is 32704.
  • Handling additional data in VARCHAR fields while using in COBOL. This can be avoided at DBA level also. Read additional info.

How to use VARCHAR Field in COBOL

01 payee-name.
49 L PIC S9(4) COMP-5.
49 D PIC X(150).
  • In COBOL program you need to move length value into length field L and data value into data field D

Also Read

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.