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

Convert all numeric values of cobol to Java


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

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Fri Jul 17, 2009 1:14 pm
Reply with quote

Hi every one,

What is the equivalent declaration of s9(4) comp and s9(9) comp to numeric values in COBOL?

Thanks,
murali.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Jul 17, 2009 2:20 pm
Reply with quote

Hi Murali,

Could you be more specific in what u are trying to achieve.

S9(4) COMP ==> 2 bytes
S9(9) COMP ==> 4 bytes

If you are just trying to use the space (memory) then 9(2) or 9(4) respectively would suffice.
Else if u are trying to copy the value to 9(n) field, then a simple MOVE statment would be enough.

Hope this is what u were looking for...
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Fri Jul 17, 2009 2:44 pm
Reply with quote

Thanks Binop,

what could be the Picture clause for numeric for S9(10) comp-3.

Thanks,
Murali.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Fri Jul 17, 2009 2:45 pm
Reply with quote

Correction S9(10)V Usage Comp-3
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Jul 17, 2009 2:48 pm
Reply with quote

Hi Murali,

What is it that you want to acheive ?? icon_rolleyes.gif
Please be more specific.
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: Fri Jul 17, 2009 3:16 pm
Reply with quote

Murali, be aware that a COMP-3 or COMP field is numeric by COBOL definition. In fact, you cannot even do an IF NUMERIC test on a COMP field because every COMP field is NUMERIC -- always. Hence numeric picture clauses for your examples are PIC S9(4) COMP, PIC S9(9) COMP, and PIC S9(10) COMP-3.

If you are wanting to know what the equivalent USAGE DISPLAY picture clauses would be, just take the COMP or COMP-3 off of the field. If you're wanting to know something else about these fields, please clarify what it is you're asking.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Fri Jul 17, 2009 3:26 pm
Reply with quote

I have to retrieve some data from CICS Container and convert all numeric values of cobol to Java, In such case what could be the numeric Picture clause for S9(4) comp,s9(9) comp,s9(10)V comp-3?

Thanks,
Murali.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Jul 17, 2009 3:32 pm
Reply with quote

Hi Murali,

If u had posted this as the first post it would have made our life easier... icon_razz.gif

As far as i remember about Java... the COMP variables should not be a problem coz that's how its already defined. Every numeric field will be binary only in Java ( plz do correct me if i am wrong ).

In case of the packed value, you will need to convert to the binary form and then send it.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Jul 18, 2009 7:22 pm
Reply with quote

For my application,i will get the data from Java through Containers and vice versa i will transfer data from cobol to Java.

You said for comp it's not a problem, but i am not clear about packed decimal. What should be done?

Thanks,
Murali.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Jul 18, 2009 7:35 pm
Reply with quote

In addition,

when data from COBOL to Java,

Is there any problem when data is transfered from COBOL to Java,

for example,

Java data type int is mapped to s9(9) comp of COBOL, is it possible to pass the same data from COBOL to Java data type?


Please clarify.

Thanks,
Murali.
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 Jul 18, 2009 7:42 pm
Reply with quote

PIC S9(9) COMP in COBOL is a 32-bit integer field -- if you can figure out what that is in Java, use it.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jul 19, 2009 6:56 am
Reply with quote

Hi Muali,

Maybe this wiil help:

The decimal value -1234 will have an internal memory (EBCIDIC) representaion of the following using the PICs indicated (depending on COMPILER Options) on an IBM Mainfreame :

Code:
S9(4)     COMP        X'FB2E'
S9(5)     COMP        X'FFFFFB2E'
S9(10)    COMP        X'FFFFFFFFFFFFFB2E'  ===> corrected from (9)
S9(10)V   COMP-3      X'00000001234D'
S9(5)     DISPLAY     X'F0F1F2F3D4'

You will have match the JAVA data type internal representations to these to make your decision(s).

PS. If the field value is +1234 the COMP value is X'4D2" and the "F"s in the fields would be zeros; the "D"s in the COMP-3/DISPLAY fields would be "C"s.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sun Jul 19, 2009 9:38 am
Reply with quote

Hi Jack,

I have a doubt in the example you have mentioned...
I guess the S9(9) COMP will take only 4 bytes...

Please confirm.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sun Jul 19, 2009 9:46 am
Reply with quote

Hi Murali

