Skip to Content
0
Former Member
Jan 15, 2008 at 09:58 PM

JCO from Message Mapping in XI

28 Views

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