on 01-15-2008 9:58 PM
I'm trying to create a function in XI Message Mapping that saves some information in a XI DB table using JCO.
I've created DB table ZEDI with Fields A,B,C,D. My function is following:
imports:java.lang.String;java.io.ByteArrayInputStream;java.io.InputStream;com.sap.mw.jco.*;
public String WriteTable(String ISA,String GS,Container container){
//write your code here
String DBTABLE = "ZEDI";
String sapClient = "200";
String hostName = "10.1.10.81";
String systemNumber = "00";
String userName = "DBuser";
String password = "DBpass";
String language = "EN";
int i = 0;
JCO.Repository mRepository;
JCO.Client mConnection = JCO.createClient(
sapClient,
userName,
password,
language,
hostName,
systemNumber );
// connect to SAP
mConnection.connect();
// create repository
mRepository = new JCO.Repository( "GenericLookup", mConnection );
// create function template to select data from any table
JCO.Function function = null;
IFunctionTemplate ft = mRepository.getFunctionTemplate("ZEDI");
function = ft.getFunction();
//JCO.ParameterList lookupFieldPos = function.getImportParameterList();
JCO.Table FieldPos = function.getTableParameterList().getTable("ZEDI");
// Pass function parameters
FieldPos.setValue(ISA,"A");
FieldPos.setValue(GS,"B");
mConnection.execute(function );
mConnection.disconnect();
return ISA;
Message Mapping test returns Exception:[java.lang.NullPointerException].
Do you have any idea what do I need to change to make it working?
Thanks!
Naycho
Hi Naycho
You have created a SAP table, but you have to create ABAP Function Module (RFC) with import /export parameters to access tables via JCO.
The null pointer exception is because - IFunctionTemplate ft = mRepository.getFunctionTemplate("ZEDI");
is searching for a function not table name.
hope this helps
Regards
Prahllad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've decided to to use ABAP function in XI for DB calls.
So I just need to popule function parameters from my message mapping.
Thanks for your help here.
Regards
Naycho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My mapping is working fine without this function.
Is JDBC better option?
Regards
Naycho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>>Is JDBC better option?
Definitely. It is the approach recommended by SAP.
Some reason behind this is you dont need to hard code user id, pwd in the UDF. You can feel the advantage of this when you transport the objects to QA and then to Prod. JDBC lookups internally uses JCO, but since it is designed by SAP it can be a better option in terms of performance.
Regards,
Jai Shankar
Hi Stoitsov,
Just to make sure that the null pointer exception is coming for this field only just disable the target field whereever you using in your mapping and give a try once again and see whether you have the same error or not.
Also I would suggest to make a JDBC lookup directly instead of JCO.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.