Mod function in java
Hello everybody, I need help on mod fuction in java, but I don't know how can I use it, if you know how use it, please give a little example...thanks..
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arithmetic.html
Similar Messages
-
Any Mod function in JAVA?
I did not find 'MOD' function in the Math class. Is there any 'MOD' function in Java?
Thanks!What is your MOD function?
Does the %-operator do what you need or do you want a strict mathematical modulus that returns only positive values? -
User defined function in java for message mapping
I wrote the following user defined function in java for message mapping and mapped vendor with this. The aim of this function is to write a error file at defined path when i send empty Vendor value from File to RFC-Function module BAPI_PO_CREATE. The "err.txt" error file is not written when i execute in TEST but the value "ERROR" is returned to destination Vendor Field.
public String validation(String a, Container container) {
//write your code here
if (a.equals("")) {
try {
String source = "Vendor cannot be empty";
char buffer[] = new char[source.length()];
source.getChars(0, source.length(), buffer, 0);
for (int i = 0; i < buffer.length; i +=2)
f0.write(buffer<i>);
f0.close();
FileWriter f1 = new FileWriter("/10.10.0.55/sapmnt/trans/edixiin/err.txt");
f1.write(buffer);
f1.close();
catch (IOException e) {}
return "ERROR";Hi Senthil,
Check these things :
1) Whether you have permission to create a file in that directory.
2) try giving this
10.10.0.55
sapmnt
trans
edixiin
err.txt
3) Also check for permissions.
Hope this will help you.
Regards
Suraj -
Writing message mapping function in Java in integration repository
Hi XI Pundits,
I am new to XI. I was working on Message mapping in intergration repository.
To map the source messages to target messages, we do graphical kind of mapping like drag and drop.
There are some functions aavilable at the bottom like concatehate, trim and etc. which we use if we need to modify the source message and map to target.
But in case we face a situation when we don't find the function which suits our requirement, I guess we need to write a new function. We can write these new function using Java only.
Can someone throw some light on this ?
<b>What do we do to invoke java editor in integartion reposity to write mapping function in java ?
Can someone give an example of snippet of code ?</b>
Thanks.Hi Tushar,
Go thro this help link. You will get all info about User defined function.
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
To get more understanding on mapping go thro this link(PDF File)
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb5e89a6638
Hope this helps.
regards,
P.Venkat
Message was edited by: Venkataramanan -
Subpartition with MOD Function in Oracle 11g
Hi All,
Can we create Subpartition based on MOD Function in Oracle 11g ?Hi!
What are you refering with "MTS"? Anybody knows a term like this (except MultiThreaded Server). -
Mod function in LabView's Configure Formula
Hello, all. Today is my first shot at using the Configure Formula feature in LabVIEW (7.1), and I'm not doing well at it.
The kicker seems to be my (mis)understanding of the mod function.
Here's the formula I have to work with:
J=1+(((((C/100)%4)*5)+G)%7), whereduplicate post, see: http://forums.ni.com/ni/board/message?board.id=170&message.id=161086
LabVIEW Champion . Do more with less code and in less time . -
Can we call java function in java script????
hello
please tell me can i call a java function through java script function in jsp???of course not. JavaScript is interpreted by the client (web browser) while the Java code in a JSP resides on the server. don't confuse the web application's architecture.
robert -
FM call from Variant Function in JAVA SCE
Hello,
I have an issue with Variant Configuration in CRM WEB UI / WebShops.
We have created a variant function in ECC to read/pull a customer master value (KNVV table). This is working fine in ECC & got the desired result.
Now we need replicate the same in CRM. For this we need to create KB, Version & write a variant function in Java class in SCE. In that variant function we need to call a function module and get the customer master / Business partner value as similar to ECC process described above.
But we see that the SAP standard is not supporting FM calls from VF in Java. i.e. we are unable to call the JCO call to a CRM function module from SCE. The package for User defined classes "com.sap.sce.user" and the method inside it public boolean execute(fn_args args, Object obj) { ..... } has no option to make a FM call.
Has anyone faced the similar requirement and has any resolution for this?
Thanks,
Surya.Hi Eric,
You sound quite familiar with the variant functions. I am also working on IPC-SCE
variant functions for few years now.
We have a situation where I am building some debug logs in one java variant function and want to display it to the web UI at some condition.
Is there any object(like context etc.) that IPC server-side and Webapps share?
I can write that log to a text file and read it from web ui ... but I wanna avoid that.
Is there any other way you know of???
Regards,
Ruchika -
How to access C/C++ functions in Java using existing .dll library
Hi JNI Guru's,
I am having well written API in C/C++.This C/C++ files are made into *.dll files.The api are working fine.
I wan't access the C/C++ api functions in Java., just using System.LoadLibrary("*.dll").Is it possible.I kindly request you to suggest some examples and how to do this.
Its Urgent !.
Thanks and Regards,
V K LALIn general you cannot simply access dlls that have already been written. The DLLs called using JNI must conform to JNI calling standards.
This means you will probably have to write one or more "wrapper" dlls which a) provide the correct JNI interface, and b) call the existing dlls.
There are some programs around that claim to be able to generate such wrappers. Try a google search for "wrapper", "jni", "generate".
The JNI tutorial covers creating wrappers. -
How do I call c functions from java?
See http://java.sun.com/docs/books/tutorial/native1.1/index.html
-
Calling a SP or Function from Java receiving a geometry(MDSYS.SDO_GEOMETRY)
Hi there,
What I want to do is: calling a stored procedure OR function from Java with a String-variable as input and receiving a geometry (SDO_GEOMETRY).
I’m facing currently the problem of calling a stored function on oracle 11g from Java using JPA (EclipseLink), Spring 2.5.6 returning an MDSYS.SDO_GEOMETRY object.
I’ve tried to call a stored procedure with MDSYS.SDO_GEOMETRY as an output parameter instead, but with no success.
The function’s signature looks like this:
CREATE or REPLACE
FUNCTION GET_GEO_BRD_FUNCTION(p_geo_brd_id IN VARCHAR2) RETURN MDSYS.SDO_GEOMETRY AS
sdo_geom MDSYS.SDO_GEOMETRY := null;
BEGIN
/* do some fancy stuff on the database side */
SELECT sp_geom
INTO sdo_geom
FROM geo_brd WHERE id = p_geo_brd_id;
RETURN sdo_geom;
END;
The calling code looks like this:
MyClass extends JpaDaoSupport{
/** logger */
protected static final ILogger LOG = LogFactory.getLogger(MyClass.class);
* {@inheritDoc}
* @see com.example.MyClass#calculateGeometry(java.lang.String)
@Override
public JGeometry calculateGeometry(final String id) {
JGeometry geometry = null;
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
final StoredFunctionCall functionCall = new StoredFunctionCall();
functionCall.setProcedureName("GET_GEO_BRD_FUNCTION");
functionCall.addNamedArgument("p_geo_brd_id");
functionCall.setResult("sdo_geom", Oracle.sql.STRUCT.class);
final ValueReadQuery query = new ValueReadQuery();
query.setCall(functionCall);
query.addArgument("p_geo_brd_id");
final ArrayList args = new ArrayList();
args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
final Object result = session.executeQuery(query, args);
return result;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
try {
geometry = JGeometry.load(result);
} catch (final SQLException e) {
MyClass.LOG.error("Error loading JGeometry from STRUCT.", e);
return null;
return geometry;
And when I execute the query I get the following error:
Internal Exception: java.sql.SQLException: ORA-06550: Row 1, Column 13:
PLS-00382: expression is of wrong type
ORA-06550: Row 1, Column 7:
PL/SQL: Statement ignored
Error Code: 6550
Call: BEGIN ? := GET_GEO_BRD_FUNCTION(p_geo_brd_id=>?); END;
bind => [=> sdo_geom, 2e531e62-2105-4522-978a-ab8baf19e273]
Query: ValueReadQuery()
So I thought may be let's try it with a stored procedure instead...
The procedure looks like this:
CREATE or REPLACE
PROCEDURE GET_GEO_BRD_PROCEDURE(p_geo_brd_id IN VARCHAR2, sdo_geom OUT MDSYS.SDO_GEOMETRY) AS
BEGIN
/* do some fancy stuff on the database side */
SELECT sp_geom
INTO sdo_geom
from geo_brd where id = p_geo_brd_id;
END;
The calling Java code in case of the stored procedure looks like this (only the content of the JPACallback has changed):
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
final StoredProcedureCall spCall = new StoredProcedureCall();
spCall.setProcedureName("GET_GEO_BRD_PROCEDURE");
spCall.addNamedArgument("p_geo_brd_id", "p_geo_brd_id", String.class);
spCall.addNamedOutputArgument("sdo_geom", "sdo_geom", OracleTypes.STRUCT);
final ValueReadQuery query = new ValueReadQuery();
query.setCall(spCall);
query.addArgument("p_geo_brd_id"); // input
final List args = new ArrayList();
args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
final Object result = session.executeQuery(query, args);
return result;
And when I execute the query I get the following error:
java.sql.SQLException: ORA-06550: Row 1, Column 13:
PLS-00306: wrong number or types of arguments in call to 'GET_GEO_BRD_PROCEDURE'
ORA-06550: Row 1, Column 7:
PL/SQL: Statement ignored
So both exceptions look quite similar.
I guess in both cases the exception description leads to the assumption, that the wrong type for the return value / output parameter is used…
So - how can a receive a MDSYS_SDO_GEOMETRY object from a stored procedure or stored function in Java ?
What is wrong in the Java code?
Thank you in advance for any suggestions!
Yours,
Chris
Edited by: user3938161 on 20.12.2011 07:46
Edited by: user3938161 on Dec 20, 2011 8:06 AM: added variable declaration of JGeometry geometry in source codeThanks, that did the trick! ;-)
Here is now the code for stored procedure and function for anybody else encountering the same troubles... (be aware of the parameter order and/or naming!)
Code for stored functions:
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
* Using CallableStatement for stored functions
STRUCT st = null;
CallableStatement cs = null;
final DatabaseLogin login = session.getLogin();
final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
try {
try {
cs = _conn.prepareCall("{? = call GET_GEO_BRD_FUNCTION(?)}");
cs.registerOutParameter(1, OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
cs.setString(2, "2e531e62-2105-4522-978a-ab8baf19e273");//TODO: hardcoded for test
cs.execute();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured calling the stored procedure", e);
if (cs != null) {
//reading geometry from the database
try {
st = (STRUCT) cs.getObject(1);
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
} finally {
try {
if (_conn != null && !_conn.isClosed()) {
_conn.close();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured on closing the database connection.", e);
return st;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
The code for stored procedure solution:
final JpaCallback action = new JpaCallback() {
@Override
public Object doInJpa(final EntityManager em) throws PersistenceException {
final Session session = JpaHelper.getEntityManager(em).getActiveSession();
* Using CallableStatement for stored procedure
STRUCT st = null;
CallableStatement cs = null;
final DatabaseLogin login = session.getLogin();
final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
try {
try {
cs = _conn.prepareCall("{call GET_GEO_BRD_PROCEDURE(?,?)}");
cs.setString("p_geo_brd_id", "2e531e62-2105-4522-978a-ab8baf19e273");
cs.registerOutParameter("sdo_geom", OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
cs.execute();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured calling the stored procedure", e);
if (cs != null) {
//reading geometry from the database
try {
st = (STRUCT) cs.getObject("sdo_geom");
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
} finally {
try {
if (_conn != null && !_conn.isClosed()) {
_conn.close();
} catch (final SQLException e) {
MyClass.LOG.error("An exception occured on closing the database connection.", e);
return st;
final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action); -
Using the Safe Mode function on your PlayStation 3?
i followed the steps it works fine then when i sign in within a afew seconds it cuts off and gets a red flashing light again i dont know what to do :/
RabidWalker wrote:
Using the Safe Mode function on your PlayStation 3?
Safe Mode:
The option to use Safe Mode on the PlayStation 3 was introduced if a problem occurs where it will no longer start up normally.
To use this feature the console will need to have the System Software update 2.60 (or later).
When to Use Safe Mode?
When starting up the PlayStation 3, and the XMB menu no longer appears (you may see a wavy line on the background instead).
When the PlayStation 3 is started up, nothing appears on screen.
When the PlayStation 3 is started up and you encounter the following message ‘The Hard disk’s file system is corrupted and will be restored’. When selecting ‘OK’ the system restores and restarts, however the same message appears.
When the PlayStation 3 is started up and you encounter the following message ‘The Hard disk’s database will be rebuilt’. When selecting ‘OK’ the system begins the operation and then fails (stopping the restoration of the HDD).
There is an issue after the PlayStation 3 update process is started, or a rebuilding of the database occurs.
Safe Mode procedure:
1) Ensure the PlayStation 3 is in standby mode (where the red light is apparent), and then turn the console off at the mains switch.
2) Turn the mains power on, then while in standby touch and hold the power button.
3) Keep your finger pressed on the power button (after 5 seconds you will hear a beep).
4) After 10 seconds of holding your finger on the power button, you will hear a second beep and the console will shut down (you can remove your finger).
5) Touch and hold the power button again.
6) Again hold your finger down on the button until you hear another beep after 5 seconds.
7) A number of seconds after this you will hear a double beep- you can remove your finger.
8) You will be prompted to plug your controller in and press the PS button on your controller. After doing so you will access the Safe Mode menu with a number of options.
Safe Mode Option Screen:
Restart System
Selecting this option will start up the system normally- It will also allow you to exit the Safe Mode Menu.
Restore Default Settings
Selecting this option will restore Default settings on your console (when starting the unit you will be prompted to set time, time zone etc). This option will also delete your PlayStation Network account information from the system.
Your User information will be deleted and restored- the indicator will be an asterix by your username e.g. *RabidWalker.
When logging into your user you will encounter no issues with disc based games. However when attempting to play PSN downloaded games you may encounter the message:
‘To access the system, you must activate the system.
Go to [PlayStation Network] > [Account Management] to activate this system. (80029514). ’
Follow the instruction to activate your PlayStation 3 to play downloaded games (if the system is activated, deactivate and reactivate the system)
Restore File System
This option will begin a process to repair data on your Hard Disk Drive. Therefore it will check for any corrupted data and try and recover this. It the data cannot be recovered it may be erased to ensure that it does not interfere with the operation of the PlayStation 3.
Rebuild Database
If issues continue to persist and you select this option please note that data will be removed during this process.
The following information will removed:
- Messages
- Playlists
- User changes to Information Screens
- User changes to Picture under Photos
- Video Thumbnails
- Video Playback History
- Video Resume Information
This process may take same time to complete
Restore PS3 System
The option to restore PS3 system is the same as the ‘quick format’ option on the XMB menu. It will reformat the HDD, removing all data and restoring the Hard drive to its original state.
System Update
Selecting this option will install the PlayStation 3 Update but only if the update is on an external media storage device plugged into the console.
This option can be used if any issues are encountered with the installation of the System software update.
If you have any queries regarding this or any other issues please PM me or catch me on Twitter
@RabidWalker
Rabid
-
MOD() function - incorrect output
The following bit of SQL uses the mod() function to determine modulus 2 of two large numbers
13:37:20 SQL>set echo on
13:37:24 SQL>@mod_test
13:37:25 SQL>
13:37:25 SQL>
13:37:25 SQL>
13:37:25 SQL>select mod(power(2,127)-1,2) from dual
13:37:25 2 /
MOD(POWER(2,127)-1,2)
1
1 row selected.
13:37:25 SQL>
13:37:25 SQL>select mod(power(2,128)-1,2) from dual
13:37:25 2 /
MOD(POWER(2,128)-1,2)
-1
1 row selected.
13:37:25 SQL>
Notice that mod(power(2,128)-1,2) returns an incorrect answer, while the
answer for mod(power(2,127)-1,2) is correct.
Does someone here know why?
Is it a limit?
Or is it a bug?
Please supply an explanation and/or URL for your answer. :)Must be due to the fact the scale for a NUMBER can range from -84 to 127, and Floating Point Number Limits are:
Value Binary-Float Binary-Double
Maximum positive finite value 3.40282E+38F 1.79769313486231E+308
Minimum positive finite value 1.17549E-38F 2.22507485850720E-308 -
hi,
i am trying to commit for every 1000 records.
how to use mod function in following script?
DECLARE
v NUMBER;
counter NUMBER;
CURSOR r1 IS SELECT * FROM TAB1;
BEGIN
FOR c1 IN r1 LOOP
v:=c1.ssn_id;
counter := counter + 1;
IF MOD(counter,1000 ) = 0 THEN
dbms_output.put_line(v);
commit;
dbms_output.put_line(counter);
counter := 0;
END IF;
END LOOP;
END;
could anyone help me for commiting every 1000th record.
thanks in Advance.The only problem I see, is you did not initialize COUNTER.
if you have counter := counter + 1; without initializing COUNTER, it is like adding NULL + 1 and this will always result in NULL
declare
cursor c1 is select ssn from TAB ;
v_cnt number:=0; -- NOTE YOU MUST INITIALIZE TO SOME NUMBER
begin
for c_rec in c1 loop
v_cnt := v_cnt + 1;
if mod(v_cnt,1000) = 0 then
dbms_output.put_line('SSN: '||C_REC.SSN) ;
dbms_output.put_line('v_cnt: '||v_cnt||' time to commit');
end if;
end loop;
end;
/ -
OWB10GR2 - Error when try to use 'MOD' function in an Expression
Hi
I'm trying to use the MOD function in an expression, e.g. mod(44,12), however, when I validate I get the error:-
Line 2, Col 18:
PLS-00201: identifier 'MOD' must be declared
Line 0, Col 1:
PL/SQL: Statement ignored
Has anyone else come across this problem, and can anyone please suggest a solution?
Thanks
GBNot yet, thanks for the suggestion.
If you use MOD in an expression or Constant, the expression does not validate but the mapping itself does validate, deploy and runs ok. So
This issue has been reported as a bug therefore for the time being we can just ignore the expression validation message.
Maybe you are looking for
-
Help please... I was given a new I phone 5S and realized I would loose all my information on my phone, so I turned on I cloud and it told me I needed a "outlook" email address which I set up. Now I have 2 email addresses but it won't acknowledge my
-
Regarding downlaod the output from ALV grid format
Hi i want to download the output ALV grid format into excel sheet . but condition is when ever user press the button (&ZDL) the should be downloaded. and also how to convert the output into CSV format.
-
Output lenght in ALV with FM REUSE_ALV_GRID_DISPLAY
Hi people! I need some help! I trying to set output lenght of a field to better view. I used in fieldcatalog OUTPUTLEN and set it to 50, but doesn't work... Anyone can give me a tip? Thanks! i = i + 5. CLEAR ltype_fieldcat. ltype_fieldcat-col_p
-
Mac OS X Leopard on a third party laptop ?
i have an HP laptop intel core 2 duo 2.20 2 GB ram 150 GB hard drive intel graphics card can i remove windows xp and install leopard on it ? Message was edited by: PandaJin
-
Auto play quicktime movies when you open website
hi everyone, i have been trying to make autoplay quictime movies in to my websites, i dont want people to click on the play button in order to watch them, the next ones are some emails that i have with a great guy using iweb but i dont really underst