In XI mapping, how to get number from a number_range object in SAP R/3

HI All,
I have a scenario where I need to read a Number_range object  in SAP R/3 or ABAP XI and retreive the current number.
I need to use this number during the message mapping.
(I read about JCO and RFC, but am a little confused about how-to and what is the correct approach)
Just to let you know, I do not want to pass this number in the original IDOC coming from IDOC, so I need this lookup.
Scenario:
In MM, make a call to SAP.
Get the latest number from SNRO( number-range object)
Use this number in mapping.
Any help pointers, greatly appreciated.
Many thanks
Shirin

Shrin,
Please find the parameters you need to specify while creating UDF
Imports:javax.xml.transform.stream.StreamResult;com.sap.aii.mapping.lookup.;javax.xml.transform.dom.DOMSource;javax.xml.parsers.DocumentBuilder;java.io.;javax.xml.parsers.;org.w3c.dom.;org.xml.sax.;javax.xml.transform.;
The Template for RFC Lookup
String content = "";
MappingTrace importanttrace;
importanttrace = container.getTrace() ;
//Filling the string with our RFC-XML (With Values)
String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:<Function Module name>xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"></ns0:ZFI_GET_RUNID> ";
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
//1. Determine a channel (Business System, Communication channel)
Channel channel = LookupService.getChannel("<Business System Name>","Communication channel name");
//2. Get a RFC accesor for a channel.
accessor = LookupService.getRfcAccessor(channel);
//3. Create a xml input stream representing the FM request message.
InputStream inputstream = new ByteArrayInputStream(m.getBytes());
//4. Create xml Payload
XmlPayload payload  =  LookupService.getXmlPayload(inputstream);
//5. Execute Lookup
Payload result = accessor.call(payload);
InputStream in = result.getContent();
//This are the extra step which i dont know what it mean
//out = new ByteArrayOutputStream(1024);
//byte[] buffer = new byte[1024];
//for (int read = in.read(buffer); read > 0; read = in.read(buffer))
//out.write(buffer,0,read);
//content = out.toString();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList list = document.getElementsByTagName( "REsult" );
Node node = list.item(0);
if (node  != null)
     node = node.getFirstChild();
     if (node  != null)
          content = node.getNodeValue();
} catch (Exception e) {
importanttrace.addWarning("Error while closing accesor" + e.getMessage());
catch (LookupException e)
importanttrace.addWarning("Error While lookup" + e.getMessage());
//This exception is not to be catch at this step as there is no try step before this
//catch (IOException e)
//importanttrace.addWarning("Error" + e.getMessage());
finally
if(out!=null)
  try{
       out.close();
} catch (IOException e) {
importanttrace.addWarning("Error while closing system" + e.getMessage());
//7. close the accessor in order to free resources
if (accessor!=null) {
try{
      accessor.close();
} catch (Exception e) {
importanttrace.addWarning("Error while closing accesor" + e.getMessage());
return content;
Have mentioned in genric  where u need to specify the communication channel name, business service etc.,
Moreover there is a field result, which is the output returned from the FM

Similar Messages

  • How to get Number from xml in flash?

    hi
    this is my XML file
    <?xml version="1.0"?>
    <ArrayHolder>
            <level1>"1","1","1"</level1>
         <level2>2,2,1,2,2</level2>
    <level3>1,3,3,3,1</level3>
    </ArrayHolder>
    I want to store level1's no in "levelArray".
    Thanks,
    JaxNa

    ohhh sorry this is my mistake.
    <?xml version="1.0"?>
    <ArrayHolder>
            <level1>"1,1,1,1</level1>
         <level2>2,2,2,2,2</level2>
    <level3>1,3,3,3,1</level3>
    </ArrayHolder>
    here it corrected.
    Thanks,
    JaxNa

  • How to get Byte[] from an image object?

    This are the codes that i have tried, it did an resized.jpg but the file doesnt consist of the image. My program will stream the .jpg file using fileconnection then i resize the image and created the new image using image.createRGBImage(). Lastly, i need to save the resized image as a jpeg file but i failed to do so..
    byte[] jpegData = ImageByteConverter.getByteArray(image);
    OutputStream out = fconn.openOutputStream();
    out.write(jpegData,0,jpegData.length);
    * This method converts a int-array, containing all RGB values for the image, to
    * a byte-array containing all RGB values.
    public static byte[] getByteArray(Image image){
    // Allocate new memory for the int-array and fill the array in the getRGB method.
    int[]raw = new int[image.getWidth() * image.getHeight()];
    image.getRGB(raw, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
    byte[]rawByte = new byte[image.getWidth() * image.getHeight() * 4];// ARGB
    int a, r, g, b;
    int n = 0;
    // loop through the int-array and get the 4 bytes of each value to the byte-array.
    // since java isn't supporting unsigned bytes we need to store the ARGB values from -128 to 127
    // where -128 = 128, -127 = 129 and -1 = 255
    for(int i=0; i<raw.length; i++){
    // Right-shift the values to fit in a byte.
    int ARGB = raw;
    a = (ARGB & 0xFF000000) >> 24;
    r = (ARGB & 0xFF0000) >> 16;
    g = (ARGB & 0xFF00) >> 8;
    b = (ARGB & 0xFF);
    rawByte[n] = (byte)b;
    rawByte[n+1] = (byte)g;
    rawByte[n+2] = (byte)r;
    rawByte[n+3] = (byte)a;
    n+=4;
    raw=null;
    return rawByte;
    Thanks in advance.

    you can do follwoing but not sure whether thats what you want.
    Also not sure whether its the best way.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(image, "PNG",baos);
    InputStream in = new ByteArrayInputStream(baos.toByteArray());

  • How to get day from Week Number

    Hi all,
    how to get date from the week number when the day is MONDAY.
    like : week num =33
    how get the date of the day MONDAY from this..

    SQL> select
      to_char(d,'YYYY') y,
      w,
      trunc((trunc(d,'Y')+w*7-date '1000-01-01')/7)*7+date '1000-01-01' monday
    from
    (select sysdate d, 33 w from dual);
    Y             W MONDAY
    2005         33 15.08.2005Message was edited by:
    Laurent Schneider
    I wrote an article which may help you to get out of the mess with weeks that start on friday, saturday, sunday, monday
    http://laurentschneider.blogspot.com/2005/07/tochar-d.html

  • How to get coordinates from Google Map

    I wonder how to get coordinates from Google Map to JavaFX application when click has occured. Here is an example of code:
    public class JavaFXApplication extends Application {
    public void showCoordinates(String coords)
            System.out.println("Coordinates: " + coords);
        @Override public void start(Stage stage)
            final WebView webView = new WebView();
            final WebEngine webEngine = webView.getEngine();
            webEngine.load(getClass().getResource("googlemap.html").toString());
            webEngine.getLoadWorker().stateProperty().addListener(
                    new ChangeListener<State>() {
                        @Override
                        public void changed(ObservableValue<? extends State> ov, State oldState, State newState) {
                            if (newState == State.SUCCEEDED) {
                                JSObject window = (JSObject) webEngine.executeScript("window");
                                window.setMember("java", new JavaFXApplication());
            BorderPane root = new BorderPane();
            root.setCenter(webView);
            stage.setTitle("Google maps");
            Scene scene = new Scene(root,1000,700, Color.web("#666970"));
            stage.setScene(scene);
            stage.show();
       public static void main(String[] args){
            Application.launch(args);
    // googlemap.html file
    <!DOCTYPE html>
    <html>
        <head>
            <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
            <style type="text/css">
                html { height: 100% }
                body { height: 100%; margin: 0px; padding: 0px }
                #map_canvas { height: 100%; background-color: #666970; }
            </style>       
            <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
            </script>
            <script type="text/javascript">           
                function initialize() {
                    var latlng = new google.maps.LatLng(40.75089, -73.93804);
                    var myOptions = {
                        zoom: 10,
                        center: latlng,
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        mapTypeControl: false,
                        panControl: true,
                        navigationControl: true,
                        streetViewControl: false,
                        backgroundColor: "#666970"
                    var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);    
                    document.map = map;
            google.maps.event.addListener(map, 'click', function(event) {
                //java.showCoordinates(event.latLng); ???
            map.setCenter(location);
            </script>
        </head>
        <body onload="initialize()">
            <div id="map_canvas" style="width:100%; height:100%"></div>
        </body>
    </html>Edited by: krbltik on 03.10.2012 22:59

    Hi, welcome!
    You may also have a look at GPS Info Qt, available for free at Ovi Store: http://store.ovi.com/content/165671
    GPS Info Qt is a nice Qt app. I have it on my C6-01 and I like it.
    Regards.

  • How to get number of rows return in SELECT query

    i'm very new in java, i have a question:
    - How to get number of rows return in SELECT query?
    (i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)
    Thanks.

    make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
             String sql = "select * from testing";
             PreparedStatement ps =
              con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
             ResultSet rs = ps.executeQuery();
             rs.last();
             System.out.println("Row count = " + rs.getRow());
             rs.beforeFirst();~Tim
    NOTE: Ugly, but does the trick.

  • How to get Position from EmployeeInfo in DIAPI

    I am using DIAPI(JCO) for SAP B1. According to one or my reuirement i am in need of Position from the EmployeesInfo. But there  seems no option or method for getting position from that. Can anyone guide me how to get that from EmployeesInfo ? Any help is appreciated..

    Looking at the DI API properties vs. DB fields mapping documentation in the SAP Business One developer area (https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c5f5dbcc-0a01-0010-5d82-f25f2bee715e)
    it seems that this field is not exposed (yet).
    I.e. you could only run a SQL statement to get this information.
    Sorry,
    Frank

  • How to get resultset from oracle procedure use ejb3

    how to get resultset from oracle procedure use ejb3
    i know oracle procedure should like this
    Create or replace PROCEDURE resultset_test(
    aaa IN NUMBER,
    bbb OUT sys_refcursor) ....
    but what s the ejb3 scripts looks like? please give me an example or link~
    ths

    - there are no EJB3 scripts, only compiled application code
    - the part of the EJB spec that deals with databases is called the Java Persistence API, but likely you are just looking for the JDBC API.
    Now you should know what to Google to get your "example script": "java jdbc oracle procedure"

  • How to get photos from iphoto back onto an SD card. I have a MacBook Pro with a built in SC card slot.

    How to get photos from iPhoto back onto a SD card. I have a MacBook Pro with built in SD card slot. I have tried "Export" but this does not work.

    It's best to export the photos to a folder and then drag the folder onto the memory card.  Memory cards are usually formatted for PCs, FAT 32, which doesn't permit more than a limited number of files in the root directory. Putting the photos in a folder gets around that limitation.
    OT

  • How to get BOOLEAN from STORED FUNCTION

    We are calling legacy PLSQL stored procedures and functions via named queries. This has worked fine so far, but there are some functions which return the type 'BOOLEAN'. e.g.
    FUNCTION some_function( some_argument IN NUMBER) RETURN BOOLEAN;
    Where the return type is BOOLEAN calling the named query fails with
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    A couple of threads have hinted that what we are trying to do is not possible:
    How to get BOOLEAN from STORED PROCEDURES
    Re: Creating Named Query: from OracleCallableStatement
    This would possibly be due to 'restriction in the OCI layer'. Can anyone help? Is there really now way to call a valid PLSQL stored function via a named query when the return type is BOOLEAN?
    thanks

    I can't comment on possible issues you might have with the driver, but if it can be done in JDBC, it should be possible in TopLink.
    TopLink has the StoredFunctionCall which extends the StoredProcedureCall but adds an unnamed ouput parameter in the first spot of its parameter list. You will need to get the databasefield and set its type to BOOLEAN ie:
      DatabaseField returnField = (DatabaseField)yourStoredFunctionCall.getParameters().firstElement();
            returnField.setName(name);
            returnField.setSqlType(Type.BOOLEAN);Be sure not to use the setType() method, as I believe TopLink will try to use the Type.BIT when a boolean class is used as the classtype.
    Best Regards,
    Chris

  • How to get hostname from targetlist in custom deployment procedure?

    When I make a simple procedure with a phase that will loop through a procedure hostname list
    and a hostcmd or directive inside that will use the hostname ex change a configuration file. How to get hostname from the hostname targetlist?
    I would rather not use $(hostname) or similar function if I can get the hostname from the target list.
    Edited by: user476601 on 2012-09-06 05:59

    I have tried that and cannot get it to work.
    I have tried to make a procedure with:
    parameter
    - parallel fase
    - step directive with hostname parm based on simple sh script (echo $hostname)
    - map hostname setvalue %TargetName%
    In a hostcmd step you cannot access %TargetName% directly
    it doesn't work. Please come with an example if you have tried it.
    /René

  • How to get photos from mac to iPhone 6? when i try it just comes up iCloud instead of my photos

    how to get photos from mac to iPhone 6? when i try it just comes up iCloud instead of my photos

    Make sure Settings > iCloud > Photos > iCloud Photo Library (Beta) = "Off"
    Then sync your iPhone using iTunes and make sure your sync settings for photos are set correctly in iTunes.

  • I got a new computer and don't know how to get music from ipod touch to itunes library

    I recently got a new computer and don't know how to get music from my ipod touch to show on my itunes library. 

    You need to transfer the iTunes folder from the old computer to the new one.
    iTunes: How to move your music to a new computer (Mac or Windows):
      http://support.apple.com/kb/HT4527

  • I have a new MacAir and don't know how to get info from my USB stick and my SD photo card.  Can anyone help me please?

    I have a new MacBook Air and don't know how to get info from my USB stick and get info from my SD card.  Can anyone help, please?

    Plug the stick and/or card into the appropriate slots on the side of your Air. Do you see icons for the devices appear on the desktop? Click into them to see what files are there.
    Matt

  • How to get data from a USB-UIRT device using Labview?

    How to get data from a USB-UIRT device using Labview?
    I'm trying to get data from a USB-UIRT device, is it posible with Labview?
    I really appreciate your help, 
    thanks

    You may want to contact the developer of the device for the API and DLL.
    http://65.36.202.170/phpBB2/viewforum.php?f=3

Maybe you are looking for

  • How can my saved highlights be shared on multiple devices

    I am using Dropbox + Adobe Reader on my iPad 1.  I have a lot of highlights however, when I open the PDF on another computer (Windows PDF reader) the highlights are gone. Is there anyway I can save the highlights I've made? Either in the file or in a

  • Unlimited Data Plan on USB Modem

    Hello, I'm new to forum and I apologize if this has already been discussed but I haven't seen my particular situation anywhere; I have a 3G USB modem on the much talked about unlimited data plan. What I have is a month-by-month unlimited plan which i

  • Missing Serial Numbers for CS4 COmponents & Acrobat X Pro

    Greetings! I installed CS5.5 on my 32-bit system, which means I had to install the included "complimentary" CS4 copies of After Effects & Premiere Pro.  As stated in one of the Adobe troubleshooting sections I read, the CS4 components require a separ

  • JSF & JSP

    DEAR SIR/MADAM, can u tell me what is major difference between jsf & jsp? because i need to planning develop web application. which is a best for design/deploy/performance. i don't know how to choose which one ? best regards boris

  • FUnction Module For OPen Reservation

    Dear All, CAn you give me details of a fuction module which will return me details of open reservation items. deepak