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

How to Pass data types int, float to commarea from java


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

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Mon Sep 17, 2007 12:38 pm
Reply with quote

We are using the ECIRequest base class to interface with commarea cobol/cics programs.
In java we are using getbyte method to pass the data to commarea.
At present the data that gets passed to commarea from java goes as string.
But i need to pass an integer and decimal type datas to cics programs...
would like to know how to do this.
Currently it works if we do conversion of int to string and pass it to cobol..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Sep 17, 2007 12:44 pm
Reply with quote

Hello,

Where is the java code running?
Back to top
View user's profile Send private message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Mon Sep 17, 2007 2:00 pm
Reply with quote

Java code will be running on windows environment using cics transaction gateway we will be interfacing with the commarea .
for java ibm has provided a base classes to pass the data to commarea.
ECIrequest is the base class method that we are using.
The sample code
import com.ibm.ctg.client.JavaGateway;
import com.ibm.ctg.client.ECIRequest;
import java.io.IOException;
public class EciTest02
{
public static void main(String args[]) throws IOException
{
System.out.println("Test for Gateway");
try {
JavaGateway jg= new JavaGateway("localhost:",2006);
byte commarea[]=("-------------------------------------------------------------------").getBytes("IBM037");
// byte commarea[]=("02.0002.0000.00").getBytes("IBM037");
ECIRequest req= new ECIRequest(ECIRequest.ECI_SYNC,//sync or async
"CICS1",//cics Server Name
"dsrm022",// user id
"dsrm022",// password
"M22AP01",// program name
"M22I",// transaction idc
commarea, commarea.length,//commarea data & length
ECIRequest.ECI_NO_EXTEND,//extended mode
ECIRequest.ECI_LUW_NEW); //LUW token

System.out.println("ECIREQUEST");
System.out.println("Comm in: " + new String(req.Commarea, "IBM037"));
jg.flow(req);
System.out.println("Comm out: " + new String(req.Commarea, "IBM037"));
System.out.println("Rc: " + req.getRc());
jg.close();
}catch (IOException ioe)
{
System.out.println("Handled exception: " + ioe.toString());
}
}
}
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 17, 2007 2:51 pm
Reply with quote

If the data is going to be translated enroute, you can't use packed decimal, binary or float types, only character...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Sep 17, 2007 6:20 pm
Reply with quote

Hello,

Stay with the string. Windows does not play well with mainframe "internal" numerics.
Back to top
View user's profile Send private message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Tue Sep 18, 2007 4:18 pm
Reply with quote

I am interfacing with dfhcommarea from my java client program running on windows.
From windows java client i need to pass a float to cobol dfhcommarea.
But currently it passes to cobol only as a string.
The problem we have is with decimal and comp values defined in commarea in cobol..
Any suggesstions appreciated...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Sep 18, 2007 8:36 pm
Reply with quote

Hello,

As has already been posted - if you are running on a Windows machine, your best way is to use the string.

You will probably spend a lot of time trying to get the desktop to prepare mainframe "numerics".

Change the existing mainframe code to use the string. If you really don't want to change the existing code, I'd suggest a new bit of mainframe code to take the string from java and change it (on the mainframe) to whatever format(s) you need - then pass it on to the existing code.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Sep 21, 2007 10:48 pm
Reply with quote

Quote:
From windows java client i need to pass a float to cobol dfhcommarea


carrying on floating point operations on different platform is, using a light term, like opening a can of worms ( IEEE standards and so on )

I would rather rely on a common set of functions/classes which would give consistent results on different platforms

check this url
http://www2.hursley.ibm.com/decimal/

regards

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

Moderator Emeritus


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

PostPosted: Fri Sep 21, 2007 11:29 pm
Reply with quote

Hi Enrico,

Excellent link - thanks for posting it icon_smile.gif

d
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Tue Sep 25, 2007 12:57 pm
Reply with quote

Am new to this forum, i got the given site above which helped me a lot, thank you very much to Enrico.

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

Moderator Emeritus


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

PostPosted: Tue Sep 25, 2007 6:29 pm
Reply with quote

Hello Vasanth and welcome to the forums.

Enjoy your time here and look around. There are many helpful items posted.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Wed Sep 26, 2007 10:31 am
Reply with quote

as i seen for every character there is an equivalent EBCIDIC code convert it into binary and then to decimal format. and then move it to DFHCOMMAREA will work normally. I tried and it is working still i need tuning in my code.


Have a great day
Vasanth... icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Sep 26, 2007 10:06 pm
Reply with quote

Hello Vasanth,

Thank you for posting your progress icon_smile.gif

We're here if there are any new "opportunities".
Back to top
View user's profile Send private message
ramco_sita

New User


Joined: 25 Jun 2007
Posts: 40
Location: chennai

PostPosted: Thu Sep 27, 2007 10:35 am
Reply with quote

Java is able to pass only as a string thru ECIRequest. We have to handle this in the cobol code.
in cobol we capture it as an alphanumeric and then move that to a working storage variable which is numeric and for calculation we made it as a comp-3 field and after calculation we pass it back to the commarea field which will put decimal point and send it to the java client program.

We solved this problem and it works fine both in java client and in cobol.
Working storage section:
01 ws-decimal Pic 9(5)v9(2) usage comp-3.
01 ws-dec-no redefines ws-decimal.
05 ws-rs pic 9(5).
05 ws-p pic 9(2).

Linkage Section:
01 Dfhcommarea.
01 WS-Decimal-no .
05 ws-Rupees pic x(5).
05 ws-dot pic x(01) value ‘.’.
05 ws-paise pic x(2).

In the code we have to move it individually from ws-Rupees to ws-rs and move ws-paise to ws-p. Comp-3 is a packed decimal which is used for any calculations. For this decimal handling it involves additional coding in COBOL.

thanks for your help
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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top