Method call of BADI

Hi All,
What is the difference in calling a method of babi and implementing BAdi.
Regards,
Jeetu

Hi,
Are u working in Ecc 6.0. If yes, then once the BADI is implemented, u can call the method u want by using the syntax CALL BADI. This  concept is included in the enhancement framework topic.
Syntax
CALL BADI badi->meth    [EXPORTING  p1 = a1 p2 = a2 ...]
                     { {[IMPORTING  p1 = a1 p2 = a2 ...]
                        [CHANGING   p1 = a1 p2 = a2 ...]}
                     |  [RECEIVING   r = a  ] }
                        [EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
                                    [OTHERS = n_others]].
Effect
: Calls a BAdI method. For badi, a BAdI reference variable must be specified. For meth, a BAdI method of the corresponding BAdI must be entered directly. The additions assign actual parameters to the formal parameters of the BAdI method, or handle non-class-based exceptions as described in CALL METHOD.
The effect of the statement CALL BADI is that the specified method is called in all object plug-ins to which the BAdI object referenced by the badi refers.
If the BAdI is defined for single use, then badi must contain a valid BAdI reference. If badi is initial, a treatable exception occurs in this case.
If the BAdI is defined for multiple use, then badi must contain a valid BAdI reference or can be initial. If the referenced BAdI object refers to several object plug-ins ,then the calling sequence is the same with every CALL BAdI statement. The exact calling sequence can be determined in the definition of the corresponding BAdI implementations, if the predefined BAdI BADI_SORTER of the enhancement spot of the same name was implemented for the current BAdI. If the referenced BAdI object does not reference object plug-ins, or the badi is initial, then the statement is without effect.
System fields
As for a normal CALL METHOD, the system field sy-subrc is either set to 0 or, when treating non-class-based exceptions, it is set to the value specified after EXCEPTIONS.
Hope this helps u.
reward points if found useful.

