MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COBOL value clause limit

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 14, 2004 11:31 am    Post subject: COBOL value clause limit Reply with quote

I was under the impression that the value clause can have 16,777,215 bytes for a field defined as alphanumeric. The same can be found here Compiler limits .Today I found that you cannot have more than 160 bytes for the value clause.

To elaborate more the following code compiles with out any problem.
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+---
       IDENTIFICATION DIVISION.                                     
       PROGRAM-ID.    SAMPLE                                       
       DATE-COMPILED.                                               
       ENVIRONMENT DIVISION.                                       
       DATA DIVISION.                                               
       WORKING-STORAGE SECTION.                                     
       01 MY-LONG-VAR           PIC X(800) VALUE                   
           'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA     
      -    'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'.   
       PROCEDURE DIVISION.                                         
                                                                   
            DISPLAY MY-LONG-VAR                                     
            GOBACK.                                                 
                                                                   


Now since I defined my my-long-var as 800 bytes I want to a move a 800 byte value to the field. I just added one more line to the value clause.

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+
       IDENTIFICATION DIVISION.                                 
       PROGRAM-ID.    SAMPLE                                     
       DATE-COMPILED.                                           
       ENVIRONMENT DIVISION.                                     
       DATA DIVISION.                                           
       WORKING-STORAGE SECTION.                                 
       01 MY-LONG-VAR           PIC X(800) VALUE                 
           'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
      -    'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 
      -    'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'.
       PROCEDURE DIVISION.                                       
                                                                 
            DISPLAY MY-LONG-VAR                                 
            GOBACK.                                             
                                                                 


Now the pgm wont even compile. It gave me an error

Code:

IGYDS0026-E An alphanumeric literal that was longer than 160 characters was
specified.  The literal was truncated to 160  characters.


So I looked up on IBM for the error and was surprised to find out that this is an undocumented limitation of COBOL. In 1996, a request number REQ00056821 was created. On August 24, 1998 REQ00056821 was not accepted.

This is the link for the error

http://www-1.ibm.com/support/docview.wss?uid=swg21003846

Did anyone come across such a situation?

The solution I came up with was to split the lines into chunks for 160 bytes at 05 level and have a value clause for each 05 level.

Any other ideas?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun May 16, 2004 7:54 pm    Post subject: Reply with quote

Hi Kolusu,

Since you've solved the problem already, this is just an exercise.

Don't know the specifics of your situation, but could you cut & paste into a small file (or maybe it's already in machine readable form) and do a ref/mod read/move loop into the pic x(800) field?

Regards, Jack.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon May 17, 2004 10:53 am    Post subject: Reply with quote

Jack,

I had no problems moving from a file to the 800 byte field with reference modification. It works fine. Even this also works fine.

Code:

WORKING-STORAGE SECTION.                                   
                                                         
01 VAR-A                 PIC X(800) VALUE ALL 'A'.   
01 VAR-B                 PIC X(800).                       
                                                           
PROCEDURE DIVISION.                                       
                                                           
     MOVE VAR-A TO VAR-B   
                               
     DISPLAY 'VAR-B: ' VAR-B                               

     GOBACK.                                               



But If I try like this it won't even compile.

Code:

       MOVE 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA       
-      'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA       
-      'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA       
-      'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA       
-      'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA       
-      'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA       
        TO VAR-B                                               

       DISPLAY 'VAR-B: ' VAR-B                                 

       GOBACK.                                                 


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Wed May 19, 2004 3:49 pm    Post subject: Reply with quote

Hi Kolusu,

I don't have a manual handy and it might have been a typo on your part, but don't you need a closing quote for the AAA... literal?

Could that be the problem?

Regards, Jack.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed May 19, 2004 4:11 pm    Post subject: Reply with quote

Slade,

You don't need a closing quote as blanks at the end of each continued line are counted as part of the literal because the continued lines do not end with a quotation mark.

Check this link which explains the rules for continuation.

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/igy3lr10/1.5.4.2.1?SHELF=&DT=20020920180651&CASE=

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Maton_Man
Beginner


Joined: 30 Jan 2004
Posts: 123
Topics: 0

PostPosted: Wed May 19, 2004 9:38 pm    Post subject: Reply with quote

Why don't you offer to fix it for them... Smile
_________________
My opinions are exactly that.
Back to top
View user's profile Send private message
Maton_Man
Beginner


Joined: 30 Jan 2004
Posts: 123
Topics: 0

PostPosted: Wed May 19, 2004 9:44 pm    Post subject: Reply with quote

I just did a search of the manual and came up with the following which is tantalizingly coincidental

Quote:

A nonnumeric literal is a character string enclosed in quotation marks
("), and can contain any allowable character from the character set of the
computer. The maximum length of a nonnumeric literal is 160 characters.


As far as the length of a literal for a value clause is concerned, the manual appears to state that it simply can't exceed the size of the variable it is the value for so you should in theory be able to specify an 800 byte literal.
_________________
My opinions are exactly that.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu May 20, 2004 4:58 am    Post subject: Reply with quote

Maton_Man,

I wish I had the ability to fix it. Smile Theortically I should be able to populate the value, but the hidden compiler limitation does not allow that.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Thu May 20, 2004 9:06 pm    Post subject: Reply with quote

Hi Kolusu,

Have you tried a closing quote on the final line of the lit? I know the rule supports your contention, but I find it curious that each of their examples show a closing quote for the lit. It's typical IBM to skirt these kinds of issues.

Their discussion of variable length records processing is a typical case in point.

Regards, Jack.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri May 21, 2004 5:17 am    Post subject: Reply with quote

slade,

I did have a closing quote for all my examples. Once I have more than 3 lines of data , pgm did not compile. It worked fine with 3 lines of value clause

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Fri Feb 13, 2015 10:24 am    Post subject: Reply with quote

I happened to be researching this, and came across this topic.

As indicated earlier in the topic, an alphanumeric literal is limited to 160 bytes. This is in the 1985 ANSI Standard,

When specifying a VALUE with a literal... you run into the limit not of the VALUE clause, but of the alphanumeric literal. It is the size of the literal itself that is the problem. With a figurative constant, or ALL as was shown, there is no problem with the size.

160 bytes is a limit of the Standard, not of the compiler. In the '68 Standard, it was a compiler-implementation limit. In the '74 Standard, it was specified, as 120, for a "non-numeric literal". In '85 extended to 160 for an alphanumeric literal (change of name). In 2014, it is 8191.

The Compiler Limits is a little confusing:

Total 01 + 77 (data items) No limit
88 condition-names . . . No limit
VALUE literal . . . No limit

I think what this means is there is no compiler limit to the number of VALUE clauses. There is of course another compiler limit which will affect that anyway, which is 999,999 lines of source.

Splitting the field into smaller items seems a better way to get a long literal.

Code:
01  some-name.
    05  FILLER PIC X(60) VALUE
     "12345678901234567890123456789012345678901234567890AAAAAAAAA".
    05  FILLER PIC X(60) VALUE
     "12345678901234567890123456789012345678901234567890AAAAAAAAAA".
    etc


This is easier to correct when it is realised that the first literal has a character missing. If it was a 160-character string, a mistake in the first 64 characters is trickier to fix Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group