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

Remove spaces from variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Sat Feb 15, 2014 5:11 am
Reply with quote

Hi,

I have a variable of 100 bytes (WS-A) and filling with two variable values (WS-B and WS-C) using string function. After that i search the table using WS-A-OUT (WS-B+WS-C) but getting -305 error while program execution. With the same value when i serach table using spufi i am getting the record successfully.

Program
WS-A pic x(100).
ws-b pic x(50)
ws-c pic x(50)

String WS-B delimited by space
WS-C delimited by space
into WS-A-OUT
:
:
Select * from table where WS-COL-A = WS-A-OUT

WS-COL-A is CHAR (100) NOT NULL definition in table

Please help me why I am not able to serach the value in table using program.
Is there any spaces need to be removed
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: Sat Feb 15, 2014 3:49 pm
Reply with quote

Since we don't know what your source values look like, or what values you expect, it is not possible to suggest anything. So...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Feb 15, 2014 7:37 pm
Reply with quote

Furthermore, what is the definition of WS-A-OUT? Your STRING and SELECT statements use that variable, yet you did not provide us with the definition of it, just something called WS-A. Maybe WS-A-OUT and WS-A are defined the same, and maybe not.

Plus, if you really want to debug the problem, why do you not simply put a DISPLAY of WS-A-OUT (or WS-A) just before the SELECT statement? That way, you can see precisely what is being used for the SELECT and compare it to your results using SPUFI. You claim to be using the same value in SPUFI as in your code, yet you are getting different results. This indicates that the SPUFI value you are using is NOT the same as the value in the program.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Thu Feb 20, 2014 12:47 pm
Reply with quote

1. PROBLEM may lie in your programming since you might have not handled NULL --> since -305
2. As robert said, before firing SELECT you should have displayed the values in A,B,C variables.

Remember DISPLAY is the simplest and quick debugging technique.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Feb 20, 2014 12:56 pm
Reply with quote

Apart from all other's suggestions,
Could you also post your full SELECT statement. I guess, one of your SELECT column that has NULL value, which can't able to move to host variable.

-305:
Quote:
THE NULL VALUE CANNOT BE ASSIGNED TO OUTPUT HOST VARIABLE NUMBER position-number BECAUSE NO INDICATOR VARIABLE IS SPECIFIED

A FETCH or embedded SELECT operation resulted in the retrieval of a null value to be inserted into the output host variable, designated by entry number 'position-number' of the output SQLDA, for which no indicator variable was provided. An indicator variable must be supplied if a column returns a null value.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Feb 20, 2014 11:42 pm
Reply with quote

and it may be that your host variable is ok.

you are getting a negative 305 (as sureshpathi10 pointed out)
and that is the problem you should solve first.

had you bothered to read the manual about a -305 SQL code
and thought a bit,
i doubt if you would have posted your question.

you need to improve your debugging methods.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Sat Feb 22, 2014 1:25 am
Reply with quote

It is not about any SPACE issue and if it ever could have been then you would be ending up getting SQLCODE +100 and not -305. So as other experts pointed out please have it investigated by looking at the underlying qualified data for the above statement and as per my knowledge for SQLCODE -305 you would centainly get the column number in the log to which it had a problem which could be the easy start to correct the data or use NULL indicators or use COALESCE function
Note: Moreover, that is one of the reason I could think that SELECT * is not advised.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Variable Output file name DFSORT/ICETOOL 8
Search our Forums:

Back to Top