Write method in diif ways

Hi,
i heard that i can write method in 2 ways.
1. CALL METHOD
  lp_ukm_easy->add
  EXPORTING
    it_key_mapping = lt_mappings
  IMPORTING
    es_messages    = ls_messages.
2. ls_messages = lp_ukm_easy->add (exporting = lt_mappings) .
but when i write like 2 i have error what i doing wrong ?
Regards

Lots of things wrong.
1. If the method has only one IMPORTING parameter (or one is marked as preferred), you can leave out EXPORTING in the call to the method. 
2. If es_messages was a returning parameter you could use
ls_messages = lp_ukm_easy>add( lt_mappings ) .
3. No space between add and (
4. Always have a space inside the brackets.
5. Short form of what you wrote is:
  lp_ukm_easy->add(   EXPORTING it_key_mapping = lt_mappings
                      IMPORTING es_messages    = ls_messages ).
matt

Similar Messages

  • What is the proper way to use the write method?

    What is the proper way to use the OutputStreams write method? I know the flush() method is automatically called after the write but i cant seem to get any output
    to a file. The char array contains characters and upon completion of the for loop the contents of the array is printed out, so there is actually data in the array. But write dosnt seem to do squat no matter what i seem to do. Any suggestions?
    import java.io.*;
    public class X{
    public static void main(String[] args){
    try{      
    FileReader fis = new FileReader("C:\\Java\\Test.txt"); //read chars
    FileWriter fw = new FileWriter("C:\\Java\\Test1.txt"); //read chars
    File f = new File("C:\\Java\\Test.txt");
    char[] charsRead = new char[(int)f.length()];
    while(true){
    int i = fis.read(charsRead);
    if(i == -1) break;
    // fw.write(charsRead); this wont work
    // but there is infact chars in the char Array?
    for(int i = 0; i < charsRead.length -1 ; ++i){
    System.out.print(charRead);
    }catch(Exception e){System.err.println(e);}

    Sorry to have to tell you this guys but all of the above are broken.
    First of all... you should all take a good look at what the read() method actually does.
    http://java.sun.com/j2se/1.3/docs/api/java/io/InputStream.html#read(byte[], int, int)
    Pay special attension to this paragraph:
    Reads up to len[i] bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len[i] bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer.
    In other words... when you use read() and you request say 1024 bytes, you are not guaranteed to get that many bytes. You may get less. You may even get none at all.
    Supposing you want to read length bytes from a stream into a byte array, here is how you do it.int bytesRead = 0;
    int readLast = 0;
    byte[] array = new byte[length];
    while(readLast != -1 && bytesRead < length){
      readLast = inputStream.read(array, bytesRead, length - bytesRead);
      if(readLast != -1){
        bytesRead += readLast;
    }And then the matter of write()...
    http://java.sun.com/j2se/1.3/docs/api/java/io/OutputStream.html#write(byte[])
    write(byte[] b) will always attempt to write b.length bytes, no matter how many bytes you actually filled it with. All you C/C++ converts... forget all about null terminated arrays. That doesn't exist here. Even if you only read 2 bytes into a 1024 byte array, write() will output 1024 bytes if you pass that array to it.
    You need to keep track of how many bytes you actually filled the array with and if that number is less than the size of the array you'll need pass this as an argument.
    I'll make another post about this... once and for all.
    /Michael

  • How can we write methods in Jsp ?

    I want to write methods in jsp in such a way that in one method I should have "Creating database connection" and in another method I want to create ResultSet and in another method I want to access the ResultSet.

    u can write methods in jsp using the following tag
    <%!
    public void myMethod()
    %>

  • DatagramSocket read and write methods

    Hi,
    I am trying to implement a client/server schame via NIO DatagramChannel.
    I manage to make it work with the methods send/receive. but i am not able to make it work in "connected" mode via write/read method.
    i bind and connect like this;
    this.channel = DatagramChannel.open();
    this.channel.configureBlocking(false);
    this.channel.socket().bind(hostAdr);
    this.channel.connect(destAddress);
    then i receive messages like this:
    ByteBuffer theReceiveDataByteBuffer = ByteBuffer.allocateDirect(5000);
    Charset charset = Charset.forName("ISO-8859-1");
    StringBuffer buffer = new StringBuffer();
    String[] retval = new String[2];
    while (flag) {
    try {
    Int value = receiverChannel.read(theReceiveDataByteBuffer);
    long time = System.currentTimeMillis();
    } catch (IOException e) {
    Thread.currentThread().interrupt();
    flag = false;
    I send via the write method, it seems i manage to send but i receive nothing...
    How to code this kind of scheme with write/read ?
    thank you
    Sebastien
    Edited by: sepi_seb on Nov 29, 2007 10:06 AM

    Well (a) you're spinning madly burning up the CPU in a non-blocking read loop; (b) if this is the complete code you don't have any way of knowing whether you received anything or not; and (c) you're completely suppressing any IOExceptions that may be occurring, so you can't see anything that's going wrong.
    So:
    (a) don't use non-blocking mode, or use a Selector to tell you when OP_READ is ready for the channel;
    (b) try breaking out of the loop when you've received something, i.e. when the bytecount returned from read() > 0; and then display something;
    (c) when you get an exception it contains a valuable message and an equally valuable stack trace. Don't just ignore them.

  • Why a array in write method fifo

    Hi !
    I am a beginner on LabVIEW FPGA, and I have a thing who intrigue me. I use a FIFO Write Method on my vi PC to interact with values of condition on my vi FPGA, the thing which intrigue me it's why the Write Method forces me to use a array on Data and why in the front panel it's the tenth element of the array which can change the value.
    This problem many intrigues me, I will be grateful if someone can help me.
    Attachments:
    PC.vi ‏200 KB
    FPGA_4.vi ‏68 KB

    The host side of the DMA FIFO is always working with arrays.  This is because the FPGA can take the data off/put the data in a lot faster than the host can if one item at a time.
    You can only change the 11th element because that is the index item you are showing.  You can always change the visible index and/or expand the array to show more elements.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Print Logo in Classic Report (Write Method,Not ALV)

    Hi All,
    I'm currently doing conversion of the All the Classic Report with addition of Header with 'LOGO'.
    I'm willing to find out that Function (CALL FUNCTION 'WWW_GET_MIME_OBJECT') is only able for display but not show out during printing.
    Is that any method, I can do it(Print with Logo) without conversion to SAP Script or Smartform that was exhausted.
    *Please take note is Classic Report with Write Method (Line by Line), Not ALV.
    Thank you all in advance
    Regards,
    Trevor Wong.

    Hi,
    It is possible to include logo in classical report but its not possible to print logo in classical report. It can be done in ALV's.
    Write  the code in Top-of-page event in ALV.
    The following is the code for inserting the logo in ALV.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
               I_LOGO             = 'ENJOYSAP_LOGO'
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    ENDFORM.
    Regards
    Purnand

  • Jdev CPU profiler doesn't show inherint method timing - Any way to get it

    Hi,
    CPU profiler both in HOTSPOT and Callstack doesn't give method's inherint timings . it only shows parent + descendant timing (inclusive timing) . This doesn't help me to quickly find which method inherintly is expensive (ie timing withouts its child included ) .Is there a way to get the timing of a method without including its child method timing ..
    Regards,
    Indraneel

    Depending on what version of JDeveloper 11 you are running, exclusive time in a method is called "CPU Exclusive" or "CPU Shallow" in the CPU profiler column headings. The column is there; there is data in the column for some methods (Click on the 'CPU Exclusive/Shallow' column to sort by those values). So it's hard to understand how the profiler does not report it.
    Perhaps your issue is that the profiler doesn't report it accurately?

  • Write method in C++ xml Parser ??

    I am using the c++ XML and DOM apis to create a new document. Now i need a wite or toString method to turn the document into the XML format. I find .write in JAXP but nada so far in XML Parser!!?
    Missing something fundamental here. Would not like to write node traversal, recursive routines to try to accurately build the <></> stuff.

    Use the print() method in the Node class.

  • Writting Methods of Binary Tree

    I am using java code to write some binary tree methods.
    Got stuck in some of the following methods.
    Hopefully i can get some help here.
    Public int width(){
    // Return the maximun number of nodes in each level
    Public boolean checkIsFullTree(){
    // Return true if the tree is a full tree (If all leaves are at the same depth then the tree is full)
    Public boolean checkIsCompleteTree(){
    // Return true if the tree is a full tree (If all leaves are at the same depth then the tree is full and is filled from left to right)
    at last
    Public int internalPathLength(){
    // Return The sum of all internal nodes of the paths from the root of an extended binary tree to each node.
    other words, the sum of all depths of nodes.
    Looking forawad to see some replies. Chrees

    I have came up with some ideas.
    Public boolean checkIsFullTree(TreeNode t, int currentHeight ) {
    int maxHeight = height(); // Maximum height.
    int currentHeight=currentHeight;
    if (t == null){
    return false;
    if (t.left() ! = null){
    currentHeight++;
    checkIsFullTree(t.left(), currentHeight);
    if (t.right() ! = null){
    currentHeight++;
    checkIsFullTree(t.right(), currentHeight);
    if ( t.left() == null && t.right() == null){
    if (currentHeight == maxHeight) {
    check = true;
    }else{
    check = false;
    But i am missing sometime here i guess.
    }

  • Reg. Socket Channel Write Method

    Hi,
    We have the following method to write into the socket channel.
         private void write(SelectionKey key)
              SocketChannel channel = (SocketChannel) key.channel();
              try
                   channel.write(writeBuffer);
                   key.interestOps(SelectionKey.OP_READ);
              catch (IOException ioEx)
                   LogUtility.log(Level.SEVERE, ioEx);
    My doubt is, in case of any network related issues and network goes down, how to trap those exception. In those cases, i need to re-establish the connection again to the remote host.
    I tried to check, whether channel.isConnected b4 writing, but the doc says this will return false if the connect operation is never fired.
    It will be helpful for me, if some one gimme an idea to proceed on this.
    Best Regards,
    K.Sathishkumar

    If you get any IOException or SocketException other than a SocketTimeoutException when doing I/O to a socket or SocketChannel you must close the socket/channel. It is of no further use. What else you do depends on the application - log it, maybe try to re-establish the connection if you are a client, forget about it if you are a server.
    BTW:
    We have the following method to write into the socket channel.
    private void write(SelectionKey key)
    SocketChannel channel = (SocketChannel) key.channel();
    try
    channel.write(writeBuffer);
    key.interestOps(SelectionKey.OP_READ);This is not valid. You shouldn't throw away the result of the write and just assume the data got written as you are doing here. You should do something like this:
    try
      // assuming the buffer is already flipped
      int count;
      while (writeBuffer.hasRemaining() && (count = channel.write(writeBuffer)) > 0)
      if (count == 0)
        key.interestOps(SelectionKey.OP_WRITE);
      else
        key.interestOps(SelectionKey.OP_READ);
    catch (IOException ioEx)
      LogUtility.log(Level.SEVERE, ioEx);
      try
        channel.close();
      catch (IOException ioEx2)
        LogUtility.log(Level.SEVERE, ioEx2);
    // ...}

  • Write() method in FileItem

    I am using commons-fileupload.1.1.jar in Jakarta Apache. But when I call:
    File saveTo = new File(upload_path+"/"+name);
    item.write(saveTo);
    It fails showing following exception:
    java.io.FileNotFoundException: /var/www/icma/upload/painting_small.jpg (No such file or directory)
    Any solution please?
    Thanks in ADVANCE.

    Lots of things wrong.
    1. If the method has only one IMPORTING parameter (or one is marked as preferred), you can leave out EXPORTING in the call to the method. 
    2. If es_messages was a returning parameter you could use
    ls_messages = lp_ukm_easy>add( lt_mappings ) .
    3. No space between add and (
    4. Always have a space inside the brackets.
    5. Short form of what you wrote is:
      lp_ukm_easy->add(   EXPORTING it_key_mapping = lt_mappings
                          IMPORTING es_messages    = ls_messages ).
    matt

  • !please help me to write method in my program!

    I have written this program however � have to add something but I could not do it. I have to use four method for each selection. For chasis type four different type which are hatchback, sedan etc. this should be single selection. Moreover option part should be multi selection. Please could you help me for writing and adding these two method in to my program
    import java.util.Scanner;
         public class CarConfiguration {
              public static void main(String[] args) {
                   int choise = Menu();
         processSelector(choise);
              private static int Menu() {
         System.out.println("\nWELCOME TO CAR CONFIGURATION APPLICATION PROGRAM");
              System.out.println("======================================");
              System.out.println(" Enter _1_ to Chasis Type");
              System.out.println(" Enter _2_ to Engine Type");
              System.out.println(" Enter _3_ to Transmission");
              System.out.println(" Enter _4_ to Options ");
              System.out.println(" Enter _5_ to Finish ");
              System.out.println("======================================");
              System.out.print("Select Your Choise: ");
         Scanner input=new Scanner(System.in);
         int choise=input.nextInt();
         return(input.nextInt());
         switch(choise){
         case 1:
         break;
         case 2:
         break;
         case 3:
         break;
         case 4:
         break;
         case 5:
         break;
         default:
         System.out.println("Invalid selection");
         break;
         }

    Hi,
    This works now. You just need to create your methods and link them in with your case statement as flounder showed you.
    import java.util.Scanner;
    public class CarConfiguration
         public static void main(String[] args)
         int choise = Menu();
         processSelector(choise);
         private static int Menu()
              System.out.println("\nWELCOME TO CAR CONFIGURATION APPLICATION PROGRAM");
              System.out.println("======================================");
              System.out.println(" Enter _1_ to Chasis Type");
              System.out.println(" Enter _2_ to Engine Type");
              System.out.println(" Enter _3_ to Transmission");
              System.out.println(" Enter _4_ to Options ");
              System.out.println(" Enter _5_ to Finish ");
              System.out.println("======================================");
              System.out.print("Select Your Choise: ");
         Scanner input=new Scanner(System.in);
         int choise=input.nextInt();
         return(choise);
         private static void processSelector(int choise)
              switch(choise)
                   case 1: //enter mehtods here and for all other empty cases
                   break;
                   case 2:
                   break;
                   case 3:
                   break;
                   case 4:
                   break;
                   case 5:
                   break;
                   default:
                   System.out.println("Invalid selection");
                   break;
    }

  • About NIO non-blocking socket write method behavior

    Hi all -
    I hope anyone could help in this issue.
    Assume you create a NIO socket and configure its channel in non blocking mode:
    channel.configureBlocking(false);
    then you write a byte buffer into it:
    int sentBytesNum = channel.write(byteBuffer);
    What are the possibilities of sentBytesNum value? I am sure of two possibilities, which are:
    - all data sent so sentBytesNum equals byteBuffer data size (limit minus position before sending) (after sending the limit and position of byteBuffer are the same)
    - no data is sent so sentBytesNum is zero and byteBuffer limit and postion did not change, so we shall use a write selector to test when the channel will be ready for write to write the data.
    What I am not sure about and need someone to confirm is the third possibility:
    - only a part of data is sent (according to the available free space of socket output buffer) so sentBytesNum is more than zero but less than data size and byteBuffer position is advanced by the value of sentBytesNum, might this possibility happen??
    If yes, so we should manage to hold the non sent part of byteBuffer till the channel becomes ready for write (we can know that using write selector) so we can write it to channel???
    Thanks for help,
    Rocka

    Yes, case three can occur. The usual NIO write loop looks like this:
    int count = 0;
    while (buf.position() > 0)
      buf.flip();
      count = ch.write(buf);
      buf.compact();
      if (count == 0)
        break;
    }This will run until buf.position() == 0 or count == 0. If the partial write case happens it will loop one more time and probably get a 0 count.
    At the end of the loop, if buf.position() > 0 there is still unwritten data and at this point you should register for OP_WRITE and return to the selector. Otherwise if there is no data unwritten you should deregister OP_WRITE as you have nothing to write and aren't interested in the event any longer.
    If you are reading something and writing at the same time the logic goes like this:
    while (inch.read(buf) >= 0 || buf.position() > 0)
      // etc
    }This will read until EOF occurs and either buf.position() is zero or a zero length write occurred.

  • Error write method

    Hi!
    i have a problem with a call to the function write(byte[]). I have realized an application that sends data over a HttpConnection and i call the OutputStream.write extracted from the httpConnection.
    The code perfectly runs on the emulator, but when i run the application on a cell, the write function doesn't work.
    The code is like this:
    HttpConnection conn=(HttpConnection) Connector.open(url);
    OutputStream os=conn.getOutputStream();
    os.write(bytes);
    os.flush();
    os.close();
    Why doesn't the code work on the mobile device?
    please help me!
    Thanks, F.F.

    when i run the application on a cell, the write function doesn't work.-- What is your mode of connection to the net? WAP / GPRS / 3G / other?
    -- Are you sure the url is correctly formed?
    db

  • Extract nested Jar File

    Okay, I've been looking all day for solutions to this problem and nothing I've found pinpointed the solution, so if anyone would rather point me to another site, that's great.
    I have a .jar installer ( installer.jar ) that contains the installer code and a nested jar file ( program.jar ).
    In my experience, plain text files work great in the "getInputStream() -> FileWriter.write()" method, but my way of handling images requires javax.imageio.ImageIO, and i'm hoping something similar exists for jars.
    ALL+* i want to do is extract that jar file into the current directory, but the ZipEntry.getInputStream() method didn't work, and JarInputStream just confuses me.
    If anyone has links to other topics or source code to point to how a jarfile can be extracted.

    Thanks for the help.
    After looking around and finally noticing the Pack200 package, I have the answer!
    JarFile jf = new JarFile( "outside.jar" );
    JarOutputStream jos = new JarOutputStream( new FileOutputStream( new File( "inside.jar" ) ) );
    Pack200.newUnpacker().unpack( jar.getInputStream( jar.getEntry( "inside.jar" ) ), jos );
    jos.close();This creates a JarOutputStream that will write to the FileOutputStream forever until closed.
    The Pack200 Unpacker takes the inputstream and outputs it to the JarOutputStream.
    When the unpack method returns, the jar file is ready. Close the jar output stream and you have a workable jar!

Maybe you are looking for