cancel
Showing results for 
Search instead for 
Did you mean: 

Look Up API through JCO

Former Member
0 Kudos

Hi all,

I m using look up through JCO and calling a RFC on backend R/3 for the particular validation.I m using UDF for that.In the UDF i have specified imports as:-

imports :-java.util.;java.lang.obj.;com.sap.aii.mapping.lookup.;com.sap.mw.jco.;java.io.*;

source code --

//write your code here

JCO.Repository myRepository;

// Change the logon information to your own system/user

JCO.Client myConnection = JCO.createClient(

// all the client information namely client ,user id pwd etc

myConnection.connect();

// create repository

myRepository = new JCO.Repository( "SAPLookup", myConnection );

// Create function

JCO.Function function = null;

IFunctionTemplate ft = mRepository.getFunctionTemplate("xxxxx"); //Name of RFC

function = ft.getFunction();

// Obtain parameter list for function

JCO.ParameterList input = function.getImportParameterList();

// Pass function parameters

input.setValue( a , "xxxxx" ); //import parameter of RFC, a is input argument.

myConnection.execute( function );

String ret = function.getExportParameterList().getString( "XXXX" ); //export param

myConnection.disconnect();

return ret;

}

however on test i m getting follwing error:

Source code has syntax error: D:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map6df266d0f96411dbb2a4000bcd3f5f3d/source/com/sap/xi/tf/_MM_Source_To_Target_.java:157: 'class' or 'interface' expected public static void main(String[] args) throws Exception{/!_$ClNRep_/_MM_Source_To_Target_ st = new /!_$ClNRep_/_MM_Source_To_Target_(); st.testExecute(); }

Can anybody help me out in rectifying this Syntax errror.

Regards,

AshwinM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Ashwin,

Why dont you use the standard RFC Look up API for this?

Have you see this article by Michal already.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...

Regards,

Jai Shankar

Answers (3)

Answers (3)

Former Member
0 Kudos

hi bhavesh,

Thanks for the reply...

Now consider for scneario..

1.file to file

2.ZRFC to be lookd up in the backend

3.sender1 field >UDF>receiver field...

what will be the value of variable "m" mentiond in blog recommended for RFC API Mapping LookUp..ie" String m =......" // payload to be filled through RFC XML

Regards,

Ashwin M

bhavesh_kantilal
Active Contributor
0 Kudos

Ashwin,

This will be your Request RFC in XML format.

Import the RFC in XI, use it in some dummy mapping, fillin the request parameters in the TEST tab of your mappinga nd you will get the XML of the RFC request. Now use this in your UDF. Ofcourse the parameters need to be passed as inputs to the UDF and need to be appeneded to the RFC request XML string.

Regards

Bhavesh

Former Member
0 Kudos

hi all,

Thanks for the quick reply...

However whats the error with the source code of UDF through the JCO ...also when u use RFC API u need use RFC adapter which i dont want...I would prefer to use JCO unless there is ne Performance issue...

Kindly correct me on Syntax error..."what interface or Class is expected"

Regards,

AshwinM

Message was edited by:

Ashwin M

bhavesh_kantilal
Active Contributor
0 Kudos

You are hardcoding the user id , password etc in your UDF. This is something will cause issues asyou move your objects across environments from Dev to Qaulity and production.

You cannot change the user id and passwordi n your mapping code in your Quality and Prodction. Use of RFC Lookup is strongly recommended with the RFC adapter.

I dont think using RFC Lookup API causes any perfromance degradations. We have used this feature multiple times in and have never faced performance constraints as a result of this.

Regards

Bhavesh

MichalKrawczyk
Active Contributor
0 Kudos

hi,

don't use this way as you will have to hardcode

pass client, user etc...

use RFC API instead

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>