What is the use of Level 49 in COBOL?

Showing Answers 1 - 11 of 11 Answers


  • Jan 16th, 2007

it is the last level of sub group elements.

  Was this answer useful?  Yes


  • Jan 19th, 2007

For declaring the  host variables, you can use level numbers 01 through 49, and
77 also. you got it clear

  Was this answer useful?  Yes


  • Jan 30th, 2007

Hi,Level 49 is the last sub level and is used to declare identifiers for which we are not sure that what length they can occupy. For exapmle we have a filed NAME in our file and its length is 50 and we want that if name of a person is of 20 chars only, rest 30 chars positions could be reused than to leave the space unused.EX. Say our Rec is01 EMP-REC 05 EMPID PIC X(10). 05 DEPT PIC X(20). 49 NAME PIC X(50). 49 ADDRESS PIC X(50). And if NAME is 'PRADEEP' i.e. using only 7 chars out of allocated 50 then the next field ADDRESS will start right from where the NAME filed ends instead of leaving the 43 positions unused.All, Please advise me if I am wrong.pradeep

  Was this answer useful?  Yes

anil bidave

  • Feb 4th, 2007

it is used to define the db2 char in cobolas var char.

  Was this answer useful?  Yes


  • Feb 4th, 2007

it is used to define the db2 char in cobolas var char.

  Was this answer useful?  Yes

Pradeep Bhatt

  • Feb 6th, 2007

Yes It is used for VARCHAR type in a Copybook for a DB2 table, but the logic is to implement the efficient space utilization which is provided in DB2 by VARCHAR against CHAR.

  Was this answer useful?  Yes


  • Feb 10th, 2007

It is last sub groups of elemenary items.

  Was this answer useful?  Yes

Irina K

  • Mar 24th, 2007

You "need" 49 levels to define host variables for VARCHAR cols in DB2. The 1st 49 contains the length of the string; the 2nd the string itself. To move the string you can use refmod or the STRING stmt, eg.:


01  varchar-fld.
    49  vf-len     pic s9(004) comp.
    49  vf-data    pic  x(00n).

move vf-data(1:vf-len) to ....
PS It's the creator's responsibility to populate vf-len when vf-data is populated. When the data is written to the DB2 table it will only occupy as many bytes as the vf-len indicates even though the PIC of the host variable may be larger.

Also note that there is no "space" fill when the col is loaded into vf-data. If vf-data was 5 bytes and conained "AAAAA" then you loaded the col containing "BB" the result would be "BBAAA"

  Was this answer useful?  Yes

Although level 02-49 level are group or elementry elements but sometimes 49 are used for dynmic SQL, i.e.
01 WS-SQl-statement1-VARIABLE.
    49  WS-SQL-STATEMENT1-LEN                  PIC S9(4).         USAGE COMP.
    49  WS-SQL-STATEMENT1-TXT                  PIC x(1000.         


  • Apr 2nd, 2013

The level number 02 to 49 are use to specify the group and elementary data items within a record.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions