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
 

 

unable to move pic 9(4) comp value to pic s9(4) comp

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ms0033436

New User


Joined: 20 Nov 2008
Posts: 15
Location: Pune

PostPosted: Fri Jan 28, 2011 8:41 pm    Post subject: unable to move pic 9(4) comp value to pic s9(4) comp
Reply with quote

Hi

My requirement is :
There are 2 variables X and Y.

X - IMS segment variable - pic 9(4) comp value 0001
Y is DB2 variable (DCLGEN variable ). - pic s9(4) usage comp.
My program uses cobol-db2 where the below is happening:
move X to Y.

There is a select query (Dynamic cursor) which uses Y variable in the where clause.

After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table

can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp?
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Jan 28, 2011 9:04 pm    Post subject:
Reply with quote

Quote:
can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp?
COBOL has a number of ways to do this: MOVE, COMPUTE, ADD, SUBTRACT, MULTIPLY, DIVIDE. If you need an IMS or DB2 solution, you need to specify this and you should not have posted in the COBOL forum.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jan 28, 2011 9:09 pm    Post subject: Re: unable to move pic 9(4) comp value to pic s9(4) comp
Reply with quote

Deleted by poster.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Sat Jan 29, 2011 1:51 am    Post subject: Re: unable to move pic 9(4) comp value to pic s9(4) comp
Reply with quote

ms0033436 wrote:
Hi

My requirement is :
There are 2 variables X and Y.

X - IMS segment variable - pic 9(4) comp value 0001
Y is DB2 variable (DCLGEN variable ). - pic s9(4) usage comp.
My program uses cobol-db2 where the below is happening:
move X to Y.

There is a select query (Dynamic cursor) which uses Y variable in the where clause.

After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table

can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp?

Although it has been quite a few years since I last wrote COBOL, ISTR that it is:
Code:
MOVE COMP-VAR TO SIGNED-COMP-var.

Show us -- cut and paste using the code tags, not an attached screen shot -- the declarations of the variable, the query, the DDL for the table (or an equivalent section from SYSCOLUMNS), and the error message. Your story does not seem to be congruent with reality.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Jan 29, 2011 1:59 am    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

Compile the program using the LIST,NOOFFSET options (generate Assembler) and post the Assembler expansion of this move.

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jan 29, 2011 2:20 am    Post subject:
Reply with quote

Hello,

I suspect that the actual move is not the problem but rather the definitions of the data in the database versus the program are not acceptable to db2 as presented.

Methinks Akatsukami is on target. . .

And the requested info needs to be posted for us to better help.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Jan 29, 2011 2:38 am    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

Dick,

Remember the recent posting where the OP insisted that COMP was Packed-Decimal? The compiler should execute this COMP-to-COMP move in one MVC.

But, maybe Akatsukami is on to something?

Bill
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Sat Jan 29, 2011 2:39 am    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

Quote:

After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table

S9(4) Comp is a half word binary field and would contain x'0001' if positive (or for example x'FFFF' if negative 1).
What exactly is the form that DB2 is expecting this in as you say it is expecting '+0001'? Can you clarify that point?

Quote:

can anybody has idea how to move pic 9(4) comp to pic s9(4) usage comp?

There is nothing wrong with that Move.

Have you looked further into SQL CODE -104?
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db29.doc.codes/n104.htm
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jan 29, 2011 2:55 am    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

Hi Bill,

Yup, i do recall. . . Unfortunately, we have very many with a complete mis-understanding of how data is actually stored for the various data types. . .

And it is almost like pulling teeth to get the useful info posted . . .

Maybe it will follow soon icon_wink.gif

d
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sat Jan 29, 2011 2:57 am    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

After further review, perhaps the compiler is loading the unsigned-halfword into a register and then issuing a "LOAD POSITIVE REGISTER"?

This would ensure any negative value becomes positive.

After the LPR of itself (or another register), it probably issues a STH (or maybe an STCM) to the signed-halfword and we're done?

