Update method

I am writing a simple test application that plots a line depending on some values read from an array. I dont want to redraw the full line everytime a new point is added to the end of the line, instead i just want to leave the points already plotted and just draw a line between the last point and the next point in the array. Here is the code. when i run the code only the last point(line) gets drawn. i read that if you overwrite the update() method the screen should not be cleared.
public class NewPanel extends JPanel {
     int[] array;
     int ii = 0;
     //Graphics g;
     public NewPanel(){
          array = new int[200];
          for(ii = 0; ii <200; ii++ ){
               array[ii] = 100;
               repaint();
          this.setVisible(true);
          this.setBackground(Color.BLACK);
     public void update(Graphics g){
          paint(g);
     public void paint(Graphics g){
          g.setColor(Color.BLACK);
          g.drawLine(ii,array[ii],ii + 1,array[ii + 1]);
}

1/ Calling repaint puts an event onto the window manager's queue. When the window manager's thread gets time, the window is repainted.
The loop increments ii to 200 and puts 200 event onto the queue in a very short space of time.
By the time the window manager gets to take the first event off the queue and call update(), ii already is 200.
To see the update happen, you need to put your animation into a seperate thread, and incorproate a delay in it.
2/ update is called when the background is to be repainted by the component. Overriding it to call paint means that the background is not repainted by the component. It does not mean that anything you draw will stay on the window.
Different platforms apply different amounts of buffering to the window, so what you have drawn may persist until the panel is resized, of it may not persist at all. It may get overwritten if the windon gets covered, it may not.
Swing components override update to delegate drawing the background to paintComponent() anyway, so for swing you only ever need override paintComponent().
To get a persistant image, you would use an Image as a double buffer.
But in this case, as the image data is already in an integer array, the easier thing is to use the drawPolyline method.
The following shows the update happening as data is set by a separate thread, and allows the call to clear the background to be switched on by passing in a command line argument:import java.awt.*;
import javax.swing.*;
import java.util.Random;
public class NewPanel extends JPanel {
  int[] xPoint;
  int[] yPoint;
  int numberPoints;
  boolean clear;
  static final int MAX_POINTS = 100;
  static final int STEP_SIZE = 4;
  static final int LEFT = 12;
  static final int RING_RADIUS = 6;
  public NewPanel (boolean clear){
    xPoint = new int[MAX_POINTS];
    yPoint = new int[MAX_POINTS];
    this.setVisible(true);
    this.setBackground(new Color(255, 255, 220));
    this.clear = clear;
  public void animate () {
    new Thread (new Runnable () {
      public synchronized void run () {
        try {
          Random random = new Random();
          numberPoints = 0;
          while (numberPoints<MAX_POINTS) {
            // some random line data
            if (numberPoints==0) {
              yPoint[numberPoints] = getHeight()/2;
            } else {
              yPoint[numberPoints] = yPoint[numberPoints-1] + 10 - random.nextInt(21);
            xPoint[numberPoints] = STEP_SIZE*numberPoints + LEFT;
            numberPoints++;
            repaint();
            Thread.sleep(100);
        } catch (InterruptedException iex) {
    }).start();
  static final BasicStroke FAT_STROKE = new BasicStroke (3);
  public void paintComponent (Graphics g) {
    // if a command arg is given, clear the background
    if (clear) {
      super.paintComponent(g);
    // draw the line
    if (numberPoints>0) {
      // make it pretty
      Graphics2D g2D = (Graphics2D)g;
      g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                           RenderingHints.VALUE_ANTIALIAS_ON);
      g2D.setStroke(FAT_STROKE);
      g2D.setColor(Color.black);
      // actually draw it
      g2D.drawPolyline(xPoint, yPoint, numberPoints);
      // highlight current point- if many rings show
      // then the background isn't cleared
      g2D.setColor(Color.red);
      g.drawOval(xPoint[numberPoints-1] - RING_RADIUS,
                 yPoint[numberPoints-1] - RING_RADIUS,
                 2*RING_RADIUS,
                 2*RING_RADIUS);
  public static void main (String[] args) {
    JFrame frame = new JFrame();
    NewPanel panel = new NewPanel(args.length>0);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(2*LEFT+MAX_POINTS*STEP_SIZE, 300);
    frame.setVisible(true);
    panel.animate();
}Pete

Similar Messages

  • Insert or Update method - removed from Web Services v2.0?

    Was the "insert or update" method on standard objects taken out of Web Services v2.0 for a reason? Is there an equivalent of this functionality in Web Services v2.0?
    Thanks,
    -Kevin

    Hello,
    You can make use of the Execute method in WS 2.0 as an alternate, but if you are looking out for InsertOrUpdate Functionality u have to use WS 1.0.

  • Conversion from awt to Swing, colored list widget, and awt update() method

    Now that my Interactive Color Wheel program/applet is in Swing, I guess I should continue my previous thread in here from the AWT forum ("list widget with different colors for each list item?"):
    * list widget with different colors for each list item?
    My current issue involves two canvas (well, JPanel) refresh issues likely linked to double buffering. You can see them by running the following file with "java -jar SIHwheel.jar":
    * http://r0k.us/rock/Junk/SIHwheel.jar
    [edit add]
    (Heh, I just noticed Firefox and Chrome under Windows 7 will allow you to run thie .jar directly from the link. Cool.)
    [edit]
    If you don't trust me and would rather run it as an applet, use:
    * http://r0k.us/rock/Junk/SIHwheel.html
    (For some reason the first issue doesn't manifest when running as applet.)
    1) The canvas goes "wonky-white" when the user first clicks on the wheel. What is supposed to happen is simply the user sees another dot on the wheel for his new selected color. Forcing a complete redraw via any of the GUI buttons at the bottom sets things right. The canvas behaves itself from then on, at least until minimized or resized, at which point one needs to click a GUI button again. I'll be disabling resizing, but minimizing will still be allowed.
    2) A button image, and sometimes toolTip text, from an entirely different JPanel will appear in the ULC (0,0) of my canvas.
    Upon first running the new Swing version, I had thought everything was perfect. I soon realized though that my old AWT update() method was never getting called. The desired case when the user clicks somewhere on the wheel is that a new dot appears on his selected color. This usually allows them to see what colors have been viewed before. The old paint(), and now paintComponent(), clear the canvas, erasing all the previous dots.
    I soon learned that Swing does not call update(). I had been using it to intercept refresh events where only one of the components on my canvas needing updating. Most usefully, don't redraw the wheel (and forget the dots) when you don't need to. The way I chose to handle this is to slightly modify the update() to a boolean method. I renamed it partialOnly() and call it
    at the beginning of paintComponent(). If it returns true, paintComponent() itself returns, and no clearing of the canvas occurs.
    Since I first posted about these two issues, I've kludged-in a fix to #1. (The linked .jar file does not contain this kludge, so you can see the issue.) The kludge is included in the following code snippet:
        public void paintComponent(Graphics g)
            Rectangle ulc;
         if (font == null)  defineFont(g);
         // handle partial repaints of specific items
         if (partialOnly(g))  return;
            ...  // follow with the normal, full-canvas refresh
        private boolean partialOnly(Graphics g)
         boolean     imDone = true;
         if (resized > 0)  // this "if { }" clause is my kludge
         {   // should enter on 1 or 2
             imDone = false;
             resized += 1;     // clock thru two forced-full paints
             if (resized > 2)  resized = 0;
            if (wedgeOnly)
             putDotOnWheel(g);
                paintWedge(g);
             drawSnake(g);
             drawSatSnake(g);
             updateLumaBars(g);
                wedgeOnly = false;
              else if (wheelOnly)
                wheelOnly = false;
              else
                imDone = false;  // was paint() when method was update() in the AWT version
            return(imDone);
        }Forcing two initial full paintComponent()s does whatever magic the double-buffering infrastructure needs to avoid the "wonky-white" problem. This also happens on a minimize; I've disabled resizing other than minimization. Even though it works, I consider it a kludge.
    The second issue is not solved. All I can figure is that the double buffers are shared between the two JPanels, and the artifact buttons and toolTips at (0,0) are the result. I tried simply clearing the top twenty lines of the canvas when partialOnly() returns true, but for some reason that causes other canvas artifacting further down. And that was just a second kludge anyway.
    Sorry for being so long-winded. What is the right way to avoid these problems?
    -- Rich
    Edited by: RichF on Oct 15, 2010 8:43 PM

    Darryl, I'm not doing any custom double buffering. My goal was to simply replicate the functionality of awt's update() method. And yes, I have started with the Swing tutorial. I believe it was there that I learned update() is not part of the Swing infrastructure.
    Problem 1: I don't see the effect you describe (or I just don't understand the description)Piet, were you viewing the program (via the .jar) or the applet (via the .html)? For whatever reason, problem 1 does not manifest itself as an applet, only a program. FTR I'm running JDK/JRE 1.6 under Windows 7. As a program, just click anywhere in the wheel. The whole canvas goes wonky-white, and the wheel doesn't even show. If it happens, you'll understand. ;)
    Are you aware that repaint() can have a rectangle argument? And are you aware that the Graphics object has a clip depicting the area that will be affected by painting? You might use these for your partial painting.Yes and yes. Here is an enumeration of most of the update regions:
    enum AoI    // areas of interest
        LUMA_SNAKE, GREY_SNAKE, HUEBORHOOD, BULB_LABEL, LUMA_WEDGE,
        LAST_COLOR, BRIGHTNESS_BOX, INFO_BOX, VERSION,
        COLOR_NAME, EXACT_COLOR, LUMA_BUTTON, LUMA_BARS, GUI_INTENSITY,
        QUANTIZATION_ERROR
    }That list doesn't even include the large color intensity wedge to the right, nor the color wheel itself. I have a method that will return a Rectangle for any of the AoI's. One problem is that the wheel is a circle, and a containing rectangle will overlap with some of the other AoI's. I could build an infrastructure to handle this mess one clip region at a time, but I think it would add a lot of unnecessary complexity.
    I think the bigger picture is that, though it is now updated to Swing, some of the original 1998 design decisions are no longer relevant. Back then I was running Windows 98 on a single-core processor clocked at significantly less than 1 GHz. You could actually watch the canvas update itself. The color wheel alone fills over 1000 arcs, and the color intensity wedge has over 75 update regions of its own. While kind of interesting to watch, it's not 1998 any more. My multi-core processor runs at over 2 GHz, and my graphic card is way, way beyond anything that existed last century. Full canvas updates probably take less than 0.1 sec, and that is with double-buffering!
    So, I think you're right. Let the silly paintComponent() do it's thing unhindered. If I want to track old dots on the wheel, keep an array of Points, remembering maybe the last 10. As a final step in the repainting process, decide how many of those old dots to display, and do it.
    Thanks, guys, for being a sounding board.
    Oh, I'm moving forward on implementing the color list widget. I've already added a 3rd JPanel, which is a column to the left of the main paint canvas. It will contain 3 GUI items:
    1) the color list widget itself, initially sorted by name
    2) 3 radio buttons allowing user to resort the list by name, hue, or hex
    3) a hex-entry JTextField (which is all that is there at this very moment), allowing exact color request
    The color list widget will fill most of the column from the top, followed by the radio buttons, with hex-entry at bottom.
    For weeks I had in mind that I wanted a pop-up color list widget. Then you shared your ColorList class, and it was so obvious the list should just be there all the time. :)
    -- Rich

  • Problem with update method

    import java.awt.*;
    import java.applet.Applet;
    public class graphplotter extends Applet
    public void init()
    repaint();
    public void update(Graphics g)
    g.drawRect(0,100,100,100);
    g.drawLine(50,100,50,200);
    g.drawLine(0,150,200,150);
    this code above does not draw the rectangle and line
    automatically when the applet loads.
    how to rectify this.

    i used the update method because i wanted to add new images to the existsing background image.if i use the paint method the even the existing backgroung image again has to be painted again.

  • Which update method to use???

    Hi all,
    Our client has an average of 1000 sales orders per day.
    Which update method will be the best for such a scenario and why?
    Please suggest.
    Cheers
    Jayashree

    Obviously Delta Update.
    Whenever you have a regular postings in the source system, it is always advised to go for Delta update instead of Full update.
    If you go for Full update, day-by-day the number of records will increase and yr data load performance will be badly affected.
    In case of Delta, only the changes will be captured and load perofrmance will be consistent.
    Regards,
    Balaji V

  • How to make update method permanent once and forever?

    Hi,
    Every time I get an update to Flash and install it, at the end of the install I get the three update choices of ‘Allow Adobe to install updates (recommended)’, ‘Notify me to install updates’ and ‘Never check for updates (not recommended)’. Every time I choose the second option and every single subsequent time there is an update I have to go through the same procedure again because the first option becomes selected. I do NOT want Adobe to perform automatic updates. Is there a way to set it to notify me of updates but never bug me to change my update method? I have tried changing the setting through the Control Panel but this doesn’t make any difference either. I just want to be notified of updates but not be pestered with those same three options EVERY time.

    This answer is NOT working. The line "SilentAutoUpdateEnable=0" is already present. And it still queries for the annoying question, even when asked and answered ad nauseum.
    Adobe should in the very next update, as a minimum, make it such, that the chosen value in "Choose your update method:" remains PERMANENT and FOR EVER until the user changes it. It is WILDLY annoying to have to answer this question over and over and over and over and over and over again. Make a new value or something that will be written to the mms.cfg file, that will permanently understand this setting, I Want to update, but I want to know when and how and why, and I especially want to do it myself - Automatic updates can for novice users be nice, until it screws up the entire system - but for super user level or above it is an annoyance, that programs do not respect the answers of the user. It SHOULD ask this question ONCE, and never ever there after - unless the user changes the behaviour, in e.g. the mms.cfg file.
    I hope this is crystal clear --- it should be, and I cannot fathom that millions of other users are not annoyed by this popup box ... When i press "DONE" ... it should be EXACTLY THAT - notify me to install updates, BUT NOT to ask it every time what "update method" i want to use -- i've only told you a million times before --- just freaking get the answer and understand it.
    Annoyed regards : CyberstormXIII

  • Early delta initialization and update methods

    Hi gurus
    Can we use EDI with "queued delta" as update method?
    If yes where we need to do that setting and if no then would you pl tell me which functionality we need to use in infopkg to load delta from R/3 with Queued delta as a update method?
    Pl help to understand this.
    Thanks

    In the 'update' mode in your infopackage, if you see an 'early delta init' option, you can use it for that datasource (for queued or any other delta). This is where you choose to run an 'early delta init'.

  • Update methode in model-view-controller-pattern doesn't work!

    I'm writing a program in Java which contains several classes. It must be possible to produce an array random which contains Human-objects and the Humans all have a date. In the program it must be possible to set the length of the array (the number of humans to be produced) and the age of the humans. In Dutch you can see this where is written: Aantal mensen (amount of humans) and 'Maximum leeftijd' (Maximum age). Here you can find an image of the graphical user interface: http://1.bp.blogspot.com/_-b63cYMGvdM/SUb2Y62xRWI/AAAAAAAAB1A/05RLjfzUMXI/s1600-h/straightselectiondemo.JPG
    The problem I get is that use the model-view-controller-pattern. So I have a model which contains several methodes and this is written in a class which inherits form Observable. One methode is observed and this method is called 'produceerRandomArray()' (This means: produce random array). This method contains the following code:
    public void produceerMensArray() throws NegativeValueException{
         this.modelmens = Mens.getRandomMensen(this.getAantalMensen(), this.getOuderdom());
    for (int i = 0; i < this.modelmens.length; i++) {
              System.out.println(this.modelmens.toString());
    this.setChanged();
    this.notifyObservers();
    Notice the methods setChanged() and notifyObservers. In the MVC-patterns, these methods are used because they keep an eye on what's happening in this class. If this method is called, the Observers will notice it.
    So I have a button with the text 'Genereer' as you can see on the image. If you click on the button it should generate at random an array. I wrote a controller with the following code:
    package kristofvanhooymissen.sorteren;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    /**Klasse GenereerListener.
    * @author Kristof Van Hooymissen
    public class GenereerController implements ActionListener {
         protected StraightSelectionModel model;
         /**Constructor.
         *@param model Een instantie van het model wordt aan de constructor meegegeven.
         public GenereerController(StraightSelectionModel model) {
              this.model = model;
         /**Methode uit de interface ActionListener.
         * Bevat code om de toepassing te sluiten.
         public void actionPerformed(ActionEvent arg0) {
         this.model=new StraightSelectionModel();
         try{
         this.model.produceerMensArray();
         } catch (NegativeValueException e){
              System.out.println("U gaf een negatieve waarde in!");
         this.model.setAantalMensen((Integer)NumberSpinnerPanel.mensen.getValue());
         this.model.setOuderdom((Integer)NumberSpinnerPanel.leeftijd.getValue());
    StraighSelectionModel is of course my model class. Nevermind the methods setAantalMensen and setOuderdom. They are used to set the length of the array of human-objects and their age.
    Okay. If I click the button my observers will notice it because of the setChanged and notifyObservers-methods. An update-methode in a class which implements Observer.
    This method contains the follow code:
    public void update(Observable arg0,Object arg1){
              System.out.println("Update-methode");
              Mens[] temp=this.model.getMensArray();
              for (int i = 0; i < temp.length; i++) {
                   OnbehandeldeLijst.setTextArea(temp[i].toString()+"\n");
    This method should get the method out of the model-class, because the produceerRandomArray()-methode which has been called by clicking on the button will save the produce array in the model-class. The method getMensArray will put it back here in the object named temp which is an array of Mens-objects (Human-objects). Then aftwards the array should be put in the textarea of the unsorted list as you could see left on the screen on the image.
    Notice that in the beginning of this method there is a System.out.println-command to print to the screen as a test that the update-method has been called.
    The problem is that this update method won't work. My Observable class should notice that something happened with the setChanged() and notifyObservers()-methods, and after this the update class in the classes which implement Observer should me executed. But nothing happenens. My controllers works, the method in the model (produceerRandomArray() -- produce random array) has been executed, but my update-method won't work.
    Does anyone has an explanation for this? I have to get this done for my exam an the 5th of january, so everything that could help me would be nice.
    Thanks a lot,
    Kristo

    This was driving me nuts, I put in a larger SSD today going from a 120GB to a 240GB and blew away my Windows Partition to make the process easier to expand OS X, etc.  After installing windows again the only thing in device manager that wouldn't load was the Bluetooh USB Host Controller.  Tried every package in Bootcamp for version 4.0.4033 and 5.0.5033 and no luck.
    Finally came across this site:
    http://ron.dotsch.org/2011/11/how-to-get-bluetooth-to-work-in-parallels-windows- 7-64-bit-and-os-x-10-7-lion/
    1) Basically Right click the Device in Device manager, Go to Properties, Select Details tab, Choose Hardware ids from Property Drop down.   Copy the shortest Value, his was USB\VID_05AC&PID_8218 
    2) Find your bootcamp drivers and under bootcamp/drivers/apple/x64 copy AppleBluetoothInstaller64 to a folder on your desktop and unzip it.  I use winrar to Extract to the same folder.
    3) Find the files that got extracted/unzipped and open the file with notepad called AppleBT64.inf
    4) Look for the following lines:
    ; for Windows 7 only
    [Apple.NTamd64.6.1]
    ; No action
    ; OS will load in-box driver.
    Get rid of the last two lines the following:
    ; No action
    ; OS will load in-box driver.
    And add this line, paste your numbers in you got earlier for USB\VID_05ac&PID_8218:
    Apple Built-in Bluetooth=AppleBt, USB\VID_05ac&PID_8218
    So in the end it should look like the following:
    ; for Windows 7 only
    [Apple.NTamd64.6.1]
    Apple Built-in Bluetooth=AppleBt, USB\VID_05ac&PID_8218
    5) Save the changes
    6) Select Update the driver for the Bluetooth device in device manager and point it to the folder with the extracted/unzipped files and it should install the Bluetooth drivers then.
    Updated:
    Just found this link as well that does the same thing:
    http://kb.parallels.com/en/113274

  • "Direct Delta" Update Method - Why need for Collective update

    Hi folks,
    I have been going through LO Cockpit in detail and read quite extensively about new update methods and still have one doubt.
    1)Why there is "Job control" for "Direct Delta" Update method in LO Cockpit?.
    If I understand Direct Delta correctly, Application data is directly posted to Delta Queue by SAP Update management using V1 and when the Delta request comes from BW it is read from the Delta queue. So...
    2)why bother about collective run and
    3)where exactly are we going to collect from - there is no intermediate storage like extraction Q or update tables?
    One more question. I noticed that Delta queue is a stopped qRFC. what does this mean?

    Hi Jay,
    These questions have been answered by Roberto Negro in full detail of his 3 episode Blog...
    Please read his blog.
    Click Weblogs above and search for Roberto Negro.
    --Jkyle

  • Web Services 2.0 Update Method

    Hi, I'm using the update method but I'm only able to make it work with string value, it doesn't work with bool, number, currency, date....Any thoughts???
    Thanks

    Hi,
    We are having the same problem, could you post the code you used to resolve this?
    Thanks,
    Carlos

  • Problem with Update method in Applet..............

    Hi,
    i have a textfield and Button in my Applet. Applet is running locally. if i typed my directory in the textfield and press the reterive button means Applet has to display all the images in that paticular directory. Actually in the button's action performed method i am storing all the file names in the string array. Then i am going through the loop and trying to display the images side by side by increasing X co-ordinate value in the drawImage. But what is happening is, it is displaying last image only not all the images. ie repaint is not calling my update method for each time. it is calling at the end of loop only.
    In the paint method i am calling super.paint(Graphics g). the simillar way do i need to call the update method
    can you give me some idea
    the code is
    public void init() {
    try {
    image = getImage(new URL("file:///c:/Nainar/logo.jpg"));
    catch (Exception e) {
    e.printStackTrace();
    public void paint(Graphics g) {
    update(g);
    public void update(Graphics g) {
    g.drawImage(image,startX,startY,this);
    super.paint(g);
    void jButton1_actionPerformed(ActionEvent e) {
    String location = textFieldControl2.getText();
    if( location != null) {
    File filePath = new File(location);
    if( filePath.isDirectory()) {
    String fileList[] = filePath.list();
    imageFileName = new String[fileList.length];
    for( int i = 0; i < fileList.length; i++) {
    if( fileList.endsWith(".jpg")) {
    try {
    imageFileName[i] = location+"/"+fileList[i];
    image = getImage(new URL("file:///"+location+"/"+fileList[i])).getScaledInstance(100,100,Image.SCALE_DEFAULT);
    startX += 50;
    System.out.println("File Name : "+imageFileName[i]);
    // i guess problem i here repaint is not calling my update method evry time
    repaint();
    }catch(MalformedURLException murle) {
    System.out.println(murle.toString());
    Thanks in advance
    null

    Learn about the distinction between a data model and its visualisation, and maybe MVC. Then realize that the painted stuff on the canvas is no usable data model and can't be modified after it was painted but needs to be redrawn completely. Then start again.

  • Graphic update method

    I have moving Graphics in a JPanel that are updated via Runnable with a call to repaint. I'm working on changing my code to help reduce image flickering.
    Based on my research, it seems I should make use of the update method along with repaint to reduce the amount of flickering. As I understand it, the update method does not clear the image before repaint rather it repaints on top of the old image. Is that interpretation correct?...or does it "replace" the previous image first, THEN clears the old image?

    The existing update() method clears the graphics by drawing the background color all over it, and the it calls paint(), which you have presumably overridden with your drawing code.
    If you override update() and put your drawing code there, then you draw without erasing the old stuff.
    But that alone probably isn't what you want, and won't do much to prevent flickering, and will leave artifacts of the previous image as well. Generally one overrides update() because the clearing of the screen is unnecessary, usually because one is doing double buffering.
    In double buffering, you draw to an undisplayed image, and then draw the image to the graphics.

  • Documents Update method and datasources

    Hi all,
    I ve done a piece of code for updating an UDF at level line of an order when a target delivery is added. The update must be done when BeforeAction is true. This way when the user adds a new delivery, the code will update the lines of the base orders (base order of each line) and after that BO will do its updates (like closing the line if it's nedeed). For doing this i use the datasources of the form for reading the intformation, due to BeforeAction is true and the actual document is not still added. The problem is that the update method (of the order) doesn`t finish and i don`t receive any exception. Other way, if i don´t use the datasources for reading the information (if i do it using UI API), the update method works well. This is the method using DataSource:
            private void updatePiezasPtesDs(string formUid, string nombreTabla)
                Form form = kernel.Application.Forms.Item(formUid);
                try
                    Matrix mtx = form.Items.Item("38").Specific as Matrix;
                    DBDataSource ds = form.DataSources.DBDataSources.Item(nombreTabla);
                    for (int i = 0; i < mtx.VisualRowCount; i++)
                        mtx.GetLineData(i + 1);
                        if ((ds.GetValue("BaseEntry", 0) != null) &&  //IF THIS LINE HAS BASE DOCUMENT
                            (ds.GetValue("BaseEntry", 0).Length > 0))
                            int baseEntry = int.Parse(ds.GetValue("BaseEntry", 0).ToString().Trim());                   
                            if (baseEntry > 0)
                                Documents docOrigen = kernel.getDoc(baseEntry, BoObjectTypes.oPurchaseOrders, kernel.Company); //GET THE BASE DOCUMENT OF THIS LINE
                                int baseLine = int.Parse(ds.GetValue("BaseLine", 0).ToString().Trim());
                                if (!esBaseCero(baseEntry, "POR1"))
                                    baseLine--; //IF THE BASE DOCUMENT WAS DUPLICATED, THE BASE INDEX WILL BE 1 INSTEAD OF 0
                                docOrigen.Lines.SetCurrentLine(baseLine);
                                double oldValue = Convert.ToDouble(docOrigen.Lines.UserFields.Fields.Item("U_ITOP_PiezasOpenQty").Value.ToString().Trim().Replace(".", ","));
                                double recibido = Convert.ToDouble(ds.GetValue("U_ITOP_PiezasQty", 0).ToString().Trim().Replace(".", ","));
                                double newValue = oldValue - recibido;
                                docOrigen.Lines.UserFields.Fields.Item("U_ITOP_PiezasOpenQty").Value = (newValue > 0) ? newValue : 0;
                                int error = docOrigen.Update();  //THIS METHOD DOESN`T FINISH
                catch (Exception ex)
                    kernel.Application.MessageBox(ex.Message, 0, "", "", "");
    I tried to chek the last error after update method but the method doesn`t finish.
    Other way, when i read the information by accesing directly to the cells of the matrix:
                        int baseEntry = int.Parse((mtx.Columns.Item("45").Cells.Item(i + 1).Specific as EditText).Value.Trim());                
                            double oldValue = Convert.ToDouble(docOrigen.Lines.UserFields.Fields.Ite("U_ITOP_PiezasOpenQty").Value.ToString().Trim().Replace(".", ","));
                            double recibido = Convert.ToDouble((mtx.Columns.Item("U_ITOP_PiezasQty").Cells.Item(i + 1).Specific as EditText).Value.Trim().Replace(".", ","));
                            double newValue = oldValue - recibido;
                            docOrigen.Lines.UserFields.Fields.Item("U_ITOP_PiezasOpenQty").Value = (newValue > 0) ? newValue : 0;
                            int error = docOrigen.Update();
    It works well!!. I don´t know if i`m losing something but AFAIK the best way for reading the information of the actual form is using its datasources. Please if someone knows something about this it will be very helpful for me.
    Thanks,
    Edited by: Nauzet Diaz on Jul 29, 2008 11:46 AM
    Edited by: Nauzet Diaz on Jul 29, 2008 12:32 PM

    Hi all,
    i'm still having problems with dbdatasources and update documents. I've written this in FormDataEvent
               //UiApp_FormDataEvent
                if ((BusinessObjectInfo.FormTypeEx.Equals(FORM_PEDIDOCOMPRAS)) &&  //PURCHASE ORDERS
                    (BusinessObjectInfo.EventType.Equals(BoEventTypes.et_FORM_DATA_UPDATE)) &&
                    (BusinessObjectInfo.BeforeAction))
                      procesarModificaciones(form);  //"form" ORIGINATED THE EVENT
    The method procesarModificaciones(Form form) is:
           private void procesarModificaciones(Form form)
                DBDataSource ds = form.DataSources.DBDataSources.Item("OPOR");
                int docEntry = int.Parse(ds.GetValue("DocEntry", 0).Trim());
                Documents doc = kernel.Company.GetBusinessObject(BoObjectTypes.oPurchaseOrders) as Documents;
                doc.GetByKey(docEntry);
                Matrix mtx = form.Items.Item("38").Specific as Matrix;
                try
                    ds = form.DataSources.DBDataSources.Item("POR1");
                    for (int i = 0; i < doc.Lines.Count; i++)
                        doc.Lines.SetCurrentLine(i);
                        string itemCodeObj = doc.Lines.ItemCode;
                        int order = doc.Lines.VisualOrder + 1;
                        mtx.GetLineData(order);
                        string itemCodeForm = ds.GetValue("ITEMCODE", 0).Trim();
                catch (Exception ex)
                    kernel.Application.MessageBox(ex.Message, 0, "", "", "");
    I'm only exploring the business object (documents) order and the form at the same time. But this code throw this error (no sense):
    "Another user-modified table budget OBGT (ODBC 2039) Message 131-283"
    I've not used the table budget.
    I think that the problem is related with mtx.GetLineData() because when i comment the line the error doesn't appear but, of course, the method doesn't work properly. It seems like some transaction doesn't finish and the update doesn't work due to that.
    The same code using UI API instead of DbDataSources works well again:
            private void procesarModificaciones(Form form)
                DBDataSource ds = form.DataSources.DBDataSources.Item("OPOR");
                int docEntry = int.Parse(ds.GetValue("DocEntry", 0).Trim());
                Documents doc = kernel.Company.GetBusinessObject(BoObjectTypes.oPurchaseOrders) as Documents;
                doc.GetByKey(docEntry);
                Matrix mtx = form.Items.Item("38").Specific as Matrix;
                try
                    ds = form.DataSources.DBDataSources.Item("POR1");
                    for (int i = 0; i < doc.Lines.Count; i++)
                        doc.Lines.SetCurrentLine(i);
                        string itemCodeObj = doc.Lines.ItemCode;
                        int order = doc.Lines.VisualOrder + 1;
                        string itemCodeForm = (mtx.Columns.Item("1").Cells.Item(order).Specific as EditText).Value.Trim();
                catch (Exception ex)
                    kernel.Application.MessageBox(ex.Message, 0, "", "", "");
    Using UI API always for reading information from forms is not a good programming practice then help please,
    Regards.

  • Different types of Update Methods.

    Hi,
    1) Can we go for full load after inti with data.?
    2) Can you tell me the order of goin in update methods?
    Thanks,
    Naresh.

    Hi,
    1) Can we go for full load after inti with data.?
    Yes you can
    2) Can you tell me the order of goin in update methods?
    Init-->Delta
    Init-->Full
    Init without data transfer-->Full-->Delta
    Init-->Full-->Delta
    Like that, it depends on requirement
    http://help.sap.com/saphelp_nw70/helpdata/en/44/97430b99ee70dbe10000000a1553f6/content.htm
    Thanks
    Reddy

  • What exactly is Update method Master data attrib with a Time dependency ?

    Hi Experts,
    I have a Update rule in which i have an Update Method  "Master Data Attrib of " with Time dependency
    basically we are loading (update rule of )   0PAYROLL AREA ,
                  at Master data attribute of  we have 0EMPLOYEE
                  at Time Dependency When reading Master Data  END radio button is checked
                  frm it is mention as 0CALDAY.
    please explain what is function of 0calday here?
    I understand that 0PAYROLL AREA is a attribute of 0Employee and since from R/3 we are getting only 0EMPLOYEE so we are filling it from 0employee but  what is the significance of 0CALDAY here?
    Regards,
    RG

    Hi RG,
    It fills the valid value of 0PAYROLL for a particular 0EMPLOYEE in a particular time frame.
    Elaboration.
    Say  Employee          Payroll                  Valid from          Valid to
            RG                    1000000                 01.01.2007        31.12.2007
            RG                    2000000                 01.01.2008        31.12.2008
            RG                    3000000                 01.01.2009        31.12.2009
    The if your transaction data has RG employee in it with a transaction on 0CALDAY = 12.05.2007 then the valid payroll at that time would be 100000.
    On Calday 05.05.2009 your payroll would be 300000.........
    So for different days different payroll values would be valid.
    You require calday to find out which payroll value is valid in the timeframe of a transaction.
    In your update rule it is bringin the value of valid attribute value for the time of the transaction.
    Hope it helps,
    Regards,
    Sunmit.

Maybe you are looking for

  • IPod is not recognized in windows

    My iPod is not recognized in either Windows 7 or iTunes.  The iPod was jail breaked and that may have an impact.  I did a reset to remove all files and now all I can do with it is view the logo on the screen.  Help.

  • Embedded CFF font not working in TLF in latest stable build and higher (4.0.0.13875)

    Hi there, We are using embedded fonts with the TLF framework and since upgrading to the latest nightly build or the stable build, it stopped working. Here is a short example: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.a

  • I cant update message says i dont own major version

    I have a brand new imac and the app store says I need to update iPhoto.  When I try to do so, I get a message that says "you cannot update this software because you have not owned a major version of this software".  I tried logging back in but get th

  • FAQ: Why isn't the anchor point centered in shape layers?

    [UPDATE: In After Effects CC (12.1) and later, you can center the anchor point within the visible content of a layer. ] Short answer Because in shape layers you can have two distinct kinds of anchor points - the anchor point in the main transform pro

  • HT4489 Importing contacts from ACT

    Anyone have any experience with importing/syncing contacts from ACT! 2013 Pro into iCloud?