Similar Messages

  • Call of a BADI method inside another BADI

    Dear colleagues,
    Could someone guide me with the information whether it is allowed to create/call  a Badi inside an implementation of another Badi method?
    Please let me know whether there are other alternatives or the Badi call within Badi acceptable as per SAP standards?
    Many thanks in advance,
    Best regards,
    Srivatsa

    hi Ganesh,
    Check this out
    <b>Calling a BADI from another BADI</b>
    Regards,
    Santosh

  • Call various methods from a BADI

    Hello,
    I would like to know if I can call all the methods in a BADI with one call. If its possible please provide an example. THANK YOU.

    Thats not possible
    check this might be helpful
    http://help.sap.com/saphelp_47x200/helpdata/en/b8/bdb83b5b831f3be10000000a114084/content.htm

  • How to call a badi implementaion from report program

    Hi ABAP Guru,
    I have ZBADI_FALLBACK_DEF new badi created by me and there two implementation ZBADI_FALLBACK_IMP and ZBADI_FALLBACK_IMP1
    Now I am calling this badi from report program
    DATA:
       W_HANDLE TYPE REF TO ZBADI_FALLBACK_DEF.
    * GET BADI - for getting objects..................
    GET BADI W_HANDLE.
    * CALL BADI - for calling interface methods.
    CALL BADI W_HANDLE->ADD.
    This is fine,,,
    But I want to call only one implementaion ZBADI_FALLBACK_IMP.But here two implementaion is called.Please help....

    Hi Palash,
    Then you create filter BADI  and  use filter in implementation.
    While getting BADI reference use filter
    GET BADI W_HANDLE FILTERS
    Thanks & Regards,
    Arun

  • Example of how to call a BadI from an Abap and use the NEW OO ALV Grid

    Very easy to do.
    <b>REPORT  Z_BADI_TEST.
    test call Badi from standard abap.
    *Only from rel 6.40
    do the following
    1) define the Badi  (SE18).
    For Abap call test uncheck multiple use
    and filter boxes
    2) Implement the badi (SE19).
    Add any methods here in the implementation
    3) activate
    4)  define the standard class exithandler to the
    Abap. This class is the "Badi caller
    5)  define an exit variable referring to your Badi
    Implementation interface
    this interface  will normally be
    called something like 
    ZIF_EX***************
      You will see the actual name in SE18/SE19.
    6)  Instantiate your instance of the badi
    via  method call get_instance
    7)  Now call any method(s) in the Badi.
    *****************start of abap code **************
    Define the Badi calling class (standard sap class)
      class cl_exithandler definition load.   "Declaration
    *Interface reference  
      data exit type ref to zif_ex__jimbotest.    
         data yes type c.
    Used in Fmod call in Badi methods
        data: v_knvv type knvv.
        start-of-selection.
        yes = ' '.
      selection-screen  begin of block b1.
      parameters: r1  radiobutton  group rad1,
                  r2  radiobutton group rad1,
                  r3  radiobutton group rad1.
      selection-screen end of block b1.
        parameters: p_kunnr type knvv-kunnr.
        select  single * into v_knvv
        from knvv
         where kunnr eq p_kunnr.
         export v_knvv to memory id 'CUST6A'.
    *Save customer data for the function module call
    call method cl_exithandler=>get_instance 
           exporting 
           exit_name    = 'Z_JIMBOTEST' "Your Badi Name
           null_instance_accepted = yes
              changing instance = exit.
       if not exit is initial.
           if r1 = 'X'.
         call method exit->dispord .  "Badi call
          endif.
    if r2 = 'X'.
    call method exit->dispfakt.     "Badi Call
    endif.
    if r3 = 'X'.
    call method exit->dispmat.      "Badi call
    endif.
    end of calling abap******** </b>
    In the badi   methods code as shown
    1)
    method ZIF_EX__JIMBOTEST~DISPORD.
    CALL FUNCTION 'Z_DISPLAY_CUST'.
    endmethod.
    2)
    method ZIF_EX__JIMBOTEST~DISPFAKT.
    CALL FUNCTION 'Z_DISPLAY_FAKT'.
    endmethod
    3)
    method ZIF_EX__JIMBOTEST~DISPMAT.
    CALL FUNCTION 'Z_DISPLAY_CUST'.
    endmethod.
    Copy via SE 41 the status SALV_STANDARD from  standard SAP program SALV_DEMO_METADATA into the main program where you've created the 3 function modules below (SAP______TOP)
    Global Data for the three function modules I'm calling
    FUNCTION-POOL Z_BADI_KNVV.                  "MESSAGE-ID ..
    include <color>.
    include <icon>.
    include <symbol>.
    tables: zknvv.
    data: v_zzkvgr6  TYPE KNVV-ZZKVGR6.
    data: choice1  type c.
    data: choice2 type c.
    data: choice3 type c.
    data: choice4 Type c.
    data: ok-code(5) type c.
    data: answer type string.
    data: value1 type SPOP-VARVALUE1.
    data: answer1  type string.
    tables:  vbak, vbap,  vakpa, vbrk, vrkpa.
    data: lr_functions type ref to cl_salv_functions_list.
    constants: gc_true  type sap_bool value 'X',
               gc_false type sap_bool value space.
    add for colour displays
       data: ls_color type lvc_s_colo.
       DATA : LV_SALV_COLUMNS_TABLE TYPE REF TO CL_SALV_COLUMNS_TABLE.
      data: lr_columns type ref to cl_salv_columns_table,
            lr_column  type ref to cl_salv_column_table.
    Data:
            gr_table TYPE REF TO cl_salv_table.
    data: z_datum type sy-datum.
    data: v_knvv type knvv.
    data : begin of s_vbak,
              vkorg   type vakpa-vkorg,
              vkgrp   type vakpa-vkgrp,
              vtweg   type vakpa-vtweg,
              spart   type vakpa-spart,
              auart   type vakpa-auart,
              vbeln   type vakpa-vbeln,
              bstnk   type vakpa-bstnk,
              audat   type vakpa-audat,
              netwr   type vbak-netwr,
           end of s_vbak.
    data : begin of s_vbrk,
              vbeln   type vrkpa-vbeln,
              vkorg   type vrkpa-vkorg,
              fkart   type vrkpa-fkart,
              fkdat   type vrkpa-fkdat,
              netwr   type vbrk-netwr,
           end of s_vbrk.
      data: begin of s_vbap,
             matnr   type vbap-matnr,
             arktx   type vbap-arktx,
             netwr   type vbap-netwr,
             kwmeng  type vbap-kwmeng,
          end of s_vbap.
    data: t_vbap like table of s_vbap.
    data:   t_vbak
            like table of s_vbak.
      data:   t_vbrk
            like table of s_vbrk.
    data:   s_name  type tabname.
    data: gr_selections type ref to cl_salv_selections.
    data: gr_events type ref to cl_salv_events_table.
    Source code of the function modules.
    Function modules themselves
    FUNCTION Z_DISPLAY_CUST.
    s_name = 'S_VBAK'.
    orders in last 6 months
    z_datum = sy-datum - 180.
    import v_knvv from memory id 'CUST6A'.
    get data
       select avkorg aaudat avkgrp avtweg aspart aauart abstnk avbeln b~netwr
          into corresponding fields of  table t_vbak
          up to 100 rows
             from (  vakpa as a
              inner join vbak as b
               on avbeln eq bvbeln )
            where a~kunde eq v_knvv-kunnr
            and a~parvw eq 'AG'
           and a~vkorg eq 'EN01'
            and a~trvog eq '0'
            and a~audat gt z_datum.
    sort t_vbak by audat descending.
    *data: gt_hyperlink type standard table of g_type_s_hyperlink.
    Instead of if_salv_c_bool_sap=>false, you can pass the
    value if_salv_c_bool_sap=>true to this method to
    see your ALV as a list.
    display data in Grid / List
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>false
            IMPORTING
              r_salv_table   = gr_table
            CHANGING
              t_table    = t_vbak.
        CATCH cx_salv_msg.
      ENDTRY.
    try.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
          ls_color-col = col_negative.
          ls_color-int = 0.
          ls_color-inv = 0.
          lr_column->set_color( ls_color ).
      catch cx_salv_not_found.
    endtry.
    try.
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'VBELN' ).
    ls_color-col = col_negative.
          ls_color-int = 1.
          ls_color-inv = 1.
          lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    *LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'Net Value' ).
    *lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'URL' ).
    catch cx_salv_not_found.
    endtry.
    gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'
    report = sy-repid
    set_functions = gr_table->c_functions_all ).
    this statement actually does the display.
      gr_table->display( ).
    ENDFUNCTION.
    FUNCTION Z_DISPLAY_FAKT.
    s_name = 'S_VBRK'.
    invoices in last 6 months
    z_datum = sy-datum - 180.
    import v_knvv from memory id 'CUST6A'.
    get data
       select avbeln afkart avkorg afkdat
         b~netwr
          into corresponding fields of  table t_vbrk
          up to 100 rows
             from (  vrkpa as a
              inner join vbrk as b
               on avbeln eq bvbeln )
            where a~kunde eq v_knvv-kunnr
            and a~parvw eq 'RG'
           and a~vkorg eq 'EN01'
            and a~vbtyp eq 'M'
            and a~fkdat gt z_datum.
    sort t_vbrk by fkdat descending.
    *data: gt_hyperlink type standard table of g_type_s_hyperlink.
    Instead of if_salv_c_bool_sap=>false, you can pass the
    value if_salv_c_bool_sap=>true to this method to
    see your ALV as a list.
    display data in Grid / List
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>false
            IMPORTING
              r_salv_table   = gr_table
            CHANGING
              t_table    = t_vbrk.
        CATCH cx_salv_msg.
      ENDTRY.
    try.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
          ls_color-col = col_negative.
          ls_color-int = 0.
          ls_color-inv = 0.
          lr_column->set_color( ls_color ).
          catch cx_salv_not_found.
    endtry.
    try.
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'VBELN' ).
    ls_color-col = col_negative.
          ls_color-int = 1.
          ls_color-inv = 1.
          lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    *LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'Net Value' ).
    *lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'URL' ).
    catch cx_salv_not_found.
    endtry.
    gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'
    report = sy-repid
    set_functions = gr_table->c_functions_all ).
    this statement actually does the display.
      gr_table->display( ).
    ENDFUNCTION.
    FUNCTION Z_DISPLAY_MATERIAL.
    s_name = 'S_VBAP'.
    invoicesrs in last 6 months
    z_datum = sy-datum - 180.
    import v_knvv from memory id 'CUST6A'.
    get data
    select avbeln bmatnr barktx bnetwr b~kwmeng
    into corresponding fields of  table t_vbap
          up to 100 rows
    from (  vakpa as a
              inner join vbap as b
               on avbeln eq bvbeln )
            where a~kunde eq v_knvv-kunnr
            and a~parvw eq 'AG'
           and a~vkorg eq 'EN01'
            and a~trvog eq '0'
            and a~audat gt z_datum.
    TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>false
            IMPORTING
              r_salv_table   = gr_table
            CHANGING
              t_table    = t_vbap.
        CATCH cx_salv_msg.
      ENDTRY.
    try.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
          ls_color-col = col_negative.
          ls_color-int = 0.
          ls_color-inv = 0.
          lr_column->set_color( ls_color ).
      catch cx_salv_not_found.
    endtry.
    try.
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'ARKTX' ).
    ls_color-col = col_negative.
          ls_color-int = 1.
          ls_color-inv = 1.
          lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    *LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'Net Value' ).
    *lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'URL' ).
    catch cx_salv_not_found.
    endtry.
    gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'
    report = sy-repid
    set_functions = gr_table->c_functions_all ).
    this statement actually does the display.
      gr_table->display( ).
    ENDFUNCTION.
    You can extend this as far as you like -- it's really easy and MUCH MUCH easier than the old way with fieldcatalogs etc etc.

    If the pagecontainer_mc holds another movieclip that contains the button you are trying to target, then you need to include that loaded movieclip in the targeting.  And if contacts is that movieclip, then you should be able to target it directly using...
    var contacts:contatti = new contatti;
    contacts.contacts_btn.addEventListener(MouseEvent.CLICK,showContacts);

  • Method called reverse that switches complex number coordinates.

    I have written a class called "Complex" and there are no errors in the program.
    What I am confused about is how to answer an assigned question. The question
    is this: "Write a method called reverse which will return a new complex number
    with the coordinates reversed. That is, if the complex number which invokes
    the method has coordinates (a,b), then the method should return a new complex
    value with coordinates (b, a)."
    I will include my code for the class here (I'm using the NetBeans IDE):
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package tutorial8;
    * @author Aleks
    public class Complex
        private int I; // Real Part
        private int J; // Imaginary Part
        public Complex(int I, int J)
        setComplex(I, J);
    public int getI()
        return I;
    public int getJ()
        return J;
    public void setComplex(int I, int J)
    this.I=I;
    this.J=J;
    if (I==J)
    System.out.println("true");
    else
    System.out.println("false");
    }thanks.

    Your right it compiles without errors but it says it's missing a main method.
    This main method thing is driving me insane. Some of my classes work such as the following
    one:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package tutorial7;
    * @author Aleks
    import java.util.Scanner;
    public class Shortcalculation
        public static void main(String[] args)
            Scanner keyboard = new Scanner(System.in);
            System.out.println("Enter a positive integer");
            int positiveInteger = keyboard.nextInt();
           if (positiveInteger < 2)
            System.out.println("First positive integer output");
            positiveInteger = 4;
            while ((positiveInteger/3 >=1) && (positiveInteger/3 < 2))
                System.out.println("4");
            else if (positiveInteger < 3)
            System.out.println("Second positive integer output");
            positiveInteger = 21;
            while ((positiveInteger/5 >=2) && (positiveInteger/5 < 3))
                System.out.println("21");
            else if (positiveInteger < 4)
            System.out.println("Third positive integer output");
            positiveInteger = 43;
            while (positiveInteger/7 <=3)
                System.out.println("43");
            else
            System.out.println("Not a valid integer");
    }But I don't see why THIS one shouldn't. I try to include a "public static void main(string[] args)"
    in the class complex but it says it's an illegal start of the expression. Maybe it depends on
    where in the class I put it. I'm only practicing writing classes for 3-4 weeks now because I've read
    a lot of the book. Too bad my memory is kind of bad. Ok, I have changed the class for this
    question, I have added a reverse method. I did it without a return statement.
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package tutorial8;
    * @author Aleks
    public class Complex {
        private int I; // Real Part
        private int J; // Imaginary Part
        public Complex(int I, int J)
        setComplex(I, J);
        public int getI()
        return I;
    public int getJ()
        return J;
    public void setComplex(int I, int J)
    this.I=I;
    this.J=J;
    if (I==J)
    System.out.println("true");
    else
    System.out.println("false");
    public void reverse()
    this.I=J;
    this.J=I;
    }sorry for the long post.

  • Best practice for method calling on objects within a collection.

    Hi guys
    As you may be aware, based on my other thread here. I'm designing a card game in Java. I was hoping for some advice on the best practise on how methods should be called on a custom Object contained within a custom Collection.
    I have an instance variable for the Deck class as follows: List<Card> deckWhen creating an instance of the class I use deck = new ArrayList<Card>();So I have a Deck which only holds Card objects. My question is, for the Card methods, should I call them on the Card objects after 'getting' the Cards from the Deck or should I write methods within the Deck class which handles this method calling. Code explanation is as follows:
    Deck standardDeck = new Deck();I want to retrieve the suit value of a card within the deck. Is this the best way to do it this way:
    standardDeck.getCardAt(50).getSuit();
    //getCardAt is a method within the Deck class, getSuit() is a method within the Card classor this way:
    standardDeck.getSuitForCardAt(50);
    //getSuitForCardAt() is a method within the Deck class. This method calls the getSuit() method within its method body.Cheers for any help guys.
    Edited by: Faz_86 on Jul 10, 2010 9:53 AM

    Hey Saish
    Thanks for the response.
    My Card class does indeed override hashCode(), equals() and toString().
    The reason I am asking a card from the deck for its Suit is simply because of the rules of the game being played. The game I made is a 'Card Shredding' game where a player attempts to remove as many cards from their hand during each turn. The first to remove all their cards is the winner.
    When the game starts, two decks are created. A standard 52 card deck and an empty deck. Then 8 cards are dealt to each player and one card is dealt into the empty deck. The suit and value of the card on the empty deck called the 'shredding deck' dictates which moves are valid during each turn; The played card must match the Suit or the Value of the current card on the 'shredding deck'
    For example:
    Card on the empty deck = 8 of Spades
    The only card from a players hand which can be removed are any Spade or an Eight of any suit.
    Going back to the Deck.getSuitOfCardAtIndex(int index) , this method is needed because both the AI player and human player need to have the ability to take a look at the cards which have been added to the 'shredding deck'. Again this is because of the rules of the game. Therefore I need a method to take a look at the Suit and Value for any card in the 'shredding deck'.
    Taking all this into account, so far I have the following in my Deck class. Please comment on my design so far. As you can see I've tried to follow the Law Of Demter by creating many little wrapper methods. I understand totally wh getters and setters are bad but I cannot come up with a design solution to achieve what I need to based on the rules of the game without users getters. - Any tips on this would be great.
         public Card dealCard()
              Card cardToDeal = deck.remove(0);
              return cardToDeal;
         public void addCard(Card usedCard) //This method is used to add 'used' cards to the deck.
              deck.add(usedCard);
         public Card getFaceCard() //Returns the current face up playing card
              Card faceCard = deck.get(deck.size()-1);
              return faceCard;
         public int getFaceCardValue()
              int faceCardValue = deck.get(deck.size()-1).getValue();
              return faceCardValue;
         public int getFaceCardSuit()
              int faceCardSuit = deck.get(deck.size()-1).getSuit();
              return faceCardSuit;
         public String getFaceCardName()
              String faceCardName = deck.get(deck.size()-1).toString();
              return faceCardName;
         public Card getCardAt(int position) //Returns the current face up playing card
              Card card = deck.get(position);
              return card;
         public int getFaceCardValueAt(int position)
              int cardValue = deck.get(position).getValue();
              return cardValue;
         public int getFaceCardSuitAt(int position)
              int cardSuit = deck.get(position).getSuit();
              return cardSuit;
         public String getFaceCardNameAt(int position)
              String cardName = deck.get(position).toString();
              return cardName;
         public int getDeckSize() //When recycling cards, the size of the deck is needed to determine the best time to add more cards.
              return deck.size();
         }

  • METHOD PROCESS_ACCOUNT OF BADI ME_PROCESS_PO_CUST.

    HI,
    I need to implement the method PROCESS_ACCOUNT of badi ME_PROCESS_PO_CUST.
    can anyone suugest me the samolw code for the same.
    i know i can get the account assignment data in the mathod IM_ACCOUNT->get_data.
    But how to declare the variable to store the data of im_account->getdata.
    so that i can use it in the progra?
    i mean for ex for header we will declare
    ls_header type mepoheader
    and then
    ls_header  = im_header->get-data.
    similarly can you plese tell me the declaration for storing the account assinment data.
    which table that variable will refer to.
    Smriti

    hai smriti
    u can call the method
    data: it_data type MEPOACCOUNTING
    im_accoutn->get_data  importing re_data  = it_data.
    just click the method type of parameter IM_ACCOUNT which is IF_PURCHASE_ORDER_ACCOUNT_MM  an interface
    u will get all the methods fro the same  u have ur mehtod get_data just click on it and click parameters and u get the paramter type  which is MEPOACCOUNTING
    regards
    m.a
    Edited by: mohammad afzal on Jul 9, 2009 7:11 AM

  • Question about method calling (Java 1.5.0_05)

    Imagine for example the javax.swing.border.Border hierarchy.
    I'm writing a BorderEditor for some gui builder, so I need a function that takes a Border instance and returns the Java code. Here is my first try:
    1 protected String getJavaInitializationString() {
    2     Border border = (Border)getValue();
    3     if (border == null)
    4         return "null";
    5
    6     return getCode(border);
    7 }
    8
    9 private String getCode(BevelBorder border) {...}
    10 private String getCode(EmptyBorder border) {...}
    11 private String getCode(EtchedBorder border) {...}
    12 private String getCode(LineBorder border) {...}
    13
    14 private String getCode(Border border) {
    15     throw new IllegalArgumentException("Unknown border class " + border.getClass());
    16 }This piece of code fails. Because no matter of what class is border in line 6, this call always ends in String getCode(Border border).
    So I replaced line 6 with:
    6     return getCode(border.getClass().cast(border));But with the same result. So, I try with the asSubClass() method:
    6     return getCode(Border.class.asSubClass(border.getClass()).cast(border));And the same result again! Then i try putting a concrete instance of some border, say BevelBorder:
    6     return getCode(BevelBorder.class.cast(border));Guess what! It worked! But this is like:
    6     return getCode((BevelBorder)border);And I don't want that! I want dynamic cast and correct method calling.
    After all tests, I give up and put the old trusty and nasty if..else if... else chain.
    Too bad! I'm doing some thing wrong?
    Thank in advance
    Quique.-
    PS: Sorry about my english! it's not very good! Escribo mejor en espa�ol!

    Hi, your spanish is quite good!
    getCode(...) returns the Java code for the given border.
    So getCode(BevelBorder border) returns a Java string that is something like this "new BevelBorder()".
    I want Java to resolve the method to call.
    For example: A1, A2 and A3, extends A.
    public void m(A1 a) {...}
    public void m(A2 a) {...}
    public void m(A3 a) {...}
    public void m(A a) {...}
    public void p() {
        A a = (A)getValue();
        // At this point 'a' could be instance of A1, A2 or A3.
        m(a); // I want this method call, to call the right method.
    }This did not work. So, i've used instead of m(a):
        m(a.getClass().cast(a));Didn't work either. Then:
        m(A.class.asSubClass(a.getClass()).cast(a));No luck! But:
        m(A1.class.cast(a)); // idem m((A1)a);Woks for A1!
    I don't know why m(A1.class.cast(a)) works and m(a.getClass().cast(a)) doesn't!
    thanks for replying!
    Quique

  • Passing a method call to a facelet tag

    Hello,
    I am trying to create a JSF confirmation box that replaces the Javascript confirm() function. I am using Seam and Rich Faces 3.2.1. The confirm box is a facelet tag that pops up a modal box with 'cancel' and a 'continue' buttons. Everything is working correctly except for one crucial piece; passing the method call for continue button.
    Here is the set up for the facelets tag in the main xhtml page:
    <at:confirm
        id="confirm"
        title="Confirm"
        message="Do you want to continue"
        buttonText="Continue"
        backingBean="#{confirmAction}"
        method="testMethodTwo"
    />Here is the code for the button inside the facelets tag:
    <a4j:commandLink
        styleClass="rdSplGr1"
        href="#"
        action="#{backingBean[method]}">
        <s:span>#{buttonText}</s:span>
    </a4j:commandLink>The method simply does nothing when the use clicks the button. I am assuming this is due to the lack of "()" however there does not seem to be a way to get those in there. I have tried the following:
    1) placing the parens like this - method="testMethodTwo()"
    2) placing the parens like this - action="#{backingBean[method]()}"
    The first does nothing, the second causes an EL exception.
    I know that it has nothing to do with the modal as I have also placed a button like this into the modal:
    <a4j:commandLink
        styleClass="rdSplGr1"
        href="#"
        action="#{confirmAction.testMethodOne()}">
         <s:span>MethodOne</s:span>
    </a4j:commandLink>That button as you can see has what I am trying to create dynamically and it works like a charm.
    So how do I pass a method call correctly? Or if that is impossible how do I solve the problem of having a the continue button having a different method assigned to it?
    Thanks for any insight into this.
    Edited by: Rhythmicdevil on Aug 4, 2008 7:57 AM

    I agree, reflection should be a last resort. An
    interface would not be useful if you don't know what
    method you want to invoke at compile time. Interfaces
    are useful when you know the method you want to
    invoke, but not the class.That's not true. This is a really lame-ass example but it shows the point.
    public interface RuntimeMethod
       public void method();
    class AClass {
       public static void main(Sting[] args)
          new AClass.handleAtRuntime(
             Factory.getRuntimeMethod(Integer.parse(args[0])));
       public void handleAtRuntime(RuntimeMethod runtime)
          runtime.method();
    class Factory
       public static getRuntimeMethod(int method)
          switch(method)
             case 0: return new RuntimeMethod
                public void method()
                   methodA();
             case 2: return new RuntimeMethod
                public void method()
                   methodB();
             default:
                throw new IllegalArgumentException("bad input");
    }

  • New method in a BADI

    Hello,
    how can I add a new customized method in a BADI ?
    Thank you

    Hi,
    Here is the details of BADI. There are many posts for BADI.
    I could not give you the direct link so copying one of the link details.
    DEFINING THE BADI
    1) execute Tcode SE18.
    2) Specify a definition Name : ZBADI_SPFLI
    3) Press create
    4) Choose the attribute tab. Specify short desc for badi.. and specify the type :
    multiple use.
    5) Choose the interface tab
    6) Specify interface name: ZIF_EX_BADI_SPFLI and save.
    7) Dbl clk on interface name to start class builder . specify a method name (name,
    level, desc).
    Method level desc
    Linese;ection instance methos some desc
    8) place the cursor on the method name desc its parameters to define the interface.
    Parameter type refe field desc
    I_carrid import spfli-carrid some
    I_connid import spefi-connid some
    9) save , check and activate…adapter class proposed by system is
    ZCL_IM_IM_LINESEL is genereated.
    IMPLEMENTATION OF BADI DEFINITION
    1) EXECUTE tcode se18.choose menuitem create from the implementation menubar.
    2) Specify aname for implementation ZIM_LINESEL
    3) Specify short desc.
    4) Choose interface tab. System proposes a name fo the implementation class.
    ZCL_IM_IMLINESEL which is already generarted.
    5) Specify short desc for method
    6) Dbl clk on method to insert code..(check the code in “AAA”).
    7) Save , check and activate the code.
    Some useful URL
    http://www.esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://www.esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://www.esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://www.esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    www.sapgenie.com/publications/saptips/022006%20-%20Zaidi%20BADI.pdf
    http://www.sapdevelopment.co.uk/enhance/enhance_badi.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e6/d54d3c596f0b26e10000000a11402f/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c2/eab541c5b63031e10000000a155106/frameset.htm
    Now write a sample program to use this badi method..
    Look for “BBB” sample program.
    “AAA”
    data : wa_flights type sflight,
    it_flights type table of sflight.
    format color col_heading.
    write:/ 'Flight info of:', i_carrid, i_connid.
    format color col_normal.
    select * from sflight
    into corresponding fields of table it_flights
    where carrid = i_carrid
    and connid = i_connid.
    loop at it_flights into wa_flights.
    write:/ wa_flights-fldate,
    wa_flights-planetype,
    wa_flights-price currency wa_flights-currency,
    wa_flights-seatsmax,
    wa_flights-seatsocc.
    endloop.
    “BBB”
    *& Report ZBADI_TEST *
    REPORT ZBADI_TEST .
    tables: spfli.
    data: wa_spfli type spfli,
    it_spfli type table of spfli with key carrid connid.
    *Initialise the object of the interface.
    data: exit_ref type ref to ZCL_IM_IM_LINESEL,
    exit_ref1 type ref to ZIF_EX_BADISPFLI1.
    selection-screen begin of block b1.
    select-options: s_carr for spfli-carrid.
    selection-screen end of block b1.
    start-of-selection.
    select * from spfli into corresponding fields of table it_spfli
    where carrid in s_carr.
    end-of-selection.
    loop at it_spfli into wa_spfli.
    write:/ wa_spfli-carrid,
    wa_spfli-connid,
    wa_spfli-cityfrom,
    wa_spfli-deptime,
    wa_spfli-arrtime.
    hide: wa_spfli-carrid, wa_spfli-connid.
    endloop.
    at line-selection.
    check not wa_spfli-carrid is initial.
    create object exit_ref.
    exit_ref1 = exit_ref.
    call method exit_ref1->lineselection
    EXPORTING
    i_carrid = wa_spfli-carrid
    i_connid = wa_spfli-connid.
    clear wa_spfli.
    http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm
    and
    http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm
    Badihttp://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
    http://support.sas.com/rnd/papers/sugi30/SAP.ppt
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
    http://members.aol.com/_ht_a/skarkada/sap/
    http://www.ct-software.com/reportpool_frame.htm
    http://www.saphelp.com/SAP_Technical.htm
    http://www.kabai.com/abaps/q.htm
    http://www.guidancetech.com/people/holland/sap/abap/
    http://www.planetsap.com/download_abap_programs.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
    /people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-series
    /people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework
    http://esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    http://esnips.com/doc/365d4c4d-9fcb-4189-85fd-866b7bf25257/customer-exits--badi.zip
    http://esnips.com/doc/3b7bbc09-c095-45a0-9e89-91f2f86ee8e9/BADI-Introduction.ppt
    http://help.sap.com//saphelp_470/helpdata/EN/eb/3e7cee940e11d295df0000e82de14a/frameset.htm
    Suggest to do search in SDN with key - 'BADI'
    Will get a lot of helpful discussions.
    <b>Reward points if this helps.
    Manish</b>

  • Method CHECK_BEFORE_ADD_OBJECTS fo BADi CTS_REQUEST_CHECK

    Hi Experts,
    When the method CHECK_BEFORE_ADD_OBJECTS  of BADi CTS_REQUEST_CHECK is triggered?
    I implemented it (just put a balnk if..endif condition) and put a break point in it, I created a new transport request by changing a object it was not triggered and again
    I changed some other object and included that object in the same transport request then also it was not triggered.
    Thanks
    Yogesh Gupta

    In ECC 5 this is what the documentation says.
    You can use the following methods:
        * CHECK_BEFORE_CREATION
    This method is called before a request is created and after the creation dialog box. It gives you the option to:
              o make your own checks
              o change the short text and attributes.
        * CHECK_BEFORE_RELEASE
    This method is called before a request is released. It gives you the option to:
              o make your own checks (for example, on the objects in the request)
              o change the short text and attributes.
        * CHECK_BEFORE_CHANGING_OWNER
    This method is called before the owner of the request is changed, and after the confirmation dialog box. It gives you the option to make checks.
    If you are on a higher or lower version of SAP. please read the documentation of the BADI via SE18.
    Amandeep

  • Logging method calls

    Hi all!
    I'm working on a complex java system and have problems debugging it. One of the problems is, that sometimes the program stops with a NullPointerException. Unfortunately this happens in third party code, which I do not have as source. However, I'm sure that the bug is caused by a module developed by my as exchanging this module with another implementation stops the problem.
    Is there an easy way to generate a list of method calls for an entire run of a program? At the time the exception is raised, none of my methods remains in the call stack, i.e. the exception is triggered by the foreign code, but probably caused by a value returned earlier from one of my methods. I would therefore like to see what methods have been called before the exception is triggered.
    I'm currently working with JBuilder 6. It offers a debugger, but this debugger is terrible slow and very bad when the code that is to debug is not available. You could set a method breakpoint for every method I have implemented, but this would take ages. Even with only one such exception defined, the programm takes several minutes in debug mode, while it usually takes only a fraction of a second. This seems to be completely unworkable. Another thing I have tried was the built-in profiler of the JVM, but it shows results in an aggregated and messy way, not much of a help either.
    Any better tools/techniques out there?
    Thanx in advance,
    Mathias

    A method for writing to a log file is not a problem, but I would need to add at least one line of code for every
    of my methods and, more important, a meaningful log message like the method name and arguments.
    One of the reasons I decided not to implement this, was the impossibility to determine the name or signature
    of the current method automatically.Below the code I wrote for my dissertation project. I assert my authorship and copyright of this code, and hereby grant anyone who wants it permission to reproduce this and to create derivatives. It determines the name of the current method automatically, and runs under Java 1.1 (Microsoft machine - I think the Sun machine dislikes using null as the argument for the StringStream constructor, but I wasn't worried about fixing that so haven't investigated too closely). The Tracer.enter() method appends the method name and "{" to the log file. It's proof of concept - I may write an improved version after my exams. Comments cut short to avoid annoying people who don't want to scroll too far.
    import java.io.*;
    public abstract class Tracer
        static File trace_file;
        static FileWriter fw;
        static final int METHOD = 0;
        static final int FLOW = 2;
        static final int MAJOR = 4;
        static final int MINOR = 6;
        static final int trace_level = 7;
        /* Params:    IN  filename    - a String containing the desired name for */
        /*                              the trace file.                          */
        public static void open(String filename)
            try
                trace_file = new File(filename);
                fw = new FileWriter(trace_file);
            catch (IOException ioe)
                System.out.println("IOException in Tracer.open()");  
        /* Params:    IN  s           - the String containing the trace message  */
        /*            IN  level       - the level of detail of the message       */
        /* Operation: If the specified level is sufficiently low, this method    */
        /*            constructs a Throwable and processes its stack trace to    */
        /*            find the name of the method which called trace.  It then   */
        /*            writes this method name and the trace message to the trace */
        /*            file, terminating the line with a Microsoft EOL (LF-CR).   */
        private static void trace(String s, int level)
            if (level <= trace_level)
                StringStream stringStream = new StringStream(null);
                Throwable bomb = new Throwable();
                bomb.printStackTrace(stringStream);
                String method = stringStream.getMethod();
                try
                    fw.write(method+"  "+s + "\015\012");
                    fw.flush();
                catch (IOException ioe)
                    System.out.println("IOException in Tracer.trace()");  
        /* Operation: Closes the FileWriter and sets the File and FileWriter to  */
        /*            null.                                                      */
        public static void close()
            try
                fw.close();
            catch (IOException ioe)
                System.out.println("IOException in Tracer.close()");  
            trace_file = null;
            fw = null;
        /* Operation: Calls trace with message "{" and trace level METHOD.  This */
        /*                method should be called whenever a method is entered.  */
        public static void enter(String method)
            trace("{", METHOD);
        /* Operation: Calls trace with message "}" and trace level METHOD.  This */
        /*            method should be called just before any return statement,  */
        /*            or before the final } of a method with return type void.   */
        public static void exit()
            trace("}", METHOD);
        /* Params:    IN  flow_statement                                         */
        /*                            - a description of the branch just taken   */
        /* Operation: Calls trace with message flow_statement and trace level    */
        /*            FLOW.  NB This method should be called at the start of any */
        /*            block except a method body, when enter should be called.   */
        public static void flow(String flow_statement)
            trace(flow_statement, FLOW);  
        /* Operation: Calls trace with message major_statement and trace level   */
        /*            MAJOR.  This method should be used for displaying the      */
        /*            results of important steps.                                */
        public static void major(String major_statement)
            trace(major_statement, MAJOR);
        /* Operation: Calls trace with message minor_statement and trace level   */
        /*            MINOR.  This method should be used for displaying the      */
        /*            results of minor steps.  It would probably be overkill to  */
        /*            call minor after every single statement.                   */
        public static void minor(String minor_statement)
            trace(minor_statement, MINOR);
    import java.io.*;
    /* This class, which extends PrintStream, exists to allow me to get the   */
    /* name of the method invoking trace by creating a Throwable and          */
    /* examining its stack trace.  This is more reliable than tracking the    */
    /* stack myself.                                                          */
    class StringStream extends PrintStream
        StringBuffer sb = new StringBuffer();
        int state = 0;
        public StringStream(OutputStream out)
            super(out);
        public StringStream(OutputStream out,
                            boolean autoFlush)
            super(out, autoFlush);
        String getMethod()
            String return_value = sb.toString();
            sb = new StringBuffer();
            state = 0;
            return return_value;
        public void print(char[] chars)
            for (int j = 0; j < chars.length; j++)
                print(chars[j]);
        public void print(char ch)
            switch (state)
                case 0:
                case 1:
                case 2:
                    if (ch == '\t')
                        state++;
                    break;
                case 3:
                    if (ch == ' ')
                        state++;
                    break;
                case 4:
                    if (ch == ' ')
                        state++;
                    else if (ch == '/')
                        sb.append('.');
                    else
                        sb.append(ch);
                    break;
                default:
                    // do nothing
    }

  • If statement to call a badi in logic

    Hi all,
    I have a badi to calculate amount(which is the multiplication of price and quantity) and want to call this badi behind the default logic.
    I also have a dimension called key_figures and a member as unit_price.
    What I want is to call the badi only if the user inputs value to unit_price. Otherwise default logic will work in some irrelevant screens which is not desired.For example if someone inputs due date , then calculate amount badi will be called ,too which is absurd.

    Hi Vadim,
    Thanks for your reply.
    the badi code can decide what to do checking records in ct_data
    How do I decide to calculate nothing in badi if the badi is called from irrelevant input forms.(for example in due date input form). I delete the irrelevant  data in the beginning of badi but if the user inputs due date then the badi will  delete irrelevant records but still be called and try to calculate amount which is not good for the performance.Am I correct?

  • Taskflow Method call receiving null parameter.

    Hi all,
    I am using 11.1.1.6. I have created in my application an extra project which is pure Java objects and exposed a master class as a POJO DC. In my application, I have a taskflow where I have dragged and dropped one method from my POJO DC - 2 of the parameters of this methods are coming from an application scope bean. I have debugged the application, and made sure that the object being returned by the getter of my app scope bean is not null. So basically, when the breakpoint is in the return statement of my getter the oject is not null and it has been correctly initialized. Just after that, the next breakpoint is in the class receiving the parameter in my POJO DC class. In there, the object is NULL.
    Does anyone knows wat could be the reason??

    Hi Frank Nimphius-Oracle,
    That is precisely the problem.  The object is being passed as to the taskflow as an input parameter (getting it from my application scope bean). If I access the pageFlowScope inside my taskflow I see it and its there, correctely intialized. However, when I call a method call activity that consumes that object as parameter, all what it gets is null.
    The method that consumes this object is in a separate project, and its exposed in a POJO DC. I don't know if it has to be with the complexity of the object I am passing or what but I don't understand why its not being passed correctly to the DC Method.

Maybe you are looking for