Class to another

Hi ca anybody help?
I've just started learning java and I'm stuck. I'm doing an OU course and created 2 objects, one simulates a frog and the other invokes a random number (RandomNumberGenerator). So how do I get the frog object to use a method from the other object? I want to move the frog randomly, using the method of the RandomNumberGenerator.
Jon

Hi and thanks,
Here is the code of the randomNumberGenerator:
public class RandomNumberGenerator
* This will generate a random number between 1 and 5.
     public int between1And5()
     return ((new Random()).nextInt(5) + 1);
Which as you know, thiswould give a random number between 1 and 5.
Which I want to use as part of the argument in the method of the Frog class, here is the code:
public class RandomFrog extends Frog
     * Constructor for objects of class RandomFrog
     public RandomFrog()
     super();
     * If the argument newPosition lies between 1 and 11 inclusive
     * the position of the receiver is set to the argument.
     * Otherwise position is set to 5.
     public void setPosition(int newPosition)
     if ((newPosition > 1 ) && (newPosition < 11 ))
super.setPosition(newPosition);
else
super.setPosition(5);
* Increments the position of the receiver, by the random
* number (between 1 and 5 inclusive).
public void randomLeft()
super.setPosition(getPosition() - Here is where I need to use the other class method);
Hope this is a bit clearer?
Jon.