Quote:
You said for comp it's not a problem, but i am not clear about packed decimal. What should be done?


Could you be little more specific on how you are using the packed value. I am pretty much sure there is no packed format in Java. so in case if u are using only in mainframes it will be more like a working variable. If that's the case as I mentioned

Quote:
In case of the packed value, you will need to convert to the binary form and then send it


a simple MOVE statement from packed field to binary field should be enough
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Jul 19, 2009 2:07 pm
Reply with quote

Binop,

This is the flow of my program

I am getting the values from container and store it in working storage variable,where the ws- variables are passed to program x. and i am getting the values from program x and i am putting into container to pass the data to java application.

From you posting

Quote:

a simple MOVE statement from packed field to binary field should be enough

so for moving packed decimal s9(10)v comp-3, you are recommending to move to a comp variable(binary format) right? if so what should be the picture clause for the receiving comp variable?
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Jul 19, 2009 2:29 pm
Reply with quote

In addition,

Java is receiving the comp variables content as Character.

Thanks,
Murali.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sun Jul 19, 2009 4:09 pm
Reply with quote

Hi Murali,

As Jack as mentioned your variable of PIC S9(10)V will take 6 bytes in the mainframe environment. But there would be a dependency on how much the target system ( Java ) is expecting.

*Note : Before assisting you further I would have to tell you that my knowledge on CICS containers is minimal.... icon_wink.gif

What is the size of the specific character field ??
Are u having any idea on how the specific field is getting used ( processed ) in the target system ??
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Jul 19, 2009 4:56 pm
Reply with quote

Binop,

Java is receving comp and comp-3 variable as characters so the pic clause for s9(10)v comp-3 in Alphanumeric item could be X(06)???

Assume s9(10)v comp-3 having values 1234567891. Will X(06) accomodate the values mentioned. similaraly what could be the picture clause for s9(9) comp and s9(4) comp?

Thanks,
Murali.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sun Jul 19, 2009 5:44 pm
Reply with quote

Murali,

Quote:
Assume s9(10)v comp-3 having values 1234567891. Will X(06) accomodate the values mentioned

Yes it will

Quote:
similaraly what could be the picture clause for s9(9) comp and s9(4) comp

in character ?? as mentioned in my first post ... X(4) and X(2).
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Jul 19, 2009 5:56 pm
Reply with quote

Binop,

when i am moving the 9 digitis 1234567891 from s9(10)v comp-3 to
X(06) it will truncate the data.

Data shouldn't get truncated.

Thanks,
murali.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Sun Jul 19, 2009 6:05 pm
Reply with quote

Murali,

If you are doing a simple MOVE statement it will not work because you are basically trying to move from Numeric field to Character field. You will have to redefine the field in the Mainframe...

As mentioned before only if u give more details about the target system we will be in a position to help you better.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sun Jul 19, 2009 6:21 pm
Reply with quote

Binop,

Quote:

I am getting the values from container and store it in working storage variable,where the ws- variables are passed to program x. and i am getting the values from program x and i am putting into container to pass the data to java application.


So far i didn't get the data type for target system, but when the program is receiving from the container (Source/Target system) i am getting the values from java to COBOL ( ex. char(contains only numeric data)(java) to s9(4)comp) i am sending back the data after callin/manipulating the same variables since the requirement is to map the numeric data to char(java) i am moving the comp and comp-3 values to alphanumeric item and writting(Put container) into container.

Thanks,
Murali.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun Jul 19, 2009 6:25 pm
Reply with quote

it seems to me that the topic has shifted from an obscure question
to the equivalence beween data types in COBOL and JAVA for interoperability
see for example
publib.boulder.ibm.com/infocenter/ratdevz/v7r5/index.jsp?topic=/com.ibm.ent.cbl.zos.doc/topics/PGandLR/tasks/tpjav03.htm

or google for ( that's how I found the link) "cobol java data types zos"

if multiplatform operation is involved investigate about endian-ness for binary data types
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jul 19, 2009 8:18 pm
Reply with quote

Hi Binop,

You wrote:
Quote:
I guess the S9(9) COMP will take only 4 bytes...

You're right, I always seem to mis-recall the break point from 4 to 8 bytes. The line s/b:

S9(10) COMP X'FFFFFFFFFFFFFB2E'

I'll correct the orig post. Thanx for picking that up.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top