Define of subroutine in class

HI All,
Please suggest me how can I define a subroutine in class.
as I have declared subroutine in method.
Thanks,
Sandeep.

Thank Max,
can u please suggest me how can I create method to the class.
As I have created one implementation of MB_DOCUMENT_BADI and in that I have already predefined methods.
Plase suggest as its urgent.
Thanks .
sandeep.

Similar Messages

  • A question about the getProperty method defined in the Security class

    Hello Everyone!
    I would like to ask a question about the getProperty method defined in the
    Security class.
    public static String getProperty(String key) Do you know how can I exract the list of all possible keys?.
    Thanks in advance,

    I found the answer, in fact the keys are defined in the java.security file.

  • Right way of defining constants - Interfaces or Classes?

    Two widely used ways to define constants in java projects are:
    1. Interfaces - Define constants in interfaces, they automatically become static, final and then implement the interface in concrete classes that need those constants.
    2. Classes - Use normal classes and define explicitly as static, final. Use CLASS_NAME.CONSTANT_NAME to access the constant in concrete classes.
    I have gone through the web on Best-practices for defining constants and its strongly recommended for not using Interfaces for defining constants.
    "The constant interface pattern is a poor use of interfaces. That a class uses some constants internally is an implementation detail. Implementing a constant interface causes this implementation detail to leak into the class's exported API. It is of no consequence to the users of a class that the class implements a constant interface. In fact, it may even confuse them. Worse, it represents a commitment: if in a future release the class is modified so that it no longer needs to use the constants, it still must implement the interface to ensure binary compatibility. If a nonfinal class implements a constant interface, all of its subclasses will have their namespaces polluted by the constants in the interface. " from     Effective Java, Joshua Bloch
    What is your take on this?
    Rgds

    I have gone through the web on Best-practices for defining constants and its strongly recommended for not using Interfaces for defining constants.
    "The constant interface pattern is a poor use of interfaces. That a class uses some constants internally is an implementation detail. Implementing a constant interface causes this implementation detail to leak into the class's exported API. It is of no consequence to the users of a class that the class implements a constant interface. In fact, it may even confuse them. Worse, it represents a commitment: if in a future release the class is modified so that it no longer needs to use the constants, it still must implement the interface to ensure binary compatibility. If a nonfinal class implements a constant interface, all of its subclasses will have their namespaces polluted by the constants in the interface. " from     Effective Java, Joshua Bloch
    I don't like grouping constants into an interface. I prefer keeping them closer to the classes that use them.
    %

  • User defined data type generated class

    Hi
    When defining a new data type in the local dictionary, one has to option of generating a representation class.
    I have done this and indeed received the class in my app.
    However, I fail to understand how I can use this class to retrieve values set in the data type.
    Thank you for your assistance
    Regadrs
    yuval

    Hello Y PEERY
    I am not clear which context you are talking about .
    Are you taking about simple type inside local dictonary ?
    or
    A project with data dictonary type ?
    (for webdynpro only)
    In both the case no need to deal with internal generated class, this is somethig which is requrired to framework itself , end developer not at all using /modifiying it.
    or
    Might you are dealing with EJB so in this case representation class is generated once we provide the basic(name , package etc) to it , further you can modify it according to your use.
    Please clarify
    BR
    Satish Kumar

  • Very Urgent: how to define field symbols in class using se24 Points assured

    hi all
    I am new to abap oo programming. I am using se24 to build a class
    where some methods have code which involves working with field sybmols but i am not able to figure out way for how to define field symbols in the attributes section.
    I tried defining like : fld_sym type ref to  dbtab-fld
    but in the method implementation if i try to use it like assign fld to <fld_sym> there it says fld_sym is not defined as a field symbol.
    So can anyone please guide me how to define field symbols in se24.
    Also what should be the general steps while creating a class using se24.
    Points assured
    thanks

    Hi
    Global classes are like Global fun modules in which the Methods and code is already written and is mainly used for Reusability purpose.
    Goto SE24 tcode and see the std global classes like
    CL_ABAP_CHAR_UTILITIES
    see the links
    chk out the links below:
    General Tutorial for OOPS
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    Have a look at these links for OO ABAP.
    http://www.sapgenie.com/abap/OO/
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    SDN Series:
    https://www.sdn.sap.com/irj/sdn/developerareas/abap?rid=/webcontent/uuid/35eaef9c-0b01-0010-dd8b-e3b0f9ed7ccb [original link is broken]
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
    Basic concepts of OOPS
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
    http://www.henrikfrank.dk/abapuk.html
    http://www.erpgenie.com/abap/OO/
    Reward oints if useful,
    Aleem.

  • Key property on base class without hosting relationship which is defined on an inherited class

    Hello,
    I have a BaseClass which is marked Abstract=true and Hosted=false. Then I have an InheritedClass which has the BaseClass as its Base. This InheritedClass is Hosted=true while being Abstract=false. You know, the BaseClass has some common attributes for two different
    InheritedClasses which define different hosting relationships. 
    The only Key property is declared on the BaseClass. The InheritedClass does not have its own, more specialized, Key property.
    It seems the Key property on the abstract un-hosted BaseClass enforces the Key value globally and not only for the hosting parent of the InheritedClass. Am I right?
    How do I make the BaseClass's Key property be scoped to the InheritedClass's hosting parent?
    ondrej.

    Hi,
    if I understood the question correct than you need to change your model's design.
    "A key property uniquely identifies each instance of a particular class. If a property is marked as a key property, each instance of the class must have a unique value, and the value may not be null. For
    hosted classes, the value must only be unique for all instances of the class that have the same hosting parent. For
    unhosted classes, it must be unique for all instances of the class in the management group." (
    https://technet.microsoft.com/en-us/library/ee957039.aspx)
    http://OpsMgr.ru/

  • Overidding a method defined in a Final class via an interface.

    Hi,
    Is it possible to override methods of a final class
    which has implemented methods of an interface.
    interface A{
         void method1();     
    public final class FinalityA implements A{
         public void method1(){
              // Code
    }Now,I would like to override the functionality of
    method1() defined in class FinalityA.
    I cannot subclass FinalityA as this class is final.
    // Invalid.
    class Myclass extends FinalityA{
    }Is it possible to override the functionality defined in method1()
    Please suggest

    You can do:
    public class MyClass implements A {
       private final FinalityA _wrapee;
       public MyClass(FinalityA wrapped) {
           _wrapee = wrapped;
      public void method1() {
           .. do some special processing
          _wrapee.method1();
           .. do some more stuff
            }If you want to get really clever you can do stuff with java.lang.reflect.Proxy that allows you to automatically pass on calls to interface methods (this kind of thing is increasingly used for stuff like transaction management).
    What you can't do is to fiddle with the code of the method if called from a reference to FinalityA rather than a reference to the interface. The whole point of final classes and methods is to prevent that.

  • N00b query: Why would anyone ever want to define their own Exception class?

    I've been reading thru my Java textbook for the past couple hours.
    Exceptions are a wonderful thing. I already found several instances where I could've implemented try/cacth in my earlier programs.
    Anyway, getting back to the point. My question is, can someone give me a realistic situation/example where a custom Expcetion class is REQUIRED? (the key word here is "required"!)
    I can see why someone would want to have his own Exception class..... e.getMessage() as custom error messages are SO DAMN COOL!!!!!! :P
    hehe
    But seriously, if you are making intermidiate/advanced Java programs, would you ever REQUIRE to make your own Exception class? Afterall, even a custom made Exception class always "extends" from a pre-defined Java class, right?
    Let me make this a bit more clear... public class CustomException extends IOException{  }Now, if I am making a try/catch statement, I can simply say
    try{
    throw new CustomException;
    catch (IOException e) { }
    Now as you can see, the CustomException was caught by the catch claus, because IOException is the superclass of CustomException. So, in other words, the whole CustomException thingy didnt do anything useful.
    I know I know, I am so naive. Enlighten me >.<

    Sure. Say you want to have a system where you want to include a custom error code which maps to some internationalized error messages. You would create an Exception subclass with a field to hold that value separate from the normal "default" message. Then you could throw that exception in all your code. Other code can catch it as a plain Exception if they want and use the "default" message, which is okay if they don't really care about the error code.
    I don't think you are ever "required" to make your own exceptions. I have done so, but I don't often. It depends. See, there are plenty of Exception subclasses in the standard packages, and most of them cover many of the things you need. So more often if I'm throwing an exception, I'll be using the already existing ones, like IllegalArgumentException or IOException (whatever is relevant to the code).
    Yes, you can do what you did below with CustomException. However the reason you might do that is cuz you really want to do this:
    try {
       // call some code that may throw IOException from some standard IO package
       // or may throw CustomException from some of my methods...
    } catch (CustomException ce) {
       // handle cusotm exception
    } catch (IOException ioe) {
       // handle IO exception
    }Cuz you may want to differentiate between your exceptions vs. IOExceptions that might be thrown from some java.io class.
    Usually when you use an exception class it's a named class that relates to some condition. It may hold additional information besides the standard message, but I think most of the time it's just the class name which describes the problem. And if there isn't one that describes the problem that you're code might encounter, then create a subclass.

  • Cannot resolve symbol error while trying to define methods in a class

    Well, I'm fairly new to java and I'm trying to write a simple program that will take user input for up to 100 die and how many sides they have and will then roll them and output the frequencies of numbers occuring. I have overloaded the constructor for the Die class to reflect different choices the user may have when initializing the Die.
    Here is my code:import java.util.*;
    import java.io.*;
    public class Die
         private final int MIN_FACES = 4;
         private int numFaces;
         private int i = 0;
         private int faceValue;
         private Die currentDie;
         private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         private String line = null;
         public Die()
              numFaces = 6;
              faceValue = 1;
         public Die (int faces)
              if (faces < MIN_FACES) {
                   numFaces = 6;
                   System.out.println ("Minimum number of faces allowed is 6.");
                   System.out.println ("Setting faces to 6... . . .  .  .  .   .   .   .");
              else
                   numFaces = faces;
              faceValue = 1;
    //Returns an array of Die Objects
         public Die (int num_die, int faces)
              numFaces = faces;
              Die[] protoDie = new Die[num_die];
              for (i = 0; i <= num_die-1; i++)
                   Die currentDie = new Die(numFaces);
                   protoDie = protoDie.initMultiDie(currentDie, i);
         public Die (double num_die)
              int numberOfDie = (int) num_die;
              Die[] protoDie = new Die[numberOfDie];
              System.out.print ("Enter the number of sides for die #" + i);
              for (i=0; i <= protoDie.length; i++) {
              do {
                   try {
                        line = br.readLine();
                        numFaces = Integer.parseInt(line);
                   catch (NumberFormatException nfe) {
                        System.out.println ("You must enter an integer.");
                        System.out.print ("Setting number of dice to 0, please reenter: ");
                   if (numFaces < 0) {
                        System.out.println ("The number of sides must be positive.");
                        numFaces *= -1;
                        System.out.println ("Number of sides is: " + numFaces);
                   else
                      if (numFaces = 0) {
                        System.out.println ("Zero dice is no fun. =[");
                        System.out.print ("Please reenter the number of sides: ");
                   numFaces = 0;
              while (numFaces == 0);
              Die currentDie = new Die(numFaces);
              protoDie[i] = protoDie.initMultiDie(currentDie, i);
              i = 0;
         public Die[] initMultiDie (Die[] protoDie, Die currentDie, int i)
              protoDie[i] = currentDie;
              return protoDie;
         public Die reInit (int sides)
              currentDie.roll();
              return currentDie;
         public int roll()
              faceValue = (int) (Math.random() * numFaces) + 1;
              return faceValue;
    }When I compile I get 2 errors at lines 42 and 73 saying:
    Cannot resolve symbol | symbol: method initMultiDie(Die, int) | location: class Die[] | protoDie[i] = protoDie.initMultiDie(currentDie, i)
    I've tried mixing things up with invoking the method, such as including protoDie in the parameter liist, instead of invoking the initMultiDie method thru the protoDie Die[] object. I'm a little confused as to what I can and cannot do with defining arrays of Objects like Die. Thank you for any input you may be able to provide.
    ~Lije

    I may as well just replace Die with Dice and allow
    Dice to represent a collection of 1 die.. I just like
    to cut on bloat and make my programs be as efficient
    as possible.Efficiency and avoiding code bloat are good goals, but you don't necessarily achieve it by creating the smallest number of classes. If you have N algorithms in M lines, then you have that many, regardless of whether they're in one class or two. A really long source file can be a worse example of bloat than two source files of half the size -- it can be harder to read, less clear in the design, and thus with more bugs...
    The important thing is clarity and a strong design.
    The weird thing is, that initMultiDie is
    what seems to be throwing up the error, but I don't
    see why. Meh, I'm sure I'll figure it out.Refactoring a class to make the design more transparent often helps you figure out bugs.

  • Defining variables from a class gives errors

    Hi,
    I'm trying to create a questionnaire, that can hold an array
    of questions.
    The questions can be of different types, like single punch,
    multi punch, open text etc.
    Much of the code below is copied from examples I've found and
    I am definitely in the beginning
    of my learning process when it comes to Flex, but I think
    Flex can solve a problem I have at work.
    So, I'm trying to cut corners...
    I created this class called Questions, which contains all
    properties any question can have.
    When I'm trying to define a variable (myQuestion) based on
    that class, I the following error.
    (actually I get it on all properties...)
    Error:
    1120: Access of undefined property Qtype.
    This is the class definition:
    package Mycomponents
    //import other classes needed
    //import Mycomponents.Codeframe
    public class Question {
    // Define properties and methods.
    // Define public vars.
    public var Qtype:String="";
    public var Condition:String="";
    public var Qnumber:String="";
    public var Qheading:String="";
    public var Pretext:String="";
    public var Qtext:String="";
    public var Posttext:String="";
    public var Codeframe:String;
    public var Reserved:String="";
    public var EditableFrom:String="";
    public var EditableTo:String="";
    public var Decimal:String="";
    public var SetQfactor:String="";
    public var Logic_if:String="";
    public var Logic_then:String="";
    // Public constructor.
    public function Question(
    Qtype:String,
    Condition:String,
    Qnumber:String,
    Qheading:String,
    Pretext:String,
    Qtext:String,
    Posttext:String,
    Codeframe:String,
    Reserved:String,
    EditableFrom:String,
    EditableTo:String,
    Decimal:String,
    SetQfactor:String,
    Logic_if:String,
    Logic_then:String )
    this.Qtype=Qtype;
    this.Condition=Condition;
    this.Qnumber=Qnumber;
    this.Qheading=Qheading;
    this.Pretext=Pretext;
    this.Qtext=Qtext;
    this.Posttext=Posttext;
    this.Codeframe=Codeframe;
    this.Reserved=Reserved;
    this.EditableFrom=EditableFrom;
    this.EditableTo=EditableTo;
    this.Decimal=Decimal;
    this.SetQfactor=SetQfactor;
    this.Logic_if=Logic_if;
    this.Logic_then=Logic_then;
    This is the part of the code that generates the error:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.states.State;
    import mx.controls.Alert;
    import mx.events.CloseEvent;
    import flash.events.KeyboardEvent;
    import Mycomponents.Codeframe;
    import Mycomponents.Question;
    public var myQuestion:Question = new Question(
    Qtype,
    Condition,
    Qnumber,
    Qheading,
    Pretext,
    Qtext,
    Posttext,
    Codeframe,
    Reserved,
    EditableFrom,
    EditableTo,
    Decimal,
    SetQfactor,
    Logic_if,
    Logic_then
    ....more code...
    ...what am I missing in defining this variable?
    If you have a link to a good book on Flex...let me know.
    Regards
    /Acke

    When you create your local variable myQuestion, where are the
    parameters (used in the constructor) declared and initialized?
    var _qType = "some value";
    var myQ:Question = new Question(_qType,"","" etc);
    Also good OO practice is to declare your variables as private
    and add getters and setters for the values. Sometimes you may want
    to manipulate the values when getting or setting.
    If you use the standard AS3 get and set then declare your
    vars with an _
    so as not to conflict with the getter and setter. For exampe:
    public class MyClass
    private var _var1:String;
    public function get var1():String
    return _var1;
    public function set var1(v:String):void
    _var1 = v;
    This may seem like extra work, but in a complex application
    with lots of classes
    encapsulating updating of members will save you lots of
    headaches.

  • Step by Step Procedure For defining/Implementing a Local Class

    Hi!
    I need simple step-by-step procedure for defining a local class ( having 1 function only) in ABAP

          CLASS lcl_class DEFINITION
    CLASS lcl_class DEFINITION.
      PUBLIC SECTION.
        METHODS fm.
    ENDCLASS.                    "lcl_class DEFINITION
          CLASS lcl_implementation DEFINITION
    CLASS lcl_class IMPLEMENTATION.
      METHOD fm.
        CALL FUNCTION 'FM'.
      ENDMETHOD.                    "fm
    ENDCLASS.                    "lcl_implementation DEFINITION
    This is basic structure, which can be defined in an include (top include for data declaration), or some where local in your report / method.
    You can use this class be instantiating it (CREATE OBJECT) and then call the method via the instance like this:
    DATA: lr_object TYPE REF TO lcl_class.
    START-OF-SELECTION.
      CREATE OBJECT lr_object.
      CALL METHOD lr_object->fm.

  • Define custom typed collection class

    Hi, I would like to define a custom typed collection class that can hold multiple type elements, to be more concrete, i have a class defined as
    public class MyList extends ArrayList{
    public class TestMyList{
        MyList<MyDataTypeOne> listOne; // i want to use JAVA generics here, but it wont let me
        MyList<MyDataTypeTwo> listTwo;
    }and i got an error saying: "MyList" does not have typed parameters.
    I understand that i need to declare my class as something like
    public class MyList<MyDataTypeOne> extends ArrayList
    but i dont want it to be restricted to <MyDataTypeOne> but multiple types, just like ArrayList. How can i cope with this please, thanks!

    Test the following code:
    import java.util.ArrayList;
    public class MyList<E> extends ArrayList<E>{
         public MyList()
         public static void main(String[] args) {
              MyList<String> lista = new MyList<String>();
              lista.add("Bolivia");
              String x = lista.get(0);
              System.out.println(x);
    }

  • How to define ABC class field in the Customer Master Sales tab

    HI All,
    can any one let me know how to define the new  ABC class in the Customer Master Sales tab like below.
    u2013 A (> 6,000,000 )
    u2013 B (> 1,000,000u20136,000,000 )
    u2013 C (> 100,000u20132,000,000 )
    u2013 D (< 100,000 )
    can any one let me know how to define and path in IMG.
    Thanks in advance.
    kumar reddy.

    In my opinion, you don't have any such std table/view to update ABC Classification field. You might need to update relevant infostructure based on your requirement, such as sales, invoiced, etc..
    Try with following, based on your requirement:
    MC(A
    SIS: Customer,Inc.Orders - Selection
    MC+A
    SIS: Customer Returns, Selection
    MC+E
    SIS: Customer, Sales - Selection
    MC+I
    SIS: Customer Credit Memos - Selec.
    Regards
    JP

  • How to define my startup class in an .ear package?

    I am using WL6.0SP2 on solaris.
    I plan to package my application as an .ear file and to put all necesarry class
    files in there (it will has one .war file for the web tier and one .jar file for
    the EJBs).
    I want, when Weblogic loads my .ear file (i.e. my application), to execute my
    special startup class, which initializes some caches, etc.
    I do not want to define a startup/shutdown class in the console, because it is
    only specific to my application and this startup class is not present in the weblogic
    classpath during weblogic startup.
    The correct place should be in application.xml, but I don't see such thing in
    the DTD.
    Thank you,
    Ivaylo Zlatev

    There is no way to do this on the EAR level - you can use load-on-startup
    servlet(s) in your web component, or initial-beans-in-free-pool=1 EJB.
    Ivaylo Zlatev <[email protected]> wrote:
    I am using WL6.0SP2 on solaris.
    I plan to package my application as an .ear file and to put all necesarry class
    files in there (it will has one .war file for the web tier and one .jar file for
    the EJBs).
    I want, when Weblogic loads my .ear file (i.e. my application), to execute my
    special startup class, which initializes some caches, etc.
    I do not want to define a startup/shutdown class in the console, because it is
    only specific to my application and this startup class is not present in the weblogic
    classpath during weblogic startup.
    The correct place should be in application.xml, but I don't see such thing in
    the DTD.
    Thank you,
    Ivaylo Zlatev--
    Dimitri

  • Error(2): Unable to find class for bean: connection defined by tag...

    I created a project, and a JavaBean that connects to the database and I want to use it in a JSP page that exists in my project.
    Bean:
    package BeerPackage;
    import java.sql.*;
    public class ConnectionBean
    JSP:
    <%@ page import="BeerPackage.*" contentType="text/html;charset=windows-1252"%>
    <jsp:useBean id="connection" class="ConnectionBean" scope="session"/>
    Then I get the error:
    Error(2): Unable to find class for bean: connection defined by tag with class: ConnectionBean
    When I try to build the JSP
    Any ideas?

    Seems even though I have an import, I still have to specify the package name in front of the useBean.
    What am I missing here?

Maybe you are looking for

  • Apple Mini DisplayPort to VGA Adapter longer than 4 inches?

    My ViewSonic monitor no longer works with my Macbook Air. Did work for six months. Pretty sure it's the knock off cable - loose in Thunderbolt. The only genuine Apple cable I can find is four inches. Are you kidding me? Anyone know if there is a long

  • The Best Way to Check a Database.

    Hello All, I'm working on an app. where I'll retrieve upwards of 1 million items. For each retrieval, I have to make sure that the item was not previously retrieved and stored. That means on the 1millionth item, I have to test the previous 999,999 it

  • PO price changes after partial MIGO

    Dear All, I have created a PO for 100 Pcs with Rs 100 per Pc & have done GR for 50 Pcs. After 10 days i will get the remaining 50Pcs but the price has gone upto Rs 110 due to variations in market. So accordingly i changed the price in PO to Rs 110 &

  • Video playback for Amazon and Netflix are too dark to see. Running OSX 10.10.2

    When playing these streaming videos, the pictures are too dark to see much of anything. YouTube and Facebook videos are nice and bright. I tried "never activate" the plugins, but that made no difference.

  • I Need A Copy Of Internet Explorer

    I trashed IE believing that I would never need it again. However, to access account information from an insurance site, I was told that only IE for Mac would work (I tried unsucessfully both with Safari and Firefox). Since Microsoft no longer offers