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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to Pass data types int, float to commarea from java
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

Site Director


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

PostPosted: Mon Sep 17, 2007 12:44 pm    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Mon Sep 17, 2007 2:51 pm    Post subject:
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

Site Director


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

PostPosted: Mon Sep 17, 2007 6:20 pm    Post subject:
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    Post subject: DFHCOMMAREA interface from JAVa client program
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

Site Director


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

PostPosted: Tue Sep 18, 2007 8:36 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Fri Sep 21, 2007 10:48 pm    Post subject: Reply to: How to Pass data types int, float to commarea from
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

Site Director


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

PostPosted: Fri Sep 21, 2007 11:29 pm    Post subject: Reply to: How to Pass data types int, float to commarea from
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: 276
Location: Bang,iflex

PostPosted: Tue Sep 25, 2007 12:57 pm    Post subject: Hi Enrico,
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

Site Director


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

PostPosted: Tue Sep 25, 2007 6:29 pm    Post subject:
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: 276
Location: Bang,iflex

PostPosted: Wed Sep 26, 2007 10:31 am    Post subject: Hi all
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

Site Director


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

PostPosted: Wed Sep 26, 2007 10:06 pm    Post subject:
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    Post subject:
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    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 Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm
No new posts COMMAREA and CHANNELS menonkiran CICS 4 Tue Apr 04, 2017 8:14 am


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