JCO from Message Mapping in XI

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

Similar Messages

  • Data lookup in R/3 database from message mapping

    Hi,
    I am trying to lookup R/3 database from Message mapping.
    Instead of creating Java class outside XI and then importing into Integration Repository, I have defined an advanced function in message mapping and trying to connect to R/3 using JCo API. But System is giving syntax errors as listed below:
    Check Result for Object CustomerDetailsMap Source code has syntax error:
    F:/usr/sap/C03/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc1513850c14511d985d5001143eb68b9/source/com/sap/xi/tf/_CustomerDetailsMap_.java:58: illegal character: 160 Â Â Â Â Â Â Â Â // Change the logon information to your own system/user
    F:/usr/sap/C03/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc1513850c14511d985d5001143eb68b9/source/com/sap/xi/tf/_CustomerDetailsMap_.java:60: illegal character: 160             "DEV18" ,    // userid
    Can somebody help in rectifying the problem?
    Thanks and Regards,
    Nitin.

    Hi,
    can u post the java code which u have used in mapping.
    There is a doc in XI-Articles. "How to Perform SAP Data Lookups Within XI Mappings" By Jerome Delune 16 October, 2003. Try looking at this article and do ur mapping.
    Hope this helps you.
    Cheers,
    Siva Maranani.

  • How to set EXPORT parameter from message mapping

    Again, ask the question of export parameter.
    I wrote a java version transformation and it worked good with export parameter.
    However I can not work it out in graphical message mapping. I refered http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm.
    In PI7.1, I add an export parameter "EXPORT_PARA" in the "Signature" tab. Are there any special step to assign this parameter to an UDF? I did not find a way to do it.
    And then I define an UDF,
    public String SetExportPara(String sss, Container container) throws StreamTransformationException{
    String str = "GOOD";
    GlobalContainer gc = container.getGlobalContainer();
    OutputParameters paras= gc.getOutputParameters();
    if(paras.exists("EXPORT_PARA ") == true) {
    paras.setString("EXPORT_PARA ", str);
    }else {
    str = "NOT FOUND EXPORT_PARA";
    return str;
    And I assign this UDF to one element of my output XML, I tried to run it in IE, it always output "NOT FOUND EXPORT_PARA.
    why?????
    I know there is a blog : https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/8654. [original link is broken] [original link is broken] [original link is broken]
    But it did not talk how to set export parameters.

    Hi,
    i read thread
    How to export parameters from Message Mapping
    and blog
    /people/jin.shin/blog/2008/02/14/sap-pi-71-mapping-enhancements-series-parameterized-message-mappings
    but not found issue
    in this topic
    http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm.
    if i writting this code in UDF, i getting an error.
    If use this code:
    GlobalContainer gc = container.getGlobalContainer();
    OutputParameters paras= gc.getOutputParameters();
    paras.setString("EXPORT_PARA ", str);
    the export parameter is defined locally (in transformation step area). In integration process area parameter is equal to NULL.
    How send export parameter to Integration Process? For exapmple, i wanna send parameter to other transformation step in my integration process.
    thx.

  • Error exporting XIM file from message mapping

    Hi.
    We are trying to export XIM files from message mapping with CTRL + SHIFT + 0 but is not working. Iu2019ve tried to solve it with this link:
    [http://support.microsoft.com/kb/967893]
    but is still not working.
    We are with SAP PI 7.11 SP 07. Is there any SP level prerequisite to be able to export message mappings in xim files?
    Thanks a lot.
    Edited by: Christian  Abad Chico on Feb 28, 2012 11:15 AM

    I think you can't use 1.4 in SAP PI 7.1.
    I've downlaned the JDK 5 and I've associated it to enviroment variables PATH and JAVA_PATH but the application is still opening with JAVA 6.....
    Any idea?
    Regards.
    Edited by: Christian  Abad Chico on Feb 28, 2012 1:18 PM
    Edited by: Christian  Abad Chico on Feb 28, 2012 1:19 PM

  • Use exported parameter from message mapping (via UDF) in next mapping prog

    Is there any chance to assign an exported parameter from one message mapping to another mapping program within an operation mapping?

    Hi,
    Try using  dynamic configuration
    1. Set value in message mapping and
    2. Get value in java mapping
    Refer this link http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
    Regards
    Suraj

  • How to export parameters from Message Mapping

    You can make use of this export parameter only in transformation step of Integration Process. You may use the following "Parameterized Mapping Programs"
    http://help.sap.com/saphelp_nwpi71/helpdata/en/27/db283fd0ca8443e10000000a114084/content.htm
    Regards,
    Prateek

    If you have defined the signature of your UDF then the return value of the UDF must be assigned to the Export paramter of message mapping.
    Basically import parametrs represents the inputs to be passed for that function(message mapping here)
    and export represents the output of that function.
    so in your case if you want toassign the value to Export parameter (ERROR_TEXT) in UDF catch block
    assign the error returned to the ERROR_TEXT field
    http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm
    Check this link
    Hope this is clear
    Rajesh
    Edited by: Rajesh on Mar 13, 2009 5:31 PM

  • Error when testing from Message mapping test tab

    Hi Experts,
    I am wondering that when i test the message in the MM test tab its giving error and target message is not generating. I am not testing end to end then why it is triggering communication channel?
    I can see that the 'RFC_Alert_Service_RFC_Receive' communication channel is in Red color RWB--> communication channel monitoring. I even even refreshed the cache and also activated the RFC channel but no use.
    Below are the error details:
    Error when testing message from test tab of mapping -->
    java.lang.RuntimeException: Exception during processing the payload.Problem when calling an adapter by using communication channel RFC_Alert_Service_RFC_Receiver (Party: , Service: RFC_Alert_Service, XI AF API call failed. Module exception: 'error while processing the request to rfc-client: com.sap.aii.af.rfc.afcommunication.RfcAFWException: RfcAdapter: receiver channel has static errors: can not instantiate RfcPool caused by: com.sap.aii.af.rfc.RfcAdapterException: error initializing
    Error in Communication channel monitoring -->
    Receiver channel 'RFC_Alert_Service_RFC_Receiver' for party '', service 'RFC_Alert_Service'
    Error can not instantiate RfcPool caused by:
    com.sap.aii.af.rfc.RfcAdapterException: error initializing RfcClientPool:com.sap.aii.af.rfc.core.repository.RfcRepositoryException: can not connect to destination system due to: com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: Password logon no longer possible - too many failed attempts.
    Please help me how can i resolve this issue to successfully test the message in mapping-test tab.
    Regards,
    Suresh.

    > Error in Communication channel monitoring -->
    > Receiver channel 'RFC_Alert_Service_RFC_Receiver' for party '', service 'RFC_Alert_Service'
    > Error can not instantiate RfcPool caused by:
    > com.sap.aii.af.rfc.RfcAdapterException: error initializing RfcClientPool:com.sap.aii.af.rfc.core.repository.RfcRepositoryException: can not connect to destination system due to: com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE: Password logon no longer possible - too many failed attempts.
    Unlock the user you are using in the RFC channel and provide the correct password in the channel configuration. Once the channel error is resolved you would be able to test the Mapping sucessfully...
    >>why it is triggering communication channel?
    You would be using RFC lookup in the mapping....
    ~SaNv...
    Edited by: Santhosh Kumar V on Jul 8, 2009 5:48 PM

  • Alert from Message Mapping Response

    Hi All,
    I am working on a scenario wherein I am using BAPI Request & Response Messages in my mapping. I am receiving a no. from Bapi Response if the request i successful. If the number returned from BAPI is null or '', then an alert has to be thrown and send an email to support, otherwise normal processing of message.
    My question is how can I raise an alert from BAPI return Variable Value without using BPM or JAVA UDF.

    Hi,
    Alert Configuration
    http://help.sap.com/saphelp_nw04/helpdata/en/80/942f3ffed33d67e10000000a114084/frameset.htm
    Alert Inbox
    http://help.sap.com/saphelp_nw04/helpdata/en/80/942f3ffed33d67e10000000a114084/frameset.htm
    Alert Notification Step-by-Step
    http://help.sap.com/saphelp_nw04/helpdata/en/49/cbfb40f17af66fe10000000a1550b0/frameset.htm
    Defining Alert Classifications
    http://help.sap.com/saphelp_nw04/helpdata/en/49/cbfb40f17af66fe10000000a1550b0/frameset.htm
    Triggering Alerts
    http://help.sap.com/saphelp_nw04/helpdata/en/49/cbfb40f17af66fe10000000a1550b0/frameset.htm
    Setting up alerts
    Setting up alerts in RZ20
    Alert Management
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e04141e8-0f11-2a10-adaa-9d97b062c2df
    Alert Notification
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/90f449a8-a6db-2910-a386-d2b5999f5751
    Regards,
    Phani

  • Export Parameters in Parameterized Message Mapping does not work.

    Hello, XI-Gurus!
    I have a question: how to use an EXPORT parameter in Parameterized Message Mapping? seems it does not work...
    (I use XI / PI 7.1)
    For example, I have a follow scenario: a large message comes to XI from one BS (message contains a lot of rows), then this large message splits to some small messages (something about 1000 rows in one small message), and send small messaeg one by one from XI to second BS. So, after receive step I use a transformation step with Parameterized Message Mapping to get a total amount of rows in large message (it needs for making condition for loop in IP, for example). I want to use an EXPORT parameter to pass this number from Parameterized Message Mapping to Integration Process. How can I do it?
    Of course, I know the way to how to make this scenario without any parameterizing, but I want to use exactly "Parameterized Message Mapping" like it writes in this help:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/43/c3e1fa6c31599ee10000000a1553f6/frameset.htm
    This topic contains something about procedure how to use an EXPORT parameter, but this procedure does not work. I don't understand how to write this UserDefined Function, which I can set any export parameters.
    I read this blog:
    /people/jin.shin/blog/2008/02/14/sap-pi-71-mapping-enhancements-series-parameterized-message-mappings
    this blog has NO solutions about EXPORT parameters. about IMPORT parameters - everything OK.
    Some topics about how to use export parameters in MM in this forum marked as "answered", but this is not true.
    How to export parameters from Message Mapping
    Export parameter REALLY work in message mapping???????
    Export parameter in Message mapping UDF
    WBR,
    Vsevolod

    Hi Rudolf,
    It still does not works.
    Great thanks for all your answers! If your advice works on your PI-server, it means that my problem not in UDF.
    Step by step:
    1) I create in "Signature" tab two parameters: FILE_NAME, FILE_TYPE (of course, they both Export and xsd:string type)
    2) Then, I goes to "Functions" tab and create new function "testUDF" with one argument var1.
    3) In body of this UDF insert 2 strings:
       getOutputParameters.setString("FILE_NAME" , "Order");
       getOutputParameters.setString("FILE_TYPE" , "PDF");
    4) in "Definition" tab I bind function "Local.testUDF" with one field in my input message and goes to "Test" tab for testing.
    5) And then I have a message window "Problems While Testing":
    Source text of object Message Mapping: mm_ParamMap | urn:****.*.:****:TEST has syntax errors:
    Function testUDF, Line 1:
    cannot find symbol
    symbol  : variable getOutputParameters
    location: class com.sap.xi.tf._mm_ParamMap_
    getOutputParameters.setString("FILE_NAME" , "Order");
    ^
    Function testUDF, Line 2:
    cannot find symbol
    symbol  : variable getOutputParameters
    location: class com.sap.xi.tf._mm_ParamMap_
    getOutputParameters.setString("FILE_TYPE" , "PDF");
    ^
    Note: /usr/sap/PID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapb1562570ca9e11deb3fe00237d301cd6/source/com/sap/xi/tf/_mm_ParamMap_.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details. Note: /usr/sap/PID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapb1562570ca9e11deb3fe00237d301cd6/source/com/sap/xi/tf/_mm_ParamMap_.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    Look at this notes, first writes that I use a deprecated API, second - about unchecked or unsafe operations.
    And I have no idea what's wrong... Can you help me?
    Thanks!
    WBR,
    Vsevolod

  • RFC Lookup's in message mapping fail with RuntimeException for no reason

    Hi guys,
    We have developed interfaces that execute a lot of RFC's from Message Mapping, by making use of RFC Lookup API.
    In ID, in the corresponding RFC Receiver Communication Channel we have set the number of maximum connections to 100.
    However, when a big number of Idocs with lots of items is sent to XI some messages fail in XI because mapping fails with a runtime exception that is not correct, since there is a return value found from the execution of the RFC function. And when I am testing the mapping in Test mode of XI IR, the mapping is executed successfully.
    Do you think that by increasing the maximum number of connections in Communication Channel, it will take effect?
    Evaggelos

    Hi Evaggelos,
    DECREASE, may be til 10.
    Regards,
    Udo

  • Message Mapping - JDBC to IDoc

    Hi,
    I trying to map the resultset from a JDBC adapter (sender) to Inbound IDoc into SAP. I have problems with message mapping and after reading through a number of threads, I followed the following steps:
    1. Download the IDoc definition as XSD.
    2. Change occurrence of node IDOC to 1..unbounded.
    3. Upload changed XSD as external definition and
    4. use the external definition in the mapping.
    After importing the external XSD definition the IDOC node turned red. How do I map this node, now that it is  unbounded?
    Example from Message mapping:
    MT_ETA_RMX................ZSDETA01
    ..EtaNode........................IDOC     (unbounded =  RED)
    ....CARID.................................BEGIN
    ...............................................EDI_DC40
    ...............................................Z1RETA
    .................................................SEGMENT
    .................................................CARID
    Thanks,
    Henk

    Hendrik,
    whichever data record is occuring multiple on your sender JDBC message should be mapped to IDoc segment. It really depends on your JDBC message structure.
    If EtaNode is occuring multiple times, and if based on EtaNode an IDoc has to be created, map that to IDOC and if per every CARID one idoc needs to be created, then use CreateIf and exists node functions to IDoc.
    regards
    SKM

  • Using Jco calls from the message mapping

    can any body tell me how can we use JCO call in a message mapping if posssible with an example
    thanks and regards
    sandeep

    Hi,
    Refer the below code and weblog:
    ?     RFC lookup using JCO (without communication channel)
          /people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
    Notes:
    ?     Ensure that the function module is RFC-enabled.
    ?     Ensure that the parameters are passed by value and not by reference (mandatory for RFC-enabled function modules).
    IN UDF:
    Import Parameters:
    com.sap.mw.jco.*
    Code:
    Public String UOMLookup(String resultFieldName, Container container)
    JCO.Repository mRepository;
    // Change the logon information to your own system/user
    JCO.Client mConnection = JCO.createClient(
        "800", // SAP client
        "xilookup", // userid
        "test", // password
        "EN", // language
        "tsphl850", // host name
        "00" ); // system number
    // connect to SAP
    mConnection.connect();
    // create repository
    mRepository = new JCO.Repository( "SAPLookup", mConnection );
    // Create function
    JCO.Function function = null;
    IFunctionTemplate ft = mRepository.getFunctionTemplate("Z_SFLIGHT_DETAILS");
    function = ft.getFunction();
    // Obtain parameter list for function
    JCO.ParameterList input = function.getImportParameterList();
    // Pass function parameters
    input.setValue(resultFieldName, "UOMCODE" );
    mConnection.execute( function );
    String ret = function.getExportParameterList().getString( "UOMTEXT" );
    mConnection.disconnect();
    return ret;

  • Problem by transporting the message mapping from PI 7.0 to PI 7.1

    Hi Everyone,
    by transporting the message mapping from PI 7.0 to PI 7.1 i have got the following problem.
    "Source code has syntax error:
    K:\usr\sap\E71\DVEBMGS00\j2ee\cluster\serve......
    package udfpool does not exist
    import udfpool.*;
    i have used a UDF in my message mapping.
    This UDF calls for a method of a java class, which is imported as a .jar file with this message mapping.
    this message mapping works very well on PI 7.0,
    but doesn't work any more on PI 7.1 because of the problem described above.
    anyone can help me out of this problem?
    thanks!
    zc

    hi,
    but did you import the jar archive to 7.1 first?
    Regards,
    Michal Krawczyk
    http://mypigenie.com XI/PI FAQ

  • Accessing SAP:HopList element in message header from JAVA-mapping

    Dear Experts,
    Is it possible to access the SAP:HopList element from message header in JAVA-mapping? 
    I need this to get the list off all receivers of current message (I have a ReceiverDetermination with two receivers, without any conditions, so both receivers are receiving each message and in InterfaceDetermination to one of the receivers I have a JAVA-mapping, in which I need to know the name of another receiver. And the SAP:HopList is containing this information).
    Or maybe where is some other solution?
    Best Regards,
    Artsiom Anichenka

    That's tricky, since the proper way of doing it would be through BPM.
    Anyway, if you expose your XI interface as a WebService (Soap sender cc) you could access it through Mapping Lookup (lookup works for RFC, DB and Soap lookups). Check https://help.sap.com/javadocs/NW04S/current/pi/index.html
    But be aware that Mapping Lookup API is not intended for inserts/updates (since it doesn't contain any transacational handling), just mere lookups (selects in tables), so I'm not sure it is the best approach for your case.
    Regards,
    Henrique.

  • Accessing container variables from ccBPM in Message Mapping?

    Hello Friends,
    I have created a ccBPM and require to send response messages to the sending system at different points as the message proceeds from one state to another. I do not want to create multiple message mapping stating different status in every message mapping. The message mapping remains the same only the status is changing. So I am thinking if I can access container elements in ccBPM at message mapping then I should be able to use only one message mapping.  Is it possible at all?
    Let me know if you have other solutions. Let me know if I am not clear?
    Thanks & Regards,
    Anand Patil

    Hi Abhishek,
    Your suggestion to use Parameterized Mapping did solve my issue. I was looking something like this. Thanks.
    Now I have only one Message Mapping and it is used in multiple places. Thanks a lot
    Best regards,
    Anand Patil

Maybe you are looking for

  • How to see undo information

    Hi. Oracle 9.2 o/S : Windows Xp, Sp1 I want to know that can a DBA check what information is presently stored in Undo Tablespace (Automatic Mode) or in Roll back Segment (Manual Mode). Pl. Tell Me. Thanks & Regardx

  • Turn my ipad on

    Hello, I just bought my Ipad and I don't know how to turn it on. I tried to hold the power button for seconds, and what came up was apple logo and then itunes and usb cable... help

  • Can't import AVCHD from camcorder  Error C0000005 at address:0

    Every time I try to import any files from my camcorder I get a fatal error saying it can't import anything with an error code C0000005 at address 0.  This is just the trial version as I'm trying to see if it will do what I want and so far I can't get

  • Meetup in Orange County/CA About Migrating content into CQ

    Just wanted to let everybody know that we have a presentation on how to automatically transfer a site into CQ on Wed March-20 The meetup can be found at http://www.meetup.com/OC-CQ-Sling-JCR-User-Group/events/106181442/ Would be great to see as many

  • Autocomplete in APEX Report page

    Hi, i am new to apex.. my scenario is "there is a report page for a DB,in the report page a select list with 400 entries is to be there...so if i am going to type 'A' all the entries starting with A should be filtered out,then if i type 'R',all the w