cancel
Showing results for 
Search instead for 
Did you mean: 

Java Beginner need Help(numbers on java hand over, calc and return to sap)

Former Member
0 Kudos

Hi @all!

I have a new Question.

I am Beginner and would like two numbers handed on java over functional module, count on to let and sap return on.

The JCO server is furnished, always gets as result 0.

Here my beginning code:

<b>Function Module:</b>

CALL FUNCTION 'Z_TEST' destination 'JAVARFC'
  EXPORTING
    f1      = f1
    f2      = f2
  IMPORTING
    p       = p
    .

<b>Bean.java</b>

public void processFunction(JCO.Function function) {
		try {
			JCO.ParameterList input = function.getImportParameterList();
			JCO.ParameterList output = function.getExportParameterList();
			JCO.ParameterList tables = function.getTableParameterList();

			if (function.getName().equals("Z_TEST")) {

				input.setValue(input.getString("f1"), "f1");
				input.setValue(input.getString("f2"), "f2");

.

.

.

and now? as it continues and is correct that?

thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi!

thanks for your help.

@franz

the result in sap is always null.

what can be?

the source code is correct.

my fuction module in sap:


FUNCTION Z_TEST.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(F1) TYPE  INT4
*"     VALUE(F2) TYPE  INT4
*"  EXPORTING
*"     VALUE(P) TYPE  INT4
*"----------------------------------------------------------------------


ENDFUNCTION.

Former Member
0 Kudos

try parameter names uppercase ("F1", "F2" ...) in java coding

regards

franz

Former Member
0 Kudos

hi!

It don't work. p is always 0.

Must I parse p in output or must I parse f1 and f2 back? How?

Here again my code:

<b>Function Module:</b>


FUNCTION Z_TEST.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(F1) TYPE  INT4
*"     VALUE(F2) TYPE  INT4
*"  EXPORTING
*"     VALUE(P) TYPE  INT4
*"----------------------------------------------------------------------
ENDFUNCTION.

<b>ABAP</b>


REPORT  zdk_test03.

DATA: P TYPE i.

PARAMETERS: F1 TYPE i,
            F2 TYPE i.

CALL FUNCTION 'Z_TEST' DESTINATION 'JAVARFC'
  EXPORTING
    F1 = F1
    F2 = F1
  IMPORTING
    P  = P.

WRITE P.

<b>Java</b>


public void processFunction(JCO.Function function) {
		try {
			JCO.ParameterList input = function.getImportParameterList();
			JCO.ParameterList output = function.getExportParameterList();
			JCO.ParameterList tables = function.getTableParameterList();

			function.getName().equals("Z_TEST");

			int f1 = Integer.parseInt (input.getString("F1"));
			int f2 = Integer.parseInt (input.getString("F2"));
			
				output.setValue(f1+f2,"P");

		} catch (java.lang.Exception e) {
			e.printStackTrace();
		}
	}

Thanks in Advance

Former Member
0 Kudos

Does someone have an idea? Need help...

Former Member
0 Kudos

maybe you should set the parameters in your abap program too!!

f1 = 5.

f2 = 10.

Former Member
0 Kudos

Yes, already with fixed values tried. Always 0.

I'm not a Repository on Javaside, is this correct?

Perhaps it is because of it.

Message was edited by:

Denis Kühne

Former Member
0 Kudos

Hello

try only with this in java code

output.setValue(150,"P");

then deploy and test again, if the result is not 150 (also test with debugger in SAP) than something is wrong with your deployment (Wrong JNDI Name, failed deployment, .....)

regards franz

Former Member
0 Kudos

It works fine.

Take with the RFC connection(FunctionModule)...char(firm lengthens)....yes

Thanks for your help

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello

what about this



public void processFunction(JCO.Function function) {
   JCO.ParameterList input = function.getImportParameterList();
   JCO.ParameterList output = function.getExportParameterList();
   JCO.ParameterList tables = function.getTableParameterList();
   
   int f1 = Integer.parseInt (input.getString("f1));
   int f2 = Integer.parseInt (input.getString("f2));
   
   output.setValue (f1+f2,"p");
   ....

regards franz

reward points if useful

Former Member
0 Kudos

Hi Denis,

I did someting with a JCO Server, in that time i remember that i have some problems with de input parameter to pass to the remote function, the problem is that you have to cast this variables. For example:

input.setValue ( (String) input.getSring("f1"), "f1" );

Good luck

if help you, regards

Joshua