Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Varchar variable with lenght 32000

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Varchar variable with lenght 32000
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Fri Aug 26, 2011 1:29 pm    Post subject: Reply to: Varchar variable with lenght 32000
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    Post subject: Reply to: Varchar variable with lenght 32000
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Fri Aug 26, 2011 3:27 pm    Post subject: Reply to: Varchar variable with lenght 32000
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us