IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Varchar variable with lenght 32000


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Fri Aug 26, 2011 1:21 pm
Reply with quote

Hi,

i'm trying to read a database field in cobol program. The DB2 filed is declared as Varchar with the length 32000, when i read this column through a cobol program it is displaying spaces where as the table has the data.

is there any compiler option which we need to change because the varchar length is more than 255?

Thanks in Advance,
Srinath D
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Aug 26, 2011 1:29 pm
Reply with quote

Compiler option? No.

Can you show your code, please. Data definition, code from the procedure division using the data. Please use the Code button (above the input box) to preserve spacing. Highlight text, click code, click preview, correct if necessary. Please copy/paste to avoid typos.
Back to top
View user's profile Send private message
srinathds83

New User


Joined: 17 Jul 2007
Posts: 41
Location: pune

PostPosted: Fri Aug 26, 2011 3:06 pm
Reply with quote

Hi Bill,

Code is somewhat like this:

01 WS-TEXT.
49 WS-TEXT-LEN PIC S9(4) COMP.
49 WS-TEXT-FIELD PIC X(32000).


SELECT COLUMN1
INTO :WS-TEXT
FROM TAB1

DISPLAY ‘WS-TEXT : ‘WS-TEXT
DISPLAY ‘WS-TEXT-LEN : ‘WS-TEXT-LEN
DISPLAY ‘WS-TEXT-FIELD : ‘WS-TEXT-FIELD

OUTPUT:

WS-TEXT :
WS-TEXT-LEN : 0000
WS-TEXT-FIELD :


Problem is we are getting spaces in the fields. I tried using TRUNC(BIN) and TRUNC(OPT) Option as well.

Thanks
Srinath D
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Aug 26, 2011 3:27 pm
Reply with quote

Interesting. I've never displayed 32000 bytes at once before. I assume you mean

Quote:
OUTPUT:

WS-TEXT :

Then several kilometres down the listing

WS-TEXT-LEN : 0000
WS-TEXT-FIELD :

then another few kilometres



When you display WS-TEXT, WS-TEXT-LEN is within it, it can't be showing space. WS-TEXT-FIELD is also subordinate to WS-TEXT, so only actually "necessary" to display WS-TEXT-LEN and WS-TEXT-FIELD.

What data are you expecting in WS-TEXT-FIELD?

I'm just blindly assuming you've defined correctly for receiving a VARCHAR in your Cobol program, as I don't know myself. Have you?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Aug 26, 2011 4:05 pm
Reply with quote

try changing

01 WS-TEXT

to be a subordinate element under a different lvl-01.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Aug 26, 2011 4:15 pm
Reply with quote

srinathds83 wrote:
Code is somewhat like this:


also,

somewhat is BS.
computer programming is a very strict and precise discipline.

if you still have problems, after implementing my suggestion,
then copy&paste - using CODE tags (here is how to use code tags)
your exact
  • Host variable definitions
  • the ddl for the DECLARE Table
  • imbedded SQL


by the way, what is the SQL code after the SELECT?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top