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
 

 

Remove spaces from variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Remove spaces from variable
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Sat Feb 15, 2014 3:49 pm    Post subject: Reply to: Remove spaces from variable
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: 7908
Location: Bellevue, IA

PostPosted: Sat Feb 15, 2014 7:37 pm    Post subject:
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: 176
Location: Pune, Maharashtra, India

PostPosted: Thu Feb 20, 2014 12:47 pm    Post subject:
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    Post subject:
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    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Sat Feb 22, 2014 1:25 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am


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