Yeah, an MVC would not completely do the trick, because you're going from an unsigned-halfword to an signed-halfword and the receiving field needs to be a signed-value.

But, I agree, this MOVE should work as-is....

Bill
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Sat Jan 29, 2011 6:35 am    Post subject:
Reply with quote

Bill O'B,
In the direction of a move of an unsigned to a signed field, a straight MVC will be fine as the from field is by implication positive.
The opposite move however of a signed filed to an unsigned, will as you indicate result in a LH, followed by a LPR and a STH to ensure the result is positive.
None of this helps the OP however...!
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Mon Jan 31, 2011 8:17 pm    Post subject: Re: unable to move pic 9(4) comp value to pic s9(4) comp
Reply with quote

ms0033436 wrote:
After executing the program it abends with SQL CODE -104 as it is expecting in this form '+0001' in DB2 table

There is nothing wrong with the move statement. But OP need to post his SQL for the query, as SQLCODE -104 is a syntax error, so we need the SQL statements to be able to help.
Back to top
View user's profile Send private message
ms0033436

New User


Joined: 20 Nov 2008
Posts: 15
Location: Pune

PostPosted: Wed Feb 02, 2011 5:39 pm    Post subject:
Reply with quote

[S9(4) Comp is a half word binary field and would contain x'0001' if positive (or for example x'FFFF' if negative 1).
What exactly is the form that DB2 is expecting this in as you say it is expecting '+0001'? Can you clarify that point?
]

David,
i am getting the below message UNEXPECTED SQLCODE OF -104 ENCOUNTERED IN program CAUSING U3920 ABEND.
SQLCODE = -104, ERROR: ILLEGAL SYMBOL " ". SOME SYMBOLS THAT MIGHT BE
LEGAL ARE: + .

SQLSTATE = 42601 SQLSTATE RETURN CODE
SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR
SQLERRD = 3 0 0 -1 250 502 SQL DIAGNOSTIC INFORMATION
SQLERRD = X'00000003' X'00000000' X'00000000' X'FFFFFFFF'
X'000000FA' X'000001F6' SQL DIAGNOSTIC INFORMATION
BAD SQLCODE ON PREPARE QUERY AGAINST DB2 TABLE PARA
PROGRAM ABNORMALLY TERMINATED
PTOM DUMP OUTPUT 383
Due to this i am thinking that + is need in that variable. but when i display all the values used in the select query are coming correctly
this value comes with out a sign - ie. 0001
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 02, 2011 5:54 pm    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

If a halfword contained X'0001' (H'1'), the high-order sign-bit is "Off" and therefore, the value is positive, so it could be defined to an unsigned or signed halfword picture clause and utilized as such.

As you've said, a negative halfword one is X'FFFF' (H'-1') and the high-order bit is "On".

There's something we're missing here, because your code (based upon what you've posted), should work as-is.

Have you posted all there is to this problem?

Just a WAG, but perhaps these halfwords need to be aligned (a/k/a COMP SYNC)?

Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Feb 02, 2011 6:10 pm    Post subject:
Reply with quote

The OP's problem is that his generated dynamic sql SUCKS

the error message ---ILLEGAL SYMBOL " "
says it all.
the OP's refuses to post the generated slop that he feeds DB2 and
only responds to posters (like David) that provide a potential excuse
not to be responsible for his code.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 02, 2011 7:14 pm    Post subject: Reply to: unable to move pic 9(4) comp value to pic s9(4) co
Reply with quote

Dick,

Yes, absolutely, Kjeld's post said it all, but I missed it completely < sigh >

Bill
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Wed Feb 02, 2011 7:29 pm    Post subject:
Reply with quote

I think OP has confused the format of host variables that are populated by the query and host variables that introduces dynamic literals in the where statements, and thats why we need to see the SQL-code and host variable contents that causes the syntax error.
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts I am unable to use SWAPBAR ON command... mrsidhu12 TSO/ISPF 3 Thu Sep 01, 2016 1:10 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm


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