Treeset class assistance

I'm having trouble trying to use the Treeset Class.
Can anyone offer some basic instructions on how to create a priority queue using the Treeset class.

I have given this some thought and the best way I think is to introduce an ordernumber. Each new record that goes into the priority queue is given the current ordernumber which is then incremented. Each record can now be uniquely defined by a combination of the prioritynumber and the ordernumber, like (prioritynumber << 32) | ordernumber. The records will then be sorted by the prioritynumber and within each priority by their ordernumber. Simple code example,
public class Record {   // data record
    public int order;
    public int priority;
    public String data;
    public Record(int o, int p, String d) {
        order = o;
        priority = p;
        data = d;
public void test() {
    Comparator byPriority = new Comparator() {  // defines the order between records
        public int compare(Object o1, Object o2) {
            Record r1 = (Record)o1;
            Record r2 = (Record)o2;
            long l1 =  (((long)r1.priority) << 32) | ((long)r1.order);
            long l2 =  (((long)r2.priority) << 32) | ((long)r2.order);
            int r = 0;
            if (l1<l2)
                r = -1;
            else if (l1>l2)
                r = 1;
            return r;
    TreeSet pQ = new TreeSet(byPriority);   // the priority queue
    int order=0;    // each new record is given a unique order number
    pQ.add(new Record(order++,1,"A"));  // load records
    pQ.add(new Record(order++,2,"B"));
    pQ.add(new Record(order++,5,"C"));
    pQ.add(new Record(order++,1,"D"));
    pQ.add(new Record(order++,1,"E"));
    pQ.add(new Record(order++,0,"F"));
    System.out.println("TreeSet");      // print
    while (!pQ.isEmpty()) {
        Record r = (Record)pQ.first();
        pQ.remove(r);
        System.out.println(r.priority+"/"+r.order+"/"+r.data);
}   // test

Similar Messages

  • Assistance Class Problem

    Hi,
    I am using assistance class in my program for removing the errors of DB_SELECT
    Bcause of this assistance class my application become very slow .
    Can any tell fisible soln for that

    pankaj aggarwal wrote:
    And also use function modules for select queries not assistant classes. assistant classes are used when the same thing need to be used in more than one component.
    Yes you can use assistant classes for data sharing and reuse. But they are also very useful for implementing the abstraction of the MVC coding paradigm.
    An assistance class can ensure that all data access (model part of MVC)  is separated from your visual representation and control (Controller and View parts of MVC).
    And function modules are an outdated coding practice - embrace OO!
    - Chris

  • Using TreeSet, how to list in ascending order....

    hi i need to use TreeSet class
    and i need to list the list of books in order of ISBN number
    and also in order of author..
    both in ascending order..
    ivebeen thinking for long long time but..can't figure it out..
    please help me guys thanks

    The Java� Tutorial - Object Ordering
    Making Java Objects Comparable

  • Circular linked list while loop

    i have a circular linked list and i'd like a while loop to iterate though all of them. my problem is that it always excludes the last node. i know why, it's due to the fact that "current.next != alive" skips it from ever accessing the last node. i can't seem to solve it. note that the last node in the list points to the first node (alive):
                   while(current.next != alive )
                        prev = prev == null ? prev = alive : prev;
                        //identify the name with it's matching node
                        if(name.equals(current.name.toLowerCase()))
                             prev.next = current.next;
                             dead = current;
                             current = current.next;
                             dead.next = null;
                             while(dead.next != null)
                                  dead = dead.next;
                        else
                             prev = current;
                             current = current.next;     
                   }

    //this class assists the client in managing a game of assassinations. it does so by providing options such as verifying a target's existence, getting the list of dead people, getting the lsit of alive people, and moving people from the alive to dead list
    public class AssassinManager
         private AssassinNode alive;
         private AssassinNode alive_tail;
         private AssassinNode dead;
         //pre: must send a string array
         //post: nodes are created
         public AssassinManager(String[] names)
              dead = null;
              alive = new AssassinNode(names[0]);
              AssassinNode current = alive;
              System.out.println(names[0] + " is first, " + names[(names.length-1)] + " is last\n\n");
              for(int i = 1; i < names.length; i++)
                   while(current.next != null)
                        current = current.next;
                   current.next = new AssassinNode(names);
              alive_tail = current.next = new AssassinNode(names[(names.length - 1)], alive);
         //post: outputs all the people still alive
         public void printKillRing()
              AssassinNode last = null, current = alive;
              while(current.next!= alive)
                   System.out.println(current.name + " is stalking " + current.next.name);
                   last = current.next;
                   current = current.next;
              System.out.println(current.name + " is stalking " + alive.name);
         //post: outputs a list of the dead people
         public void printGraveyard()
              AssassinNode last = null, current = dead;
              while(dead != null)
                   System.out.println(current.name + " was killed by " + current.killer);
                   last = current.next;
                   current = current.next;
         //pre: must send a string name
         //post: will return true/false depending on the input if the name is in the killing ring (alive)
         public boolean killRingContains(String name)
              AssassinNode current = alive;
              name = name.toLowerCase();
              while(current.next!= alive)
                   if(name.equals(current.name.toLowerCase()))
                        return true;
                   current = current.next;
              return false;
         //pre; must send a string name
         //post: will return true/false if the name is in the graveyard list
         public boolean graveyardContains(String name)
              AssassinNode current = dead;
              name = name.toLowerCase();
              while(dead != null && current.next != null)
                   if(name.equals(current.name.toLowerCase()))
                        return true;
                   current = current.next;
              return false;
         //post: checks if game is over by seeing if there is more than 1 player
         public boolean gameOver()
              AssassinNode current = alive;
              if(current.next == null)
                   return true;
              return false;
         //post: outputs the winner's name
         public String winner()
              AssassinNode current = alive;
              if(current.next == null)
                   return alive.name;
              return null;
         //pre: must send a string name that exists is alive
         //post: will remove the user from the alive list and add it to the killed list
         public void kill(String name)
              //check if person exists to remove them from alive list
              if(killRingContains(name.trim()) == true)
                   AssassinNode prev = null, current = alive, dead = this.dead;
                   name = name.toLowerCase();
                   while(current != null)
                        System.out.println(current.name);
                        if(name.equals(current.name.toLowerCase()))
                             prev = prev == null ? alive_tail : prev;
                             prev.next = current.next;
                             //dead = dead == null ? current : dead;
                             //while(dead.next != null)
                                  //dead = dead.next;
                             if(prev.next == alive)
                                  break;
                             current = prev.next;
                        else
                             if(current.next == alive)
                                  break;
                             prev = current;
                             current = current.next;
    }Edited by: ixxalnxxi on Apr 27, 2008 12:58 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Date time picker script does not look right when calender pops up

    When I use this script in my header, my date time picker does not look right.  The pop up calender works but the layout is off,  here is the code I am adding to my header:
    <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
        <link rel="style.css" type="text/css" media="screen"
         href="http://tarruda.github.com/bootstrap-datetimepicker/assets/css/bootstrap-datetimepicker.min .css">
    And here is the code I am adding to the body of the html page below: Is it the placement of the code in the header? I've tried the beginning and the end of the hearder but no difference.  Thanks for your time on this....
    <div id="datetimepicker" class="input-append date">
    <input type="text"></input>
    <span class="add-on">
    <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
    </span>
    </div>
    <script type="text/javascript"
    src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js">
    </script>
    <script type="text/javascript"
    src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js">
    </script>
    <script type="text/javascript"
    src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min. js">
    </script>
    <script type="text/javascript"
    src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.pt-B R.js">
    </script>
    <script type="text/javascript">
    $('#datetimepicker').datetimepicker({
    format: 'MM/dd/yyyy hh:mm:ss',
    language: 'en'
    </script>

    Page is not up yet, can I attach the html to this forum?  I'l cut and paste the html below, thanks
    <!DOCTYPE html>
    <!-- Consider specifying the language of your content by adding the `lang` attribute to <html> -->
    <!--[if lt IE 7]> <html class="no-js ie6"> <![endif]-->
    <!--[if IE 7]>    <html class="no-js ie7"> <![endif]-->
    <!--[if IE 8]>    <html class="no-js ie8"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
    <!-- this is the header code for the date/time picker-->
      <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
        <link rel="style.css" type="text/css" media="screen"
         href="http://tarruda.github.com/bootstrap-datetimepicker/assets/css/bootstrap-datetimepicker.min .css">
          <!-- to here-->
        <meta charset="utf-8">
        <!-- Always force latest IE rendering engine & Chrome Frame -->
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <!-- Put your title here! -->
        <title>Hawaii Beach Weddings</title>
        <meta name="description" content="">
         <!-- Mobile viewport optimized: j.mp/bplateviewport -->
        <meta name="viewport" content="width=device-width">
        <link href="style.css" rel="stylesheet">
        <!-- Load Open Sans and Merriweather from Google Fonts
            For optimal performance, customize it to load the styles you need:
            http://goo.gl/QufgJ
        -->
        <link href="//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700|Merriweathe r:400,700,900" rel="stylesheet">
        <!-- All JavaScript at the bottom, except for Modernizr
            Modernizr enables HTML5 elements & feature detects; It includes Respond, a polyfill for min/max-width CSS3 Media Queries
            For optimal performance, use a custom Modernizr build: www.modernizr.com/download/ -->
            <script src="js/modernizr-2.6.1.min.js"></script>
        <script src="js/modernizr-2.6.1.min.js"></script>
    </head>
    <body>
        <!-- Prompt IE 6 and 7 users to install Chrome Frame:        chromium.org/developers/how-tos/chrome-frame-getting-started -->
        <!--[if lt IE 8]>
            <p class="chromeframe alert alert-warning">Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p>
        <![endif]-->
        <header id="master-header" class="clearfix" role="banner">
            <hgroup>
                <h1 id="site-title"><a href="index.html" title="Your Site Name">Hawaii Beach Weddings</a></h1>
                <h1 id="site-title2"><a href="index.html" title="Your Site Name">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</a></h1>
                <h2 id="site-description">Where the Sun, Sand and Love come together...</h2>
            </hgroup>
        </header> <!-- #master-header -->
    <div id="main" class="row">
        <!-- Main navigation -->
        <nav class="main-navigation span12 clearfix" role="navigation">
            <h3 class="assistive-text">Main menu</h3>
            <ul>
                <li><a href="index.html">Home</a></li>
                <li class="current">
                    <a href="about.html">About</a>
                    <ul class="sub-menu">
                        <li><a href="http://www.google.com">Subpage 1</a></li>
                        <li><a href="#">Subpage 2</a></li>
                    </ul>
                </li>
                <li><a href="contact.html">FAQ's</a></li>
            </ul>
        </nav> <!-- #main-navigation -->
    <div id="content" role="main" class="span12">
        <article class="page hentry">
            <header class="entry-header">
                <h1 class="entry-title">Simple Beach Weddings</h1>
            </header> <!-- .entry-header -->
            <div class="entry-content">
                <p>We specialize in simplicity for your beach wedding.  Let us keep it simple by offering what you need to make your beach wedding easy </p>
                <!-- Typography
                ================================================== -->
                <section id="typography">
                    <h1>I am first a photographer who loves to<small></small>capture &quot;the moment.&quot;</h1>
                    <p>By organizing Hawaii Beach Weddings, I have allowed myself to do what I do best: capture your moment. I use industry professionals to make a sometimes stressful event easy. By keeping it to a few simple choices: A Minister (necessary), Flowers, Music, Video, Chairs (optional), I have allowed you to quickly design your wedding event and enjoy your stay in the islands. </p>
                        <div class="row">
                            <div class="span7">
                                <h2>Ministers:</h2>
                                <h3>Reverand Robert Hoyt</h3>
                                                <p> </p>
                            </div>
                    </div>
                      <h2> </h2>
                        <div class="row"></div>
                        <div class="row">
                  </div>
                    <h2> </h2>
                </section>
                <section id="tables">
                  <div class="row">
                  </div> <!-- .row -->
                </section> <!-- #tables -->
                <!-- Forms
                ================================================== -->
                <section id="forms">
                    <h1>Let's begin with your contact information.</h1>
                    <form class="row">
                        <fieldset class="span5">
                          <p>
                            <label>Name
                              <input type="text" required></label></p>
                              <br>
                              <p><label>Phone number with area code <input type="text" pattern="\d{5}(-\d{4})?" title="a US Zip code, with or without the +4 exension" placeholder=" 123-456-7891"></label></p>
                              <br>
                              <p>
                              <label>Email
                              <input type="email"></label></p>
                              <br>
                              <h1>Where would you like your wedding to be?</h1>
                 <p><label>Honolulu (South Oahu)<input type="radio" name="rad"></label></p>
                 <p><label>Waimanalu (East Oahu) <input type="radio" name="rad"></label></p>
                    <br>     
                    <h1>What date & time would you like to have your wedding?</h1>
                     <!--This is the date/time picker-->
                          <div id="datetimepicker" class="input-append date">
          <input type="text"></input>
          <span class="add-on">
            <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
          </span>
        </div>
        <script type="text/javascript"
         src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js">
        </script>
        <script type="text/javascript"
         src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js">
        </script>
        <script type="text/javascript"
         src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min. js">
        </script>
        <script type="text/javascript"
         src="http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.pt-B R.js">
        </script>
        <script type="text/javascript">
          $('#datetimepicker').datetimepicker({
            format: 'MM/dd/yyyy hh:mm:ss',
            language: 'en'
        </script>
        <br>
                         <h1>What type of flowers would you like to have?</h1>
                         <p>
                                <label>Bouquet<br>
                                    <select>
                                        <option>None</option>
                                        <option>Red roses</option>
                                        <option>White roses</option>
                                        <option>Hibiscus</option>
                                    </select>
                                </label>
                            <p>
                                <label>Flowers<br>
                                    <select>
                                        <option>None</option>
                                        <option>Roses</option>
                                        <option>Orchids</option>
                                        <option>Hibiscus</option>
                                    </select>
                                </label>
                                  <h1>What type of Leis would you like to have?</h1>
                                <label>Leis<br>
                                    <select>
                                        <option>None</option>
                                        <option>Kukui nut (male)</option>
                                        <option>Orchids (inexpensive)</option>
                                        <option>Stephanotus (sweet smelling</option>
                                    </select>
                                </label>
    </fieldset>
    <fieldset class="span4">
                          <p>
                           <!--this is the chair number selector-->
                            <p>
                               <label>Music<br>
                                    <select>
                                        <option>None</option>
                                        <option>solo singer with ukulele</option>
                                        <option>solo singer with guitar</option>
                                        <option>solo guitar instrumental</option>
                                        <option>small ensemble</option>
                                    </select>
                                </label>
                              <br>
                              <label for="s">Number of Chairs</label><p>
                                <select id="s">
                                    <option>none</option>
                                    <option>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                    <option>6</option>
                                    <option>7</option>
                                    <option>8</option>
                                </select>
                            </p>
                            <p>
                              <label for="t">Notes</label> <textarea id="t" cols="30" rows="5">Textarea text</textarea></p>
                        </fieldset>
                <!-- Miscellaneous
                ================================================== --><!-- #miscellaneous -->
            </div> <!-- .entry-content -->
        </article> <!-- .post.hentry -->
    </div> <!-- #content -->
    </div> <!-- #main -->
        <footer id="footer" role="contentinfo">
            <!-- You're free to remove the credit link to Jayj.dk in the footer, but please, please leave it there -->
        </footer> <!-- #footer -->
        <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/jquery-1.7.2.min.js"><\/script>')</script>
        <!-- Load custom scripts -->
        <script src="js/script.js"></script>
    </body>
    </html>

  • Comparator Problem in understanding

    hello all please find query as below :
    /* program to alter the ordering of the elements in the collection class TREESET
    class Demo1 overrides compare() of Comparator interface
    which returns the int value.
    when 'return b1.compareTo(a1);' is used then the program output is as
         o/p:- vijay sunil shyjin rupesh ishwar
    i.e., names are displayed in ascending order
    when 'return a1.compareTo(b1);' is used then the program output is as
         o/p:- ishwar rupesh shyjin sunil vijay
    i.e., names are displayed in descending order
    How these change of ordering occurs ?
    import java.util.*;
    class Demo1 implements Comparator
         public int compare(Object a,Object b)
              String a1=(String) a;
              String b1=(String) b;
              return a1.compareTo(b1);
    class DemoComparator
         public static void main(String args[])
              TreeSet t=new TreeSet(new Demo1());
              t.add("sunil");
              t.add("ishwar");
              t.add("shyjin");
              t.add("rupesh");
              t.add("vijay");
              Iterator i=t.iterator();
              while(i.hasNext())
                   Object o=i.next();
                   System.out.print(o+" ");
              System.out.println();
    }

    Per the java docs:
    public interface Comparable
    This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method.
    Lists (and arrays) of objects that implement this interface can be sorted automatically by Collections.sort (and Arrays.sort). Objects that implement this interface can be used as keys in a sorted map or elements in a sorted set, without the need to specify a comparator.
    A class's natural ordering is said to be consistent with equals if and only if (e1.compareTo((Object)e2)==0) has the same boolean value as e1.equals((Object)e2) for every e1 and e2 of class C.
    It is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals. In particular, such a sorted set (or sorted map) violates the general contract for set (or map), which is defined in terms of the equals operation.
    For example, if one adds two keys a and b such that (a.equals((Object)b) && a.compareTo((Object)b) != 0) to a sorted set that does not use an explicit comparator, the second add operation returns false (and the size of the sorted set does not increase) because a and b are equivalent from the sorted set's perspective.
    Virtually all Java core classes that implement comparable have natural orderings that are consistent with equals. One exception is java.math.BigDecimal, whose natural ordering equates BigDecimals with equal values and different precisions (such as 4.0 and 4.00).
    For the mathematically inclined, the relation that defines the natural ordering on a given class C is:
    {(x, y) such that x.compareTo((Object)y) <= 0}.
    The quotient for this total order is:
    {(x, y) such that x.compareTo((Object)y) == 0}.
    It follows immediately from the contract for compareTo that the quotient is an equivalence relation on C, and that the natural ordering is a total order on C. When we say that a class's natural ordering is consistent with equals, we mean that the quotient for the natural ordering is the equivalence relation defined by the class's equals(Object) method:
    {(x, y) such that x.equals((Object)y)}.

  • Is this type casting?

    Set<AWTKeyStroke> keySet = new TreeSet<AWTKeyStroke>();
    Can anyone explain the above line.
    if it is type casting, then what type of casting is this?
    it means implict or explicit.

    That line of code relates to the language feature called 'Generics'. More specifically, it is creating an instance of the TreeSet class called keySet. It will only be possible to store into this collection - TreeSet - instances of the AWTKeyStoke class or of any sub-class. In a way, there is an implicit type cast as the TreeSet instance is being stored into a variable whose type is Set.

  • Do not seem to be able to backup iPad via iTunes on to my PC. Message after connecting is "iTunes was unable to load class information from Sync Services, Reconnect or try later"  Have tried that but get the same result. Can anyone assist?

    Do not seem to be able to backup iPad via iTunes on to my PC.
    Message after connecting is "iTunes was unable to load class information from Sync Services, Reconnect or try later" 
    Have tried that but get the same result.
    Remedies I've tried are:
    wait and try again
    reboot
    reload iTunes
    NB hp is a relatively new machine and has previously backed up quite happily.
    Can anyone assist?

    RHoodnkt-
    Try rebooting the iPad.  Hold down both the Home and Sleep buttons for several seconds until the Apple logo appears.  Ignore the "Slide to power off" arrow.  It takes a minute or two to restart.
    Also be sure your iPad battery is not completely discharged.
    Fred

  • To call standard tcode in webdynpro( thru webgui) : Assistance class

    Hi Gurus,
    I have an alv display in which the vbeln entries have link to action control.
    i.e when i click vbeln( sales order no), it should open a new window through its/webgui.
    1.I am getting following error when i activate , get_execute_location is private/protected.
    2. How do i go about the following code:
    wd_comp_controller->execute_get_location(
    IMPORTING
    e_host = lv_host
    e_out_protocol = lv_out_protocol
    e_port = lv_port ).
    Within my method of my assistance class I call an interface in class cl_http_server to procure my host,
    protocol and port number.
    CALL METHOD cl_http_server=>if_http_server~get_location
    IMPORTING
    host = e_host
    port = e_port
    out_protocol = e_out_protocol.
    Can some one explain in detail.
    Best Regards,
    Navin Fernandes.

    Hi Navin,
    To display a standard tcode in your webdynpro application using  ITS  you can use the following code
    DATA: url TYPE string,
            host type string,
            port type string.
    *Call below method to get host and port
      cl_http_server=>if_http_server~get_location(
         IMPORTING host = host
                port = port ).
    *create URL
      CONCATENATE 'http'
      '://' host ':' port
      '/sap/bc/gui/sap/its/webgui/?sap-client=&~transaction=' 'SE11'
       INTO url.
    *get the window manager as we are opening t code in external window.
      DATA lo_window_manager TYPE REF TO if_wd_window_manager.
      DATA lo_api_component TYPE REF TO if_wd_component.
      DATA lo_window TYPE REF TO if_wd_window.
      lo_api_component = wd_comp_controller->wd_get_api( ).
      lo_window_manager = lo_api_component->get_window_manager( ).
    *  call the url which we created above
      lo_window_manager->create_external_window(
      exporting
      url = url
      receiving
      window = lo_window ).
      lo_window->open( ).
    Hope this helps!
    Best Regards,
    Radhika Vadher.

  • Assistance class in Web dynpro ABAP

    step 1: Create WEB DYNPRO component. Example: Zwd_assist_class_test.
                 -save.
                -Active.  
    step 2: Assistance class on component(Zwd_assist_class_test)  screenwriter assist class name Example:Asistance_class.
    step3: Select the Assistance class name click on pop up new window .
    step4:Assistance class window methods  give method name
    step5: Select parameters of the methods  giving importing exporting table ,objects.
    step6:Select Attributes button given the attribute name Example:ET_MAR.
    For example methods READ_ONLY.
    coding for method: select * from <db_table> into table <ET_tab> where matnr between im_matnr1 and im_matnr2.
    I want using MARA,VBAK,VBAP tables data display in single table,creating two search fields .these are VBELN, MATNR
    how to write READ_ONLY method ?

    Hi Rajasekhar,
    The exporting parameters which you have declared can take only one record as its declared as work area. Instead you need to identify the table type and use like
    for MARA... MARA_TT
    for VBAK... VBAK_T
    for VBAP... VBAP_T
    but, for your requirement, you need not required to pass mara, vbak, vbap table data, instead you need to put into final internal table ET_result.
    I suggest you to create a table type ZTT_RESULT in SE11 which contains all your fields in the output.
    Now, inside READ_DATA( ) method you can do as below ( just an example)
    loop at lt_mara into ls_mara.
         move-corresponding ls_mara to ls_result.
         loop at lt_vbap into ls_vbap where matnr = ls_mara-vbeln.   
               move-corresponding ls_vbap to ls_result.
              read table lt_vbak into ls_vbak with key vbeln = ls_vbap-vbeln.
              if sy-subrc is initial.
                        move-corresponding ls_vbak to ls_result.
              endif.
         endloop.
    append ls_result to ET_RESULT.
    endloop.
    Hope this helps you.
    Regards,
    Rama

  • Assistance class not instantiated in the component controller of an ABAP WD

    I have a very weird problem when trying to launch an ABAP webdynpro I get a short dump, looking into it the assitance class does not get instantiated properly so it falls over.  It used to work, but I don't think I have substantially changed anything with the assitance class just on the layout, although something must have changed.
    In the constructor of the component controller it trys to cast (I think that is the correct term)  the assistance class from the compoent controller as below, Me->f_Alter_Ego->assistance_class is initial so that fails, it then tries to create the assistance class and falls over on create object Me->f_Assist.
      try.
        Me->f_Assist ?= Me->f_Alter_Ego->assistance_class.
      catch cx_sy_move_cast_error.    "#EC NO_HANDLER
      endtry.
      if not Me->f_Assist is bound.
        create object Me->f_Assist.
      endif.
    Extract from the short dump below.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "/1BCWDY/4LYS0NWZ8L8ENKKA93YQ==CP" had to be
         terminated because it has
        come across a statement that unfortunately cannot be executed.
        The following syntax error occurred in program
         "ZCL_WD_USER_MAINT=============CP " in include
         "ZCL_WD_USER_MAINT=============CM004 " in
        line 7:
        "You can only use "class=>method" with static methods."
    Other ABAP web dynpros in our system are fine.
    I have tried the obvious stuff like removing the assitance class from the WD component and putting it back in again.
    There is obviously somehting I am missing can anyone point me in the right direction or has experienced this before?
    Thanks,
    Tim

    Thanks Thomas,
    I could not see the wood for the trees on that one, I had syntax checked the assitance class ZCL_WD_USER_MAINT, however, that error would have been raised at runtime.
    Anyway all sorted now.
    Cheers,
    Tim

  • Data fetch for range of value inside an assistance class

    I want to create an assistance class where I can fetch data for the range of values selected ( basically when I select a range of sales order ).
    I was only only successfully in creating parameters, passing single values.
    Regards,
    Krishna.

    Hi Krishna,
    Logic to fetch the data of range ( implement in the method  )
       data : lv_matnr TYPE string VALUE 'MATNR',
                lr_matnr TYPE REF TO data.
    FIELD-SYMBOLS : <lr_matnr> TYPE ANY TABLE.
    ************ Method to call range of data ************************
    CALL METHOD wd_this->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD
      EXPORTING
        I_ID               = lv_matnr
      RECEIVING
        RT_RANGE_TABLE     = lr_matnr.
    ASSIGN lr_matnr->* to <lr_matnr>.
    *************** call the method of the assistance class
    wd_assist->GET_DATA( EXPORTING IR_MATNR = <lr_matnr> ).
    ****************** parameters of the method in the assistance class ********************
    Hope this helps you
    Thanks & Regards,
    Sankar Gelivi

  • Custom controller v Assistance Class

    Hi
    I have always used the assistance class to place all business logic.  I understand that this replaces the custom controller that is generally used for theis purpose in WDJ. Therefore, is the custom controller used much in WDA or is it largely redundant?
    Cheers
    Ian

    >
    Abhimanyu Lagishetti wrote:
    > Hi Ian,
    >
    >  It is not largely redundant as such, i can see two main reasons
    >
    >  1.  Configuration Controller, entire FPM is based on this. you can control the configuration of the WDA using custom controller
    >
    >  2. Business Logic, which belong to only current WDA can be put in Custom Controller so that it is more readable, where as in Assistance class we can use it in other applications when working in a team
    >
    > in both the cases you are following MVC
    >
    > Abhi
    1.  You are correct that configuration controllers are a useful feature of custom controllers; however FPM is not really based on this.  Custom Controllers/Configuration Controllers in your components are not a requirement of FPM.  In FPM your component implements a special Web Dynpro Component Interface.  The configuration of the FPM is done using component configuration of a standard SAP component.  Once again you can use Configuration Controllers in your FPM components like you would in any other component; but it is in no way a requirement to do so in order to use FPM.
    2.  Technically it is possible to place business logic in the custom controller, but my personal suggestion would be to not do so.  The context and context bindings carry a performance penalty and should only be used data that is needed by the layouts.  You end up creating custom controllers with logic that is locked into the component and only uses the attributes/methods.  What you end up with is a less useful class.  That is why I feel that using a normal ABAP class (possibly an Assistance Class) is the perfered way to go.
    I would add a third use: the service call wizards.  If you are going to use the wizards to generate calls to RFCs or other classes, it is often advisable to place this generated code into a custom controller (one of the wizard options). This is particularly useful if you are going to have more than one wizard call generated.  I guess you could make a case that this is the "business logic" that was being refered to in Item 2 above.  However I want would make the distinction that this is only the call to the business logic.

  • Relavance of assistant class in Webdynpro ABAP.

    When we can create a object for a class in the attributes tab of the component controller and acess the methods of the class directly, why do we need a assistant class.??
    Moderator message : Search for available information, post the question in Web Dynpro forum, thread locked
    Edited by: Vinod Kumar on Dec 22, 2011 3:09 PM

    Hai,
           In webdynpro ABAP,we use to write all the coding part within the component itself but there is a provision with which we can write the necessary business logic outside the component that is in a class and we can use that class as the assistance class in the current component. It is same as model class.

  • Select options range table to be passed to Assistance class

    Hi Guru's,
    I have an assistance class where I have to write all my select queries. I have a selection screen with multiple Select options (as input fields). Now I want to pass the select options range table to assistance class.
    Please let me know if you have any sample code for this which may also include building range tables for select options.
    Thanks,
    Pradeep

    Hi Pardeep,
    U can use following code: for field ERDAT
    data: rt_ERDAT      type ref to data,
            R_ERDAT       TYPE RANGE OF VIQMEL-ERDAT,
            R_ERDAT_line  LIKE LINE OF R_ERDAT,
    field-symbols: <fs_ERDAT> type table.
    Retrieve the data from the select option
      rt_ERDAT = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'ERDAT' ).
    Assign it to a field symbol
      assign rt_ERDAT->* to <fs_ERDAT>.
    copy field symbols to local variable
      R_ERDAT = <fs_ERDAT>.
    CALL METHOD WD_ASSIST->"METHOD_NAME"
          R_ERDAT        = R_ERDAT
    where in class method:
    R_ERDAT     Importing     Type     ZU5QNM_ERDAT_T
    ZU5QNM_ERDAT_T : is a table type of ZU5QNM_ERDAT_R
    and ZU5QNM_ERDAT_R has following structure :
    SIGN     ACE_SIGN     CHAR     1     0     Debit/Credit Sign (+/-)
    OPTION     ACE_OPTION     CHAR     2     0     Option for Ranges Tables
    LOW     ERDAT     DATS     8     0     Date on Which Record Was Created
    HIGH     ERDAT     DATS     8     0     Date on Which Record Was Created
    I hope this wiol solve ur problem.
    Regards,
    Vishal.

Maybe you are looking for

  • How do two  ipod's use one computer to download itunes?

    New to ipod's/itunes.  Family member already has an itune account set up on my computer to download music.  Can I set up my own account on the same computer to share the itunes program?

  • Trying to set up an out of the box SP 2010 approval workflow that doesn't generate warnings or errors

    I have a custom list for which I want an approval workflow.  There is only going to be one stop for the approval - creating an item is a request to a person for a new code to be created.  If I do not turn on content approval, then I get the message:

  • How to improve image quality

    I've been using Motion for a couple of years now and although I'm no expert, I'm really pleased with the possibilities. I mainly use it to create animations that are then watched on a computer - either on a CD or on the web. I've also done a few anim

  • Troubles in converting roman to arabic..pls HELP!!!

    i have a code here in converting roman to arabic and vice versa. the roman to arabic method is properly giving the correct output, then the arabic to numeral methos is malfunction..what i want is the ROMAN to ARABIC only,,,but im confuse on what to d

  • How to get a previous version of vyke freetxt for ...

    Hi there, i was using vyke freetxt (i dont know the exact version of it) happily till today when i deleted it by mistake. I went on and downloaded the new version (1.03) from vyke.com. There is something i hate in the new version. When i change the s