Similar Messages

  • How to move the contents of an itab from one class to another...

    Hello Experts,
    How can I move the contents of an internal table for a given class to another class.
    I want to transfer the contents of my internal table lt_vbak to another class
    which is lcl_get_docflow. Below is my code:
    REPORT  zsd_orderstage
            NO STANDARD PAGE HEADING.
    * Data Dictionary Table/s                      *
    TABLES: vbak.
    * Global Structure/s                           *
    TYPES: BEGIN OF t_output,
            salesgroup    type vbak-vkgrp,
            salesorder    TYPE vbak-vbeln,
            custcode      TYPE vbak-kunnr,
            shipto        TYPE likp-kunnr,
            creation_date TYPE vbak-erdat,
            created_by    TYPE vbak-ernam,
            delorder      TYPE likp-vbeln,
            invnumber     TYPE vbrk-vbeln,
           END OF t_output.
    * Global Internal Table/s                      *
    DATA: gt_output TYPE STANDARD TABLE OF t_output.
    * SELECTION-SCREEN                             *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_kunnr TYPE vbak-kunnr OBLIGATORY.
    SELECT-OPTIONS: s_group for vbak-vkgrp,
                    s_auart FOR vbak-auart,
                    s_erdat FOR vbak-erdat  OBLIGATORY,
                    s_ernam FOR vbak-ernam.
    SELECTION-SCREEN END OF BLOCK b1.
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main DEFINITION ABSTRACT.
      PUBLIC SECTION.
        TYPES: BEGIN OF t_vbak,
              vbeln TYPE vbak-vbeln,
              erdat TYPE vbak-erdat,
              ernam TYPE vbak-ernam,
              auart TYPE vbak-auart,
              kunnr TYPE vbak-kunnr,
              vkgrp type vbak-vkgrp,
             END OF t_vbak.
        TYPES: BEGIN OF t_vbfa,
                vbelv   TYPE vbfa-vbelv,
                vbeln   TYPE vbfa-vbeln,
                vbtyp_n TYPE vbfa-vbtyp_n,
               END OF t_vbfa.
        TYPES: BEGIN OF t_likp,
                vbeln TYPE likp-vbeln,
                kunnr TYPE likp-kunnr,
               END OF t_likp.
        TYPES: BEGIN OF t_vbrk,
                vbeln TYPE vbrk-vbeln,
               END OF t_vbrk.
        DATA: gt_vbfa     TYPE STANDARD TABLE OF t_vbfa,
              gt_likp     TYPE HASHED TABLE OF t_likp
                          WITH UNIQUE KEY vbeln,
              gt_vbrk     TYPE HASHED TABLE OF t_vbrk
                          WITH UNIQUE KEY vbeln,
              gt_delivery TYPE STANDARD TABLE OF t_vbfa,
              gt_invoice  TYPE STANDARD TABLE OF t_vbfa.
    ENDCLASS.                    "lcl_main DEFINITION
    *       CLASS lcl_get_so DEFINITION
    CLASS lcl_get_so DEFINITION INHERITING FROM lcl_main.
      PUBLIC SECTION.
        DATA: lt_vbak TYPE STANDARD TABLE OF t_vbak.
        METHODS: get_sales_orders
                    RETURNING
                       value(re_vbak) TYPE t_vbak.
    ENDCLASS.                    "lcl_get_so DEFINITION
    *       CLASS lcl_get_so IMPLEMENTATION
    CLASS lcl_get_so IMPLEMENTATION.
      METHOD get_sales_orders.
        SELECT vbeln erdat ernam auart kunnr vkgrp
          FROM vbak
          INTO TABLE lt_vbak
         WHERE erdat IN s_erdat
           AND ernam IN s_ernam
           AND auart IN s_auart
           AND kunnr = p_kunnr.
      ENDMETHOD.                    "get_sales_orders
    ENDCLASS.                    "lcl_get_so IMPLEMENTATION
    *       CLASS lcl_get_docflow DEFINITION
    CLASS lcl_get_docflow DEFINITION INHERITING FROM lcl_main.
      PUBLIC SECTION.
        DATA: lt_vbfa TYPE STANDARD TABLE OF t_vbfa.
        METHODS: get_subsequent_docs
                    IMPORTING
                       value(im_vbak) TYPE t_vbak
                    EXPORTING
                       ex_vbfa TYPE t_vbfa.
    ENDCLASS.                    "get_docflow  INHERITING FRO
    *       CLASS lcl_get_docflow IMPLEMENTATION
    CLASS lcl_get_docflow IMPLEMENTATION.
      METHOD get_subsequent_docs.
      ENDMETHOD.                    "get_subsequent_docs
    ENDCLASS.                    "get_docflow IMPLEMENTATION
    * Global Internal Table/s                      *
    START-OF-SELECTION.
      DATA: o_get_so      TYPE REF TO lcl_get_so,
            o_get_docflow TYPE REF TO lcl_get_docflow.
      CREATE OBJECT: o_get_so,
                     o_get_docflow.
      CALL METHOD o_get_so->get_sales_orders.
    What I want is to pass the records of lt_vbak to method get_subsequent_docs. How do I do this guys?Thank you and take care!

    .

  • How to kill one class from another class

    I need to dipose one class from another class.
    So that first i have to find what are all threads running in that class and then to kill them
    Assist me.

    Subbu_Srinivasan wrote:
    I am explaining you in clear way
    No you haven't been.
    >
    In my application i am handling many JInternalFrame.Simultaneously i am running working on more than one frame.
    Due to some poor performance of some thread in one JInternalFrame,the thread is keeps on running .
    i could not able to proceed further on that screen.
    So i have to kill that JInternalFrame.Yoinks.
    To be begin with your problem sounds like you are doing everything in one thread. So stop doing that. Second when you get it split up and if a task is taking too much time then interrupt it. No kill. Interrupt. This means the worker thread needs to check sometimes if it has been interrupted.

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Calling a drawLine() from one class to another from an ActionEvent

    I have several JPanel objects called and placed on a JFrame. The JFrame has a RadioButton group with radio buttons. If I select a radio button and call a drawLine() method from a JPanel, I receive a "NullPointerException". Is it not possible to call this graphic method from one class to another?
    Thanks for any input you can provide.
    John

    Remember that each panel draws it's own current state. So you need the ActionPerformed to change the state in your target panel.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class PanelComm extends JPanel {
      private SubPanelOne subPanelOne = new SubPanelOne();
      private SubPanelTwo subPanelTwo = new SubPanelTwo();
      public class SubPanelOne extends JPanel {
        public SubPanelOne () {
          setLayout ( new BorderLayout() );
          setBorder ( BorderFactory.createTitledBorder ( "SubPanel One" ) );
          Reactor     reactor    = new Reactor();
          ButtonGroup group      = new ButtonGroup();
          JPanel      radioPanel = new JPanel(new GridLayout(0, 1));
          JRadioButton buttonOne = new JRadioButton ( "One" );
          buttonOne.addActionListener ( reactor );
          group.add ( buttonOne );
          radioPanel.add ( buttonOne );
          JRadioButton buttonTwo = new JRadioButton ( "Two" );
          buttonTwo.addActionListener ( reactor );
          group.add ( buttonTwo );
          radioPanel.add ( buttonTwo );
          JRadioButton buttonThree = new JRadioButton ( "Three" );
          buttonThree.addActionListener ( reactor );
          group.add ( buttonThree );
          radioPanel.add ( buttonThree );
          add ( radioPanel ,BorderLayout.LINE_START );
        protected void paintComponent ( Graphics _g ) {
          super.paintComponent ( _g );
          Graphics2D g = (Graphics2D)_g;
          g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
      public class SubPanelTwo extends JPanel {
        private JLabel text = new JLabel();
        public SubPanelTwo () {
          setLayout ( new BorderLayout() );
          setBorder ( BorderFactory.createTitledBorder ( "SubPanel Two" ) );
          text.setFont ( new Font ( "Verdana" ,Font.PLAIN ,30 ) );
          text.setHorizontalAlignment ( JLabel.CENTER );
          add ( text ,BorderLayout.CENTER );
        protected void paintComponent ( Graphics _g ) {
          super.paintComponent ( _g );
          Graphics2D g = (Graphics2D)_g;
          g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
        public void setChoice ( String cmd ) {
          text.setText ( cmd );
      public class Reactor implements ActionListener {
        public void actionPerformed ( ActionEvent e ) {
          subPanelTwo.setChoice ( e.getActionCommand() );
      public PanelComm () {
        setLayout ( new GridLayout ( 1 ,2 ) );
        add ( subPanelOne );
        add ( subPanelTwo );
      //  main
      public static void main ( String[] args ) {
        JFrame f = new JFrame ( "Panel Communication" );
        f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
        f.getContentPane().add ( new PanelComm() ,BorderLayout.CENTER );
        f.setSize ( 320 ,120 );
        f.setVisible ( true );
      }  // main
    }

  • Moving a method from one class to another issues

    Hi, im new. Let me explain what i am trying to achieve. I am basically trying to move a method from one class to another in order to refactor the code. However every time i do, the program stops working and i am struggling. I have literally tried 30 times these last two days. Can some one help please? If shown once i should be ok, i pick up quickly.
    Help would seriously be appreciated.
    Class trying to move from, given that this is an extraction:
    class GACanvas extends Panel implements ActionListener, Runnable {
    private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
    MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              addWorldDesignItemsToMenuBar();
              return menuBar;
    This is the method i am trying to move (below)
    public void itemsInsideWorldDesignMenu() {
              designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                        new String[] { "In Rows", "In Clumps", "At Random",
                                  "Along the Bottom", "Along the Edges" }, 1);
              designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                        new String[] { "50", "100", "150", "250", "500" }, 3);
              designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                        new String[] { "It grows back somewhere",
                                  "It grows back nearby", "It's Gone" }, 0);
              designMenuItemsApproximatePopulation = new WorldMenuItems(
                        "Approximate Population", new String[] { "10", "20", "25",
                                  "30", "40", "50", "75", "100" }, 2);
              designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                        new String[] { "At the Center", "In a Corner",
                                  "At Random Location", "At Parent's Location" }, 2);
              designMenuItemsMutationProbability = new WorldMenuItems(
                        "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                                  "1%", "2%", "3%", "5%", "10%" }, 3);
              designMenuItemsCrossoverProbability = new WorldMenuItems(
                        "Crossover Probability", new String[] { "Zero", "10%", "25%",
                                  "50%", "75%", "100%" }, 4);
    Class Trying to move to:
    class WorldMenuItems extends Menu implements ItemListener {
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;

    Ok i've done this. I am getting an error on the line specified. Can someone help me out and tell me what i need to do?
    GACanvas
    //IM GETTING AN ERROR ON THIS LINE UNDER NAME, SAYING IT IS NOT VISIBLE
    WorldMenuItems worldmenuitems = new WorldMenuItems(name, null);
    public MenuBar getMenuBar() {
              menuBar = new MenuBar();
              addControlItemsToMenuBar();
              addSpeedItemsToMenuBar();
              worldmenuitems.addWorldDesignItemsToMenuBar();
              return menuBar;
    class WorldMenuItems extends Menu implements ItemListener {
         private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
         private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
         private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
         private WorldMenuItems designMenuItemsCrossoverProbability;
         GACanvas gacanvas = new GACanvas(null);
       private CheckboxMenuItem[] items;
       private int selectedIndex = -1;
       WorldMenuItems(String menuName, String[] itemNames) {
          this(menuName, itemNames, -1);
       WorldMenuItems(String menuName, String[] itemNames, int selected) {
          super(menuName);
          items = new CheckboxMenuItem[itemNames.length];
          for (int i = 0; i < itemNames.length; i++) {
             items[i] = new CheckboxMenuItem(itemNames);
    add(items[i]);
    items[i].addItemListener(this);
    selectedIndex = selected;
    if (selectedIndex < 0 || selectedIndex >= items.length)
    selectedIndex = 1;
    items[selectedIndex].setState(true);
         public int getSelectedIndex() {
              return selectedIndex;
    public void itemStateChanged(ItemEvent evt) {  // This works on other systems
    CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
    for (int i = 0; i < items.length; i++) {
    if (newSelection == items[i]) {
    items[selectedIndex].setState(false);
    selectedIndex = i;
    newSelection.setState(true);
    return;
    public void itemsInsideWorldDesignMenu() {
         designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                   new String[] { "In Rows", "In Clumps", "At Random",
                             "Along the Bottom", "Along the Edges" }, 1);
         designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                   new String[] { "50", "100", "150", "250", "500" }, 3);
         designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                   new String[] { "It grows back somewhere",
                             "It grows back nearby", "It's Gone" }, 0);
         designMenuItemsApproximatePopulation = new WorldMenuItems(
                   "Approximate Population", new String[] { "10", "20", "25",
                             "30", "40", "50", "75", "100" }, 2);
         designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                   new String[] { "At the Center", "In a Corner",
                             "At Random Location", "At Parent's Location" }, 2);
         designMenuItemsMutationProbability = new WorldMenuItems(
                   "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                             "1%", "2%", "3%", "5%", "10%" }, 3);
         designMenuItemsCrossoverProbability = new WorldMenuItems(
                   "Crossover Probability", new String[] { "Zero", "10%", "25%",
                             "50%", "75%", "100%" }, 4);
    public void addWorldDesignItemsToMenuBar() {
         gacanvas = new GACanvas(null);
         itemsInsideWorldDesignMenu();
         Menu designMenuItems = new Menu("WorldDesign");
         designMenuItems.add(designMenuItemsPlantGrowth);
         designMenuItems.add(designMenuItemsPlantCount);
         designMenuItems.add(designMenuItemsPlantEaten);
         designMenuItems.add(designMenuItemsApproximatePopulation);
         designMenuItems.add(designMenuItemsEatersBorn);
         designMenuItems.add(designMenuItemsMutationProbability);
         designMenuItems.add(designMenuItemsCrossoverProbability);
         gacanvas.menuBar.add(designMenuItems);

  • Moving Variable from one class to another.

    I need to get a Variable from one class to another how would I do this?

    Well this is a very tipical scehario for every enterprise application. You always create logger classes that generate log files for your application, as that is the only way to track errors in your system when its in the production enviorment.
    Just create a simple class that acts as the Logger, and have a method in it that accepts a variable of the type that you are are trying to pass; most commonly a String; but can be overloaded to accept constom classes. e.g.
    class Logger
      public void log(String message)
        writeToFile("< " + new Date() + " > " + message);
      public void log(CustomClass queueEvent)
        log("queue message was: " + queueEvent.getMessage() + " at: " + queueEven.getEventTime());
    }Hope this makes things clearer
    Regards
    Omer

  • Passing a parameter from one class to another class in the same package

    Hi.
    I am trying to pass a parameter from one class to another class with in a package.And i am Getting the variable as null every time.In the code there is two classes.
    i. BugWatcherAction.java
    ii.BugWatcherRefreshAction.Java.
    We have implemented caching in the front-end level.But according to the business logic we need to clear the cache and again have to access the database after some actions are happened.There are another class file called BugwatcherPortletContent.java.
    So, we are dealing with three java files.The database interaction is taken care by the portletContent.java file.Below I am giving the code for the perticular function in the bugwatcherPortletContent.java:
    ==============================================================
    public Object loadContent() throws Exception {
    Hashtable htStore = new Hashtable();
    JetspeedRunData rundata = this.getInputData();
    String pId = this.getPorletId();
    PortalLogger.logDebug(" in the portlet content: "+pId);
    pId1=pId;//done by sraha
    htStore.put("PortletId", pId);
    htStore.put("BW_HOME_URL",CommonUtil.getMessage("BW.Home.Url"));
    htStore.put("BW_BUGVIEW_URL",CommonUtil.getMessage("BW.BugView.Url"));
    HttpServletRequest request = rundata.getRequest();
    PortalLogger.logDebug(
    "BugWatcherPortletContent:: build normal context");
    HttpSession session = null;
    int bugProfileId = 0;
    Hashtable bugProfiles = null;
    Hashtable bugData = null;
    boolean fetchProfiles = false;
    try {
    session = request.getSession(true);
    // Attempting to get the profiles from the session.
    //If the profiles are not present in the session, then they would have to be
    // obtained from the database.
    bugProfiles = (Hashtable) session.getAttribute("Profiles");
    //Getting the selected bug profile id.
    String bugProfileIdObj = request.getParameter("bugProfile" + pId);
    // Getting the logged in user
    String userId = request.getRemoteUser();
    if (bugProfiles == null) {
    fetchProfiles = true;
    if (bugProfileIdObj == null) {
    // setting the bugprofile id as -1 indicates "all profiles" is selected
    bugProfileIdObj =(String) session.getAttribute("bugProfileId" + pId);
    if (bugProfileIdObj == null) {
    bugProfileId = -1;
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    session.setAttribute(
    ("bugProfileId" + pId),
    Integer.toString(bugProfileId));
    //fetching the bug list
    bugData =BugWatcherAPI.getbugList(userId, bugProfileId, fetchProfiles);
    PortalLogger.logDebug("BugWatcherPortletContent:: got bug data");
    if (bugData != null) {
    Hashtable htProfiles = (Hashtable) bugData.get("Profiles");
    } else {
    htStore.put("NoProfiles", "Y");
    } catch (CodedPortalException e) {
    htStore.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    PortalLogger.logException
    ("BugWatcherPortletContent:: CodedPortalException!!",e);
    } catch (Exception e) {
    PortalLogger.logException(
    "BugWatcherPortletContent::Generic Exception!!",e);
    htStore.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.GET_BUGLIST_FAILED));
    if (fetchProfiles) {
    bugProfiles = (Hashtable) bugData.get("Profiles");
    session.setAttribute("Profiles", bugProfiles);
    // putting the stuff in the context
    htStore.put("Profiles", bugProfiles);
    htStore.put("SelectedProfile", new Integer(bugProfileId));
    htStore.put("bugs", (ArrayList) bugData.get("Bugs"));
    return htStore;
    =============================================================
    And I am trying to call this function as it can capable of fetching the data from the database by "getbugProfiles".
    In the new class bugWatcherRefreshAction.java I have coded a part of code which actually clears the caching.Below I am giving the required part of the code:
    =============================================================
    public void doPerform(RunData rundata, Context context,String str) throws Exception {
    JetspeedRunData data = (JetspeedRunData) rundata;
    HttpServletRequest request = null;
    //PortletConfig pc = portlet.getPortletConfig();
    //String userId = request.getRemoteUser();
    /*String userId = ((JetspeedUser)rundata.getUser()).getUserName();//sraha on 1/4/05
    String pId = request.getParameter("PortletId");
    PortalLogger.logDebug("just after pId " +pId);  */
    //Calling the variable holding the value of portlet id from BugWatcherAction.java
    //We are getting the portlet id here , through a variable from BugWatcherAction.java
    /*BugWatcherPortletContent bgAct = new BugWatcherPortletContent();
    String portletID = bgAct.pId1;
    PortalLogger.logDebug("got the portlet ID in bugwatcherRefreshAction:---sraha"+portletID);*/
    // updating the bug groups
    Hashtable result = new Hashtable();
    try {
    request = data.getRequest();
    String userId = ((JetspeedUser)data.getUser()).getUserName();//sraha on 1/4/05
    //String pId = (String)request.getParameter("portletId");
    //String pId = pc.getPorletId();
    PortalLogger.logDebug("just after pId " +pId);
    PortalLogger.logDebug("after getting the pId-----sraha");
    result =BugWatcherAPI.getbugList(profileId, userId);
    PortalLogger.logDebug("select the new bug groups:: select is done ");
    context.put("SelectedbugGroups", profileId);
    //start clearing the cache
    ContentCacheContext cacheContext = getCacheContext(rundata);
    PortalLogger.logDebug("listBugWatcher Caching - removing markup content - before removecontent");
    // remove the markup content from cache.
    PortletContentCache.removeContent(cacheContext);
    PortalLogger.logDebug("listBugWatcher Caching-removing markup content - after removecontent");
    //remove the backend content from cache
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(((JetspeedUser)data.getUser()).getUserName()));
    PortalLogger.logDebug("listBugWatcher Caching User: " +((JetspeedUser)data.getUser()).getUserName());
    PortalLogger.logDebug("listBugWatcher Caching pId: " +pId);
    if (pdata != null)
    // User's data found in cache!
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null");
    pdata.removeObject(PortletCacheHelper.getUserPortletHandle(((JetspeedUser)data.getUser()).getUserName(),pId));
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null- after removeObject");
    PortalLogger.logDebug("listBugWatcher Caching -finish calling the remove content code");
    //end clearing the cache
    // after clearing the caching calling the data from the database taking a fn from the portletContent.java
    PortalLogger.logDebug("after clearing cache---sraha");
    BugWatcherPortletContent bugwatchportcont = new BugWatcherPortletContent();
    Hashtable httable= new Hashtable();
    httable=(Hashtable)bugwatchportcont.loadContent();
    PortalLogger.logDebug("after making the type casting-----sraha");
    Set storeKeySet = httable.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, httable.get(paramName));
    PortalLogger.logDebug("after calling the databs data from hashtable---sraha");
    } catch (CodedPortalException e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    catch (Exception e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.EXCEPTION_CODE));
    try {
    ((JetspeedRunData) data).setCustomized(null);
    if (((JetspeedRunData) data).getCustomized() == null)
    ActionLoader.getInstance().exec(data,"controls.EndCustomize");
    catch (Exception e)
    PortalLogger.logException("bugwatcherRefreshAction", e);
    ===============================================================
    In the bugwatcher Action there is another function called PostLoadContent.java
    here though i have found the portlet Id but unable to fetch that in the bugWatcherRefreshAction.java . I am also giving the code of that function under the bugWatcherAction.Java
    ================================================
    // Get the PortletData object from intermediate store.
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(
    //rundata.getRequest().getRemoteUser()));
    ((JetspeedUser)rundata.getUser()).getUserName()));
    pId1 = (String)portlet.getID();
    PortalLogger.logDebug("in the bugwatcher action:"+pId1);
    try {
    Hashtable htStore = null;
    // if PortletData is available in store, get current portlet's data from it.
    if (pdata != null) {
    htStore =(Hashtable) pdata.getObject(     PortletCacheHelper.getUserPortletHandle(
    ((JetspeedUser)rundata.getUser()).getUserName(),portlet.getID()));
    //Loop through the hashtable and put its elements in context
    Set storeKeySet = htStore.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, htStore.get(paramName));
    bugwatcherRefreshAction bRefAc = new bugwatcherRefreshAction();
    bRefAc.doPerform(pdata,context,pId1);
    =============================================================
    So this is the total scenario for the fetching the data , after clearing the cache and display that in the portal.I am unable to do that.Presently it is still fetching the data from the cache and it is not going to the database.Even the portlet Id is returning as null.
    I am unable to implement that thing.
    If you have any insight about this thing, that would be great .As it is very urgent a promt response will highly appreciated.Please send me any pointers or any issues for this I am unable to do that.
    Please let me know as early as possible.
    Thanks and regards,
    Santanu Raha.

    Have you run it in a debugger? That will show you exactly what is happening and why.

  • Calling a method of one class from another withing the same package

    hi,
    i've some problem in calling a method of one class from another class within the same package.
    for eg. if in Package mypack. i'm having 2 files, f1 and f2. i would like to call a method of f2 from f1(f1 is a servlet) . i donno exactly how to instantiate the object for f2. can anybody please help me in this regard.
    Thank u in advance.
    Regards,
    Fazli

    This is what my exact problem.
    i've created a bean (DataBean) to access the database. i'm having a servlet program (ShopBook). now to check some details over there in the database from the servlet i'm in need to use a method in the DataBean.
    both ShopBook.java and DataBean.java lies in the package shoppack.
    in ShopBook i tried to instantiate the object to DataBean as
    DataBean db = new DataBean();
    it shows the compiler error, unable to resolve symbol DataBean.
    note:
    first i compiled DataBean.java, it got compiled perfectly and the class file resides inside the shoppack.
    when i'm trying to compile the ShopBook its telling this error.
    hope i'm clear in explaining my problem. can u please help me?
    thank u in advance.
    regards,
    Fazli

  • Object Creation Of One class into another and vice versa

    Hello Everyone,
    My name is Prashant Sharma from Jaipur [Rajasthan]
    Can u people help me
    How to create of one class into another and vice versa
    Eg,
    I am having class A and class B
    I want to create object of class A into class B and vice versa
    Plz help me out of this problem as soon as possible....

    Read this: [Creating Objects|http://java.sun.com/docs/books/tutorial/java/javaOO/objectcreation.html]
    Then, do one of these three:
    1. Create an instance of the class
    2. Extend the class
    3. Access methods within the class
    Try it out. Post the problem code if you're having trouble.

  • Transfer assets from one asset class to another having different depreciation keys.

    Hi Gurus,
         I am a noob in FICO, and I am facing a problem while transferring assets from one asset class to another.
    Below is the scenario.
    I created two assets 100000000000-0 under asset class 4690a and 200000000000-0 under asset class 4690b. And I am trying to transfer the
    asset from class 4690b to 4690a by selecting the option ‘New Asset’ in the transaction ABUMN. While doing this, I am receiving an error message as below.
    'Posting with trans. type 300 not possible (No acquisition posted).'
         Message No. AA324.
    Diagnosis:
         Transaction type 300 belongs to a transaction type group, which can only be used to post to assets to which posting has already been performed. However, no postings have been made to this asset.
    Procedure:
         Use a transaction type from a transactio type group, which can be used for the first acquisition to an asset.
    The error is related to the transaction type which I hadn’t explicitly created anywhere. But, when checked in transaction AO76, the transaction  type 300 belongs to the transaction type group 30. In this group I am not able to find any solution related to the error.
    Moreover, in some of the threads in SCN, I read that modifying the transaction type group might lead to something fatal.
    Kindly help me in the below.
    1. What exactly the error message is related with?
    2. Is there any other method to transfer the asset to another class?
    Please let me know if any further details are required regarding the scenario.

    Hi ,
    I understand that you want to transfer the old asset to new asset with different asset class with different depreciation keys and the old asset is not yet capitalized and does not have any Asset Values.
    Assuming that since the First Asset is not yet capitalized, that seems to be that its just that ASset Master is created and no Asset Values appear in the Asset.(in other words no acquisition, capitalization, no dep. start etc.)..
    Alternatively this asset can be advised to be blocked and flagged for deletion and create a new Asset in the new Asset Class and then capitalize the new asset by doing the acquisition according to the business process i.e. either via PO based process(GR) or Non PO based process.
    The transfer of asset is required incase the old asset still have the values and you are transferring the old asset to new one with the left over values.
    Also would request you to kindly share some screenshots of the AW01n of the old asset and screenshots of the AS03 to have more idea on it and provide a better solution to the same..
    Warm Regards,
    Vineet

  • Importing a class from another context?

    Hi JSP techies,
    Im using RESIN and having a simple problem of figuring out how to import classes from another context, if Im using the right word.
    ie.
    My .jsp files are under $home/resin/doc/test dir. And in the jsp file, I would like to import a servlet class or a plain java class. But the servlet classes and all other classes are located under $home/resin/webapps/project/WEB-INF/classes/a/b/c
    Hence when I say
    <% page import="a.b.c.*" %>
    I get an error saying "a" not found.
    1. When I say "servlet classes are in a different CONTEXT", is that right? or is it just another directory?
    2. How can I make the jsp file import the classes from the servlets class path?
    Note: Ofcourse, when I copy the package to the
    $home/resin/doc/WEB-INF/classes dir, everything works fine. But thats simply not an efficient way to get around. Could anyone clear my doubts on this regd.?
    Thanks in advance.
    Arun

    Oh... I get it now. I'm sorry, I had you poorly misunderstood. You are trying to import servlets from another web app or servlet context. I would suggest you put servlets that are common to all web apps in the system classpath and not tie them to any particular web app. In other words create a package directory structure from the system's root directory or any where outside of any web apps and point the system classpath to the beginning of that directory structure. I have a similar thing going with Tomcat. I have a folder in my root called Java_Class which is in my classpath. I build all common utilities in this directory. So I have a com/craig/web structure that holds my AppServlet which is in package com.craig.web. This servlet is visible to all web apps via the Windows classpath. Servlets particular to an application like say an MusicOrderProcess servlet would reside in a package under the webserverhome/webapps/MusicStore/WEB-INF/classes directory where webserver home is the home directory of the webserver you are using. I've tested this across webservers as well (orionserver and Tomcat) and it works.
    From the prompt you include in your posts I am guessing that you are running on UNIX. Move your common servlets out of their respective web apps and into a common directory structure. Configure the UNIX $CLASSPATH (or is it $classpath?) environment variable to point to this sturcture and you'll be on your way!
    Post again if you have more questions!

  • Accessing a variable defined in one class from another class..

    Greetings,
    I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.
    Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem  to be working for me. Any ideas would be appreciated.  Thanks,
    - Jeremy
    package  jab.enemy
    import flash.display.MovieClip;
    import flash.events.Event;
    import jab.enemy.MissleDisappear;
    public class DieLikeThePhishes
    private var _clip2:MovieClip; // player
    private var _clip3:MovieClip; //phish1
    private var _clip4:MovieClip; //phish2
    private var _clip5:MovieClip; //phish3
    private var _clip6:MovieClip; //phish4
    private var _clip10:MovieClip; // background
    private var _clip11:MovieClip // missle1
    private var _clip12:MovieClip // missle2
    private var _clip13:MovieClip // missle3
    private var _clip14:MovieClip // missle4
    private var _clip15:MovieClip // missle5
    private var _clip16:MovieClip // missle6
    private var _clip17:MovieClip // missle7
    private var _clip18:MovieClip // missle8
    private var _clip19:MovieClip // missle9
    private var _clip20:MovieClip // missle10
    private var _clip21:MovieClip // missle11
    private var _clip22:MovieClip // missle12
    var ay1 = 0;var ay2 = 0;var ay3 = 0;var ay4 = 0;
    var vy1 = 0;var vy2 = 0;var vy3 = 0;var vy4 = 0;
    var phish1BeenHit:Boolean = false;var phish2BeenHit:Boolean = false;
    var phish3BeenHit:Boolean = false;var phish4BeenHit:Boolean = false;
    public function DieLikeThePhishes(clip2:MovieClip,clip3:MovieClip,clip4:MovieClip,clip5:MovieClip,clip6:M ovieClip,clip10:MovieClip,clip11:MovieClip,clip12:MovieClip,clip13:MovieClip,clip14:MovieC lip,clip15:MovieClip,clip16:MovieClip,clip17:MovieClip,clip18:MovieClip,clip19:MovieClip,c lip20:MovieClip,clip21:MovieClip,clip22:MovieClip)
    _clip2 = clip2;_clip3 = clip3;_clip4 = clip4;_clip5 = clip5;_clip6 = clip6;
    _clip10 = clip10;_clip11 = clip11;_clip12 = clip12;_clip13 = clip13;_clip14 = clip14;
    _clip15 = clip15;_clip16 = clip16;_clip17 = clip17;_clip18 = clip18;_clip19 = clip19;
    _clip20 = clip20;_clip21 = clip21;_clip22= clip22;
    _clip3.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame)
    function onEnterFrame(event:Event):void
    vy1+= ay1;_clip3.y += vy1; vy2+= ay2;_clip4.y += vy2;
    vy3+= ay3;_clip5.y += vy3; vy4+= ay4;_clip6.y += vy4;
    if (phish1BeenHit ==false)
    if(_clip3.y >620)
    {_clip3.y = 620;}
    if (phish2BeenHit ==false)
    if(_clip4.y >620)
    {_clip4.y = 620;}
    if (phish3BeenHit ==false)
    if(_clip5.y >620)
    {_clip5.y = 620;}
    if (phish4BeenHit ==false)
    if(_clip6.y >620)
    {_clip6.y = 620;}
    if (_clip11.hitTestObject(_clip3) ||_clip12.hitTestObject(_clip3)||_clip13.hitTestObject(_clip3)||_clip14.hitTestObject(_cl ip3)||_clip15.hitTestObject(_clip3)||_clip16.hitTestObject(_clip3)||_clip17.hitTestObject( _clip3)||_clip18.hitTestObject(_clip3)||_clip19.hitTestObject(_clip3)||_clip20.hitTestObje ct(_clip3)||_clip21.hitTestObject(_clip3)||_clip22.hitTestObject(_clip3))
    _clip3.scaleY = -Math.abs(_clip3.scaleY);
    _clip3.alpha = 0.4;
    ay1 = 3
    vy1= -2;
    phish1BeenHit = true;
    if (_clip11.hitTestObject(_clip4) ||_clip12.hitTestObject(_clip4)||_clip13.hitTestObject(_clip4)||_clip14.hitTestObject(_cl ip4)||_clip15.hitTestObject(_clip4)||_clip16.hitTestObject(_clip4)||_clip17.hitTestObject( _clip4)||_clip18.hitTestObject(_clip4)||_clip19.hitTestObject(_clip4)||_clip20.hitTestObje ct(_clip4)||_clip21.hitTestObject(_clip4)||_clip22.hitTestObject(_clip4))
    _clip4.scaleY = -Math.abs(_clip4.scaleY);
    _clip4.alpha = 0.4;
    ay2 = 3
    vy2= -2;
    phish2BeenHit = true;
    if (_clip11.hitTestObject(_clip5) ||_clip12.hitTestObject(_clip5)||_clip13.hitTestObject(_clip5)||_clip14.hitTestObject(_cl ip5)||_clip15.hitTestObject(_clip5)||_clip16.hitTestObject(_clip5)||_clip17.hitTestObject( _clip5)||_clip18.hitTestObject(_clip5)||_clip19.hitTestObject(_clip5)||_clip20.hitTestObje ct(_clip5)||_clip21.hitTestObject(_clip5)||_clip22.hitTestObject(_clip5))
    _clip5.scaleY = -Math.abs(_clip5.scaleY);
    _clip5.alpha = 0.4;
    ay3 = 3
    vy3= -2;
    phish3BeenHit = true;
    if (_clip11.hitTestObject(_clip6) ||_clip12.hitTestObject(_clip6)||_clip13.hitTestObject(_clip6)||_clip14.hitTestObject(_cl ip6)||_clip15.hitTestObject(_clip6)||_clip16.hitTestObject(_clip6)||_clip17.hitTestObject( _clip6)||_clip18.hitTestObject(_clip6)||_clip19.hitTestObject(_clip6)||_clip20.hitTestObje ct(_clip6)||_clip21.hitTestObject(_clip6)||_clip22.hitTestObject(_clip6))
    _clip6.scaleY = -Math.abs(_clip6.scaleY);
    _clip6.alpha = 0.4;
    ay4 = 3
    vy4= -2;
    phish4BeenHit = true;
    if (_clip3.y > 10000)
    _clip3.x = 1000 +3000*Math.random()-_clip10.x;
    _clip3.y = 300;
    _clip3.alpha = 1;
    _clip3.scaleY = Math.abs(_clip3.scaleY);
    ay1 = vy1 = 0;
    phish1BeenHit = false;
    if (_clip4.y > 10000)
    _clip4.x = 1000 +3000*Math.random()-_clip10.x;
    _clip4.y = 300;
    _clip4.alpha = 1;
    _clip4.scaleY = Math.abs(_clip4.scaleY);
    ay2 = vy2 = 0;
    phish2BeenHit = false;
    if (_clip5.y > 10000)
    _clip5.x = 1000 +3000*Math.random()-_clip10.x;
    _clip5.y = 300;
    _clip5.alpha = 1;
    _clip5.scaleY = Math.abs(_clip5.scaleY);
    ay3 = vy3 = 0;
    phish3BeenHit = false;
    if (_clip6.y > 10000)
    _clip6.x = 1000 +3000*Math.random()-_clip10.x;
    _clip6.y = 300;
    _clip6.alpha = 1;
    _clip6.scaleY = Math.abs(_clip6.scaleY);
    ay4 = vy4 = 0;
    phish4BeenHit = false;
    var missleDisappear1 = new MissleDisappear(_clip11,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear2 = new MissleDisappear(_clip12,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear3 = new MissleDisappear(_clip13,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear4 = new MissleDisappear(_clip14,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear5 = new MissleDisappear(_clip15,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear6 = new MissleDisappear(_clip16,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear7 = new MissleDisappear(_clip17,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear8 = new MissleDisappear(_clip18,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear9 = new MissleDisappear(_clip19,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear10 = new MissleDisappear(_clip20,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear11 = new MissleDisappear(_clip21,_clip3,_clip4,_clip5,_clip6,_clip10);
    var missleDisappear12 = new MissleDisappear(_clip22,_clip3,_clip4,_clip5,_clip6,_clip10);

    I would approach it in much the same way as you would in java, by making getters and setters for all of your class variables.
    Getters being for returning the values, Setters being for setting them.
    So you would make a get function for the variable you want to access ala:
    function get1PhishBeenHit():boolean {
         return this.phish1BeenHit;
    Then to access the value of that variable from outwith the class:
    var result:boolean = ClassInstanceName.get1PhishBeenHit();

  • Get a reference of a local class at another program

    Hello experts! Sorry if this has been asked before, but I couldn't find exactly what I'm searching for.
    Within function-pool MIGO (main program of transaction MIGO), there's a local class LCL_MIGO_KERNEL. This class has the private attribute PT_CHANGE_TAKEIT (which is an internal table).
    During the execution of MIGO, for a certain criteria, I would like to clear the contents of PT_CHANGE_TAKEIT. Since it's a private attibute, I have managed to create a new public method that just clears it. This method was defined and inplemented within ENHANCEMENT SPOTS available all over SAPLMIGO. My method is ZZ_CLEAR_PT_CHANGE_TAKEIT. So far so good.
    Now, I have to call this method. I have found no other ENHANCEMENT SPOTS in SAPLMIGO at a place where I would me able to make the call (eg, don't know if the criteria fits yet).
    Inside BADI MB_MIGO_BADI, method LINE_MODIFY, I have just what I need to know if I should clear PT_CHANGE_TAKEIT.
    However, inside here I don't have access to the instance of class LCL_MIGO_KERNEL (the instance itself is (SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL)
    So far I have managed to get a pointer to the instance with:
      FIELD-SYMBOLS: <lfs_kernel> TYPE ANY.
      ASSIGN ('(SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL')
        TO <lfs_kernel>.
    So I have the instance of the class, but how can I call my method ZZ_CLEAR_PT_CHANGE_TAKEIT?
    The command  call method <lfs_kernel>->zz_clear_pt_change_takeit.
    can't be done because ""<LFS_KERNEL>" is not a reference variable" as the sintax check tells me.
    I have tried stuff like
      CREATE DATA dref TYPE REF TO
                 ('\FUNCTION-POOL=MIGO\CLASS=LCL_MIGO_KERNEL').
      ASSIGN dref->* TO <ref>.
    but nothing works so far.
    I know if LCL_MIGO_KERNEL was a class from SE24 (not a local one), I could just create a field-symbol of that type instead of type ANY and it would work.
    Does anyone have an idea how that can be done?
    Thank you very much!

    I have managed to do what I needed by calling my method from other ENHANCEMENT SPOTS within SAPLMIGO and some extra coding on MB_MIGO_BADI, but unfortunately I couldn't do what I originaly wanted which was to call a method of a local class from another program, something that could be handy in other situations.
    If it's not lack of knowledge by myself and it really can't be done, I think the ABAP OO framework fell just short of having that flexibility, since I can get the field-symbol to point to the instance of the class, but just can't call the method because of syntax issues.
    Thanks!
    Well it seems you already solved, but I got curious and knew how this could be done, so I wanted to prove it and here it is:
    * This would be inside the Function group
    CLASS lcl_kernel DEFINITION.
      PUBLIC SECTION.
        METHODS:
          zz_clear_pt_change_takeit.
    ENDCLASS.                    "lcl_kernel DEFINITION
    CLASS lcl_kernel IMPLEMENTATION.
      METHOD zz_clear_pt_change_takeit.
        WRITE 'Dummy! I do nothing!'.
      ENDMETHOD.                    "zz_clear_pt_change_takeit
    ENDCLASS.                    "lcl_kernel IMPLEMENTATION
    START-OF-SELECTION.
    * This is just to create the reference. It corresponds to
    * (SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL in your example
      DATA: kernel  TYPE REF TO lcl_kernel.
      CREATE OBJECT kernel.
    *----------------- Now your program (which supposedly does not have
    *----------------- access to kernel or even lcl_kernel def)
    *----------------- would begin
      FIELD-SYMBOLS: <lfs_kernel> TYPE ANY.
      DATA: generic_ref           TYPE REF TO object.
      ASSIGN ('KERNEL')
        TO <lfs_kernel>.
      generic_ref = <lfs_kernel>.
      TRY.
          CALL METHOD generic_ref->('ZZ_CLEAR_PT_CHANGE_TAKEIT').
        CATCH cx_sy_dyn_call_illegal_method .
      ENDTRY.
    Apart from that, I wouldn't access a local class this way. There's a reason for blocking the access, one of them being that SAP could change local classes without notice thus breaking your program.

  • How to transter contents of itab from one class to another...

    Hello experts,
    I am currently having problems on how to transfer the contents of an itab or even
    the value of a variable from one class to another. For example, I have 10 records
    in it_spfli in class 1 and when I loop at it_spfli in the method of class 2 it has no records!
    This is an example:
    class lcl_one definition.
    public section.
    data: gt_spfli type table of spfli.
    methods get_data.
    endclass.
    class lcl_one implementation.
    method get_data.
      select * from spfli
      into table gt_spfli.
    endmethod.
    endclass.
    class lcl_two definition inheriting from lcl_one.
    public section.
      methods loop_at_itab.
    endclass.
    class lcl_two implementation.
    method loop_at_itab.
      field-symbols: <fs_spfli> like line of gt_spfli.
      loop at gt_spfli assigning <fs_spfli>.
       write: / <fs_spfli>-carrid.
      endloop.
    endmethod.
    endclass.
    start-of-selection.
    data: one type ref to lcl_one,
          two type ref to lcl_two.
    create object: one, two.
    call method one->get_data.
    call method two->loop_at_itab.
    In the example above, the contents of gt_spfli in class lcl_two is empty
    even though it has records in class lcl_one. Help would be appreciated.
    Thanks a lot guys and take care!

    Hi Uwe,
    It is still the same. Here is my code:
    REPORT zfi_ors_sms
           NO STANDARD PAGE HEADING
           LINE-SIZE 255
           LINE-COUNT 65
           MESSAGE-ID zz.
    Include program/s                            *
    INCLUDE zun_standard_routine.           " Standard Routines
    INCLUDE zun_header.                     " Interface Header Record
    INCLUDE zun_footer.                     " Interface Footer Record
    INCLUDE zun_interface_control.          " Interface Control
    INCLUDE zun_external_routine.           " External Routines
    INCLUDE zun_globe_header.               " Report header
    INCLUDE zun_bdc_routine.                " BDC Routine
    Data dictionary table/s                      *
    TABLES: bkpf,
            rf05a,
            sxpgcolist.
    Selection screen                             *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE sxpgcolist-parameters.
    SELECTION-SCREEN END OF BLOCK b1.
    */ CLASS DEFINITIONS
          CLASS lcl_main DEFINITION
    CLASS lcl_main DEFINITION ABSTRACT.
      PUBLIC SECTION.
    Structure/s                                  *
        TYPES: BEGIN OF t_itab,
                rec_content(100) TYPE c,
               END OF t_itab.
        TYPES: BEGIN OF t_upfile,
                record_id(2)    TYPE c,            " Record ID
                rec_date(10)    TYPE c,            " Record Date MM/DD/YYYY
                prod_line(10)   TYPE c,            " Product Line
                acc_code(40)    TYPE c,            " Acc Code
                description(50) TYPE c,            " Description
                hits(13)        TYPE c,            " Hits
                amount(15)      TYPE c,            " Amount
               END OF t_upfile.
    Internal table/s                             *
        DATA: gt_bdcdata    TYPE STANDARD TABLE OF bdcdata,
              gt_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll,
              gt_itab       TYPE STANDARD TABLE OF t_itab,
              gt_header     LIKE TABLE OF interface_header,
              gt_footer     LIKE TABLE OF interface_footer,
              gt_upfile     TYPE STANDARD TABLE OF t_upfile.
    Global variable/s                            *
        DATA: gv_target             TYPE rfcdisplay-rfchost,
              gv_err_flag(1)        TYPE n VALUE 0,
              gv_input_dir(100)     TYPE c
                                     VALUE '/gt/interface/FI/ORS/inbound/',
              gv_inputfile_dir(255) TYPE c,
              gv_eof_flag           TYPE c VALUE 'N',
              gv_string             TYPE string,
              gv_delimiter          TYPE x VALUE '09',
              gv_input_records(3)   TYPE n,
              gv_input_file_ctr(6)  TYPE n,
              gv_proc_tot_amt(14)   TYPE p DECIMALS 2,
              gv_prg_message        TYPE string,
              gv_gjahr              TYPE bkpf-gjahr,
              gv_monat              TYPE bsis-monat.
    Work area/s                                  *
        DATA: wa_itab               LIKE LINE OF gt_itab,
              wa_upfile             LIKE LINE OF gt_upfile,
              wa_footer             LIKE LINE OF gt_footer,
              wa_header             LIKE LINE OF gt_header.
    ENDCLASS.
          CLASS lcl_read_app_server_file DEFINITION
    CLASS lcl_read_app_server_file DEFINITION INHERITING FROM lcl_main.
      PUBLIC SECTION.
        METHODS: read_app_server_file,
                 read_input_file,
                 split_header,
                 process_upload_file,
                 split_string,
                 conv_num CHANGING value(amount) TYPE t_upfile-amount,
                 split_footer,
                 update_batch_control,
                 process_data.
    ENDCLASS.
          CLASS lcl_process_data DEFINITION
    CLASS lcl_process_data DEFINITION INHERITING FROM
                                                 lcl_read_app_server_file.
      PUBLIC SECTION.
        METHODS process_data REDEFINITION.
    ENDCLASS.
    */ CLASS IMPLEMENTATIONS
          CLASS lcl_read_app_server_file IMPLEMENTATION
    CLASS lcl_read_app_server_file IMPLEMENTATION.
    */ METHOD read_app_server_file  -  MAIN METHOD
      METHOD read_app_server_file.
        gv_target = sy-host.
        PERFORM file_copy USING 'ZPPDCP' p_file 'HP-UX'
                gv_target CHANGING gv_err_flag.
        CONCATENATE gv_input_dir p_file INTO gv_inputfile_dir.
      open application server file
        PERFORM open_file USING gv_inputfile_dir 'INPUT'
                                   CHANGING gv_err_flag.
        WHILE gv_eof_flag = 'N'.
          READ DATASET gv_inputfile_dir INTO wa_itab.
          APPEND wa_itab TO gt_itab.
          IF sy-subrc <> 0.
            gv_eof_flag = 'Y'.
            EXIT.
          ENDIF.
          CALL METHOD me->read_input_file.
        ENDWHILE.
      close application file server
        PERFORM close_file USING gv_inputfile_dir.
        IF wa_footer-total_no_rec <> gv_input_file_ctr.
          MOVE 'Header Control on Number of Records is Invalid' TO
               gv_prg_message.
          PERFORM call_ws_message USING 'E' gv_prg_message 'Error'.
          gv_err_flag = 1.
        ELSEIF wa_footer-total_no_rec EQ 0 AND gv_input_file_ctr EQ 0.
          MOVE 'Input File is Empty. Batch Control will be Updated' TO
               gv_prg_message.
          PERFORM call_ws_message USING 'I' gv_prg_message 'Information'.
          CALL METHOD me->update_batch_control.
          gv_err_flag = 1.
        ENDIF.
        IF gv_err_flag <> 1.
          IF wa_footer-total_amount <> gv_proc_tot_amt.
            MOVE 'Header Control on Amount is Invalid' TO gv_prg_message.
            PERFORM call_ws_message USING 'E' gv_prg_message 'Error'.
            gv_err_flag = 1.
          ENDIF.
        ENDIF.
      ENDMETHOD.
    */ METHOD read_input_file
      METHOD read_input_file.
        CASE wa_itab-rec_content+0(2).
          WHEN '00'.
            CALL METHOD me->split_header.
          WHEN '01'.
            CALL METHOD me->process_upload_file.
            ADD 1 TO gv_input_file_ctr.
            ADD wa_upfile-amount TO gv_proc_tot_amt.
          WHEN '99'.
            CALL METHOD me->split_footer.
          WHEN OTHERS.
            gv_err_flag = 1.
        ENDCASE.
      ENDMETHOD.
    */ METHOD split_header
      METHOD split_header.
        CLEAR: wa_header,
               gv_string.
        MOVE wa_itab TO gv_string.
        SPLIT gv_string AT gv_delimiter INTO
              wa_header-record_id
              wa_header-from_system
              wa_header-to_system
              wa_header-event
              wa_header-batch_no
              wa_header-date
              wa_header-time.
        APPEND wa_header TO gt_header.
      ENDMETHOD.
    */ METHOD process_upload_file
      METHOD process_upload_file.
        CLEAR gv_string.
        ADD 1 TO gv_input_records.
        MOVE wa_itab-rec_content TO gv_string.
        CALL METHOD me->split_string.
        CALL METHOD me->conv_num CHANGING amount = wa_upfile-amount.
        APPEND wa_upfile TO gt_upfile.
      ENDMETHOD.
    */ METHOD split_string
      METHOD split_string.
        CLEAR wa_upfile.
        SPLIT gv_string AT gv_delimiter INTO
              wa_upfile-record_id
              wa_upfile-rec_date
              wa_upfile-prod_line
              wa_upfile-acc_code
              wa_upfile-description
              wa_upfile-hits
              wa_upfile-amount.
      ENDMETHOD.
    */ METHOD conv_num
      METHOD conv_num.
        DO.
          REPLACE gv_delimiter WITH ' ' INTO amount.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
        ENDDO.
      ENDMETHOD.
    */ METHOD split_footer
      METHOD split_footer.
        CLEAR: wa_footer,
               gv_string.
        MOVE wa_itab TO gv_string.
        SPLIT gv_string AT gv_delimiter INTO
              wa_footer-record_id
              wa_footer-total_no_rec
              wa_footer-total_amount.
        CALL METHOD me->conv_num CHANGING amount = wa_footer-total_amount.
        APPEND wa_footer TO gt_footer.
      ENDMETHOD.
    */ METHOD update_batch_control
      METHOD update_batch_control.
        DATA: lv_sys_date      TYPE sy-datum,
              lv_sys_time      TYPE sy-uzeit,
              lv_temp_date(10) TYPE c.
        CONCATENATE wa_header-date4(4) wa_header-date2(2)
                    wa_header-date+0(2)
               INTO lv_temp_date.
        MOVE lv_temp_date TO wa_header-date.
        APPEND wa_header-date TO gt_header.
      Update ZTF0001 Table
        PERFORM check_interface_header USING wa_header 'U' 'GLOB'
                                       CHANGING gv_err_flag.
      Archive files
        PERFORM archive_files USING 'ZPPDARC' gv_inputfile_dir 'HP-UX'
                gv_target CHANGING gv_err_flag.
      ENDMETHOD.
      METHOD process_data.
        SORT gt_upfile ASCENDING.
        CLEAR wa_upfile.
        READ TABLE gt_upfile INDEX 1 INTO wa_upfile.
        IF sy-subrc = 0.
          MOVE: wa_upfile-rec_date+6(4) TO gv_gjahr,
                wa_upfile-rec_date+0(2) TO gv_monat.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
          CLASS lcl_process_data IMPLEMENTATION
    CLASS lcl_process_data IMPLEMENTATION.
      METHOD process_data.
        CALL METHOD super->process_data.
        IF NOT gt_upfile[] IS INITIAL.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    Start of selection                           *
    START-OF-SELECTION.
      DATA: read TYPE REF TO lcl_read_app_server_file,
            process TYPE REF TO lcl_process_data.
      CREATE OBJECT: read, process.
      CALL METHOD read->read_app_server_file.
      CALL METHOD process->process_data.

Maybe you are looking for

  • Windows 7 Beta problem - PLEASE HELP ME :(

    I'm running the recently released Windows 7 public beta, and have so far got iTunes running and all my songs sorted out fine. But when I try to connect my iPod Classic, neither iTunes nor my PC recognises it, except for an unresponsive "iPod" entry u

  • Is there a quick way to turn Cellular Data on and off?

    I just sent this suggestion in to Apple: I have limited data on my Iphone 4s, well 2gb and I try to use my wifi as much as possible while home especially.  I don't know the technical term for it, but when you swipe up from the bottom of the phone and

  • New Aluminum Mac Display

    I have a MacBook Pro and a new iMac. The Text on the iMac is a little bit blurry compared to the text in the MacBook Pro (Core Dual 1). Any suggestions would be appreciated. I tried to switch off the zoom feature but it did not improve the text rende

  • I deleted the recently added playlist in iTunes...how do i get it back?

    i've searched for answers but they were all for windows. does anybody know how to get the recently added playlist back on a MacBook Pro? MacBookPro   Mac OS X (10.4.8)   MacBookPro

  • Order Reason in CRM

    Hi Expert! I have configured Order Reason in CRM downloading the object CRM_CATALOG and having configured the Catalogs, Code Groups and Subject Profiles. I need to know whether it is possible - via customizing - defaulting in one business transaction