How to avaoid tables declaration in abap object 's

Hi Folks,
I realised that in abap objects we should not declare tables statement, instead we have to declare wa type dbtable. But my qsn is i am using select single * from dbtable in at selection-screen for validation, in that situation in that situation how to avoid table declaration, i tried with select single * dbtable into wa , but still its asking table declaration.
Pls help me out, thanks.
Regards
Vishal

<b>method GET_VENDOR_4_USER .
Get the Vendor for the User
data: x_lfa1 type lfa1.
  clear vendor.
  select
    lifnr
    into VENDOR
    from  zsiacvendor
    up to 1 rows
    where bname = sy-uname.
  endselect.
get the name of the vendor
  select single *
           into x_lfa1
           from lfa1
          where lifnr = vendor.
endmethod.</b>
The above code works fine for me.

Similar Messages

  • To know the functionality of table control in ABAP Objects

    Hi,
    Is there any technique to achieve the functionality of table conrol in ABAP Objects?
    Thanks.

    Hello Raja
    If you are using an editable ALV grid then you have the functionality of a table control and much much more.
    ABAP-OO based ALV grids are much more powerful (and easier) than simple table controls.
    Regards
      Uwe

  • Internal table declaration -OO ABAP

    Hi,
              I am looking to declare an internal table using OO objects. My declaration are as follows..
    TYPES : Begin of itab,
                         f1 type c,
                         f2 type c,
                 End of itab.
    DATA : itab1 type standard table of itab.
    DATA: wa_tab type itab.
    I have an internal table to say itab_pa2001 which i am reading all the records of pernr into ITAB_PA2001.To get the text i want to select * from t5*** into ..... Finally wht am looking is to move some of the fields into the final table ITAB. Could you please let me know how to set this up as i am getting wrong values when i am looping as below.
    how to declare a structure in ITAB using ABAP OO....??
    LOOP at ITAB_PA2001 into wa_itab.
    ENDLOOP.
    Thanks,
    Vind

    Hi,
    Please refer to following links :
    [How to declare an internal table in OO-ABAP programming? |Re: How to  declare an internal table in OO-ABAP programming?;
    [sample object oriented ABAP program |http://wiki.sdn.sap.com/wiki/display/Snippets/sampleobjectorientedABAPprogram]
    Hope this helps.
    Regards,
    Chandravadan

  • How to Create an XML using Abap Objects

    Hi there,
    who has an example how to create an XML Document from an internal table using abap objects
    e.g. Class CL_XML_DOCUMENT_BASE ?
    any feedback is welcome.
    thanks
    Johann

    Hi Johann,
    You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
    Regards,
    John.

  • How to use LDB PNP with ABAP objects in a program

    Hello,
    I am wondering if anybody has used the HR logical database(LDB) PNP with user defined ABAP objects in a program? I am using the FM- <b>LDB_PROCESS</b> but its not working. Also assigning PNP in the attributes section of the program -- so that I can use predefined fields from the LDB and then invoking the FM doesn't work -- throwing 'Logical database already active' error.
    I suppose even with the ABAP objects and the new FM -- I should still be able to utilize the pre-defined fields of the PNP database -- and also the built in authorizations. I cannot use GET PERNR and REJECT as they give errors. I understand that the use of HR-macros (RP-PROVIDE-FROM-LAST and et al.) are not allowed as they use the table work area -- which is not allowed in ABAP-OOPS.
    I would really appreciate if anyone could show me some insight regarding this. Thank you.
    Kshitij R. Devre

    Hi Kshitij
    It would be really good if we could use both together. But as I know, it is not possible. "GET pernr." is an event-like loop statement and so cannot be used in OO context. And I guess, the same restriction holds for the "LDB_PROCESS" since it uses LDB-specific processing.
    What I suggest you is to use standard and BAPI functions.
    Sorry for giving bad news...
    *--Serdar

  • How to implement Strategy pattern in ABAP Objects?

    Hello,
    I have a problem where I need to implement different algorithms, depending on the type of input. Example: I have to calculate a Present Value, sometimes with payments in advance, sometimes payment in arrear.
    From documentation and to enhance my ABAP Objects skills, I would like to implement the strategy pattern. It sounds the right solution for the problem.
    Hence I need some help in implementing this pattern in OO. I have some basic OO skills, but still learning.
    Has somebody already implemented this pattern in ABAP OO and can give me some input. Or is there any documentation how to implement it?
    Thanks and regards,
    Tapio

    Keshav has already outlined required logic, so let me fulfill his answer with a snippet
    An Interface
    INTERFACE lif_payment.
      METHODS pay CHANGING c_val TYPE p.
    ENDINTERFACE.
    Payment implementations
    CLASS lcl_payment_1 DEFINITION.
      PUBLIC SECTION.
      INTERFACES lif_payment.
      ALIASES pay for lif_payment~pay.
    ENDCLASS.                 
    CLASS lcl_payment_2 DEFINITION.
      PUBLIC SECTION.
      INTERFACES lif_payment.
      ALIASES pay for lif_payment~pay.
    ENDCLASS.                   
    CLASS lcl_payment_1 IMPLEMENTATION.
      METHOD pay.
        "do something with c_val i.e.
        c_val = c_val - 10.
      ENDMETHOD.                   
    ENDCLASS.                  
    CLASS lcl_payment_2 IMPLEMENTATION.
      METHOD pay.
        "do something else with c_val i.e.
        c_val = c_val + 10.
      ENDMETHOD.  
    Main class which uses strategy pattern
    CLASS lcl_main DEFINITION.
      PUBLIC SECTION.
        "during main object creation you pass which payment you want to use for this object
        METHODS constructor IMPORTING ir_payment TYPE REF TO lif_payment.
        "later on you can change this dynamicaly
        METHODS set_payment IMPORTING ir_payment TYPE REF TO lif_payment.
        METHODS show_payment_val.
        METHODS pay.
      PRIVATE SECTION.
        DATA payment_value TYPE p.
        "reference to your interface whcih you will be working with
        "polimorphically
        DATA mr_payment TYPE REF TO lif_payment.
    ENDCLASS.                  
    CLASS lcl_main IMPLEMENTATION.
      METHOD constructor.
        IF ir_payment IS BOUND.
          me->mr_payment = ir_payment.
        ENDIF.
      ENDMETHOD.                  
      METHOD set_payment.
        IF ir_payment IS BOUND.
          me->mr_payment = ir_payment.
        ENDIF.
      ENDMETHOD.                  
      METHOD show_payment_val.
        WRITE /: 'Payment value is now ', me->payment_value.
      ENDMETHOD.                  
      "hide fact that you are using composition to access pay method
      METHOD pay.
        mr_payment->pay( CHANGING c_val = payment_value ).
      ENDMETHOD.                   ENDCLASS.                  
    Client application
    PARAMETERS pa_pay TYPE c. "1 - first payment, 2 - second
    DATA gr_main TYPE REF TO lcl_main.
    DATA gr_payment TYPE REF TO lif_payment.
    START-OF-SELECTION.
      "client application (which uses stategy pattern)
      CASE pa_pay.
        WHEN 1.
          "create first type of payment
          CREATE OBJECT gr_payment TYPE lcl_payment_1.
        WHEN 2.
          "create second type of payment
          CREATE OBJECT gr_payment TYPE lcl_payment_2.
      ENDCASE.
      "pass payment type to main object
      CREATE OBJECT gr_main
        EXPORTING
          ir_payment = gr_payment.
      gr_main->show_payment_val( ).
      "now client doesn't know which object it is working with
      gr_main->pay( ).
      gr_main->show_payment_val( ).
      "you can also use set_payment method to set payment type dynamically
      "client would see no change
      if pa_pay = 1.
        "now create different payment to set it dynamically
        CREATE OBJECT gr_payment TYPE lcl_payment_2.
        gr_main->set_payment( gr_payment ).
        gr_main->pay( ).
        gr_main->show_payment_val( ).
      endif.
    Regads
    Marcin

  • How to detect modifications in an ABAP Object?

    Hi all,
    I was wondering if there's a simple way of detecting modifications in an ABAP Object.
    Imagine an ABAP entity object which holds several attributes and you need to know if this object has been modified. Instead of having to check attribute by attribute to compare it's previous value with the new one I came with the idea of calculating a HASH code for the object before the execution of the application which can change the object attributes and comparing it with the HASH calculated for the same object after the execution.
    That way, checking only two hashes simplifies a lot the code. So.... is there any way of calculating a HASH for any object instance? if not... any other approach?
    Thanks in advance.

    Sorry Hüseyin Dereli, but I'm not talking about source version control, but how to detect attribute modifications of an ABAP Object Instance.
    for example, suppose you have a program which reads data from DataBase and stores temporally that data into an ABAP Object like this:
    ABAP Object AAAA{
       private attr1
       private attr2
    and passes this ABAP Object into a screen for user interaction, or even a FunctionModule or Method or anything else...
    data: myObject type ref to AAAA.
    myObject-attr1 = 1
    myObject-attr2 = 2.
    CallFunction AnyFunction Changing data = myObject
    After the execution of AnyFunction I would like to know if myObject has been changed but I'm trying not to check attribute by attribute because if myObject has a lot of attributes (not in this example but in the real source code)
    It would be great if we could do something like this:
    data: myObject type ref to AAAA,
              oldHash type hash,
               newHash type hash.
    myObject-attr1 = 1
    myObject-attr2 = 2.
    oldHash = myObject->get_hash()
    CallFunction AnyFunction Changing data = myObject
    newHash = myObject->get_hash()
    if oldHash NE newHash.
    * MyObject has been modified
    endif.

  • Passing a program defined internal table to an abap object

    Hi. I have an internal table that was previously defined and created by SAP that I need to process in a user exit. The table is defined exactly as shown below.
    Is it possible to pass a table that was defined in this manner (not in the ABAP dictionary) as an argument to a method of an ABAP object?
    If so, what would the data type of the itab parameter have to be when defining the object's method parameter list? Is it necessary to somehow "cast it" to the KNA1 table type once I receive the table into the method? If so, what is the data type of the object's receiving variable/attribute?
    data: begin of lkna1 occurs 0001.
            include structure kna1 .
    data:
          end of lkna1 .
    Just as one additional piece of information, I am using version 4.5B and I am trying to do this through se24.
    Thanks so much!

    Hi again,
    <b>This kind of simple approach,
    we can pass ANY KIND OF TABLE
    WITHOUT HAVING TO DEFINE
    LINE TYPE IN SE11.</b>
    1. doing this simply u will achieve what u want.
      ( i just tried the same)
    2. in se24,
      give like this
    ITAB     Importing     Type     <b>STANDARD TABLE</b>
    3. in the calling program,
      call like this,
    report abc.
    data: begin of lkna1 occurs 0001.
    include structure kna1.
    data: end of lkna1.
    data: testobj type ref to zsdtest.
    select * from kna1
    into table lkna1.
    lkna1-kunnr  = '000234'.
    create object testobj.
    <b>call method testobj->testreceive
    exporting itab = lkna1[].</b>
    4.
    then in the class, source code,
    just use like this
    (so that u can accesss the fields of the itab,
    using myitab)
    <b>method TESTRECEIVE .
    data : myitab type table of kna1.
    myitab[] = itab[].
    break-point.
    endmethod.</b>
    5. thats all !
    regards,
    amit m.

  • How to change original language of ABAP objects?

    HI,
    I have created a BADI and an interface in R/3 release 6. I created the BADI in original language German, but by mistake I created the interface in Original langauge English.
    Is there a way to change the original language of the interface to German? I tried editing and activating the interface in German logon, but it did not help as teh Original langauge of the interface remained as English.
    Is there any SAP report which would help me to change the original language of ABAP objects?
    Regards,
    Srini.

    Hi,
    Here's the way out:
    Step 0. Delete the object
    Step 1. Delete the object directory entry(If it says entry doesnt exist, recreate it - ie. the object dir. entry)
    Step 2. Login to the language of choice - In ur case 'DE'
    Step 3. Recreate the new object
    Voila!!! Original Language changed
    Cheers,
    Gaurav

  • How to search for the particular ABAP Object

    Hi,
    I am using the SAP 4.6C machine, I need to search for the particular ABAP Object. Plz can anyone help me in this.
    Regards,
    Pralhad P. Teggi

    You'll get a better response if you ask a meaningful question.
    If you want to scan for Business Objects (BOR) use transaction SWO1
    For ABAP classes / objects use a combination of transactions SE24 / SE18 / SE19 and /or SE80
    (SE 18 /  SE 19 are for Badi's)
    Cheers
    Jimbo

  • ADF -how to create table binding when view object is no known until runtime

    I want to programmatically create a table binding to a view object where the view object name is not known until run-time. Then I will use a dynamic table to display it. Can anyone provide an example?

    I looked at example #9. It gets me closer to what I am looking for but not quite enough. In my case, I don't have (or want in this case) a pageDefinition with a pre-declared Iterator binding. I am converting an exsisting BC4J/Struts/JSP application. I would like to rewrite my reusable component tags to make use of ADF bindings and Faces. My tags are passed the ApplicationModule and ViewObject names as parameters, much like the old BC4J datatags. I do not want to go back and rewrite all of my pages from scratch using drag-and-drop declarative bindings with a pageDefinition for every page. I am hoping to have my rewritten tags handle everything programmatically based only on the ViewObject name passed at run-time.

  • Internal table modification in ABAP object event

    Hi Gurus
    I have an internal table displayed using ALV - OOPS concept. THe internal table has 15 rows in my test program but it can go up depending on user inpout.
    I am able to display it . on the screen . One of the fields is editable . It is required that it take input from user and on pressing enter , the value entered in that cell should be subtracted from a total amout displayed in the cell next to it.
    I have used the following code . There are no errors , but nothing happens when I edit it. The screen remains as it is.
    Any help will be very useful
    DATA : ITAB type ITABT occurs 0.
    DATA : itab_w  like line of  itab.
    CLASS LCL_EVENTS_D0100 IMPLEMENTATION.
    METHOD handle_data_changed.
    DATA: ls_good TYPE lvc_s_modi.
    DATA : L_PLANETYPE TYPE ITABT-SEL_QUANT.
    LOOP AT er_data_changed->mt_good_cells INTO ls_good.
          CASE ls_good-fieldname.
    check if column PLANETYPE of this row was changed
            WHEN 'SEL_QUANT'.
              CALL METHOD pr_data_changed->get_cell_value
                 EXPORTING
                   i_row_id = ls_good-row_id
                   i_fieldname = ls_good-fieldname
                 IMPORTING
                   e_value = l_planetype.
          ENDCASE.
          LOOP AT ITAB INTO ITAB_W .
          read table itab into itab_w WITH KEY FINDEX = LS_GOOD-ROW_ID .
          itab_w-f_balquant = itab_w-f_balquant - l_planetype.
          modify itab FROM itab_w .
        endloop.
          ENDLOOP.
    ENDMETHOD.
    ENDCLASS.

    Hi,
    Hi,
    AND also use
    * Module Pai INPUT                                                     *
    * PAI module                                                           *
    module pai input.
      save_ok = ok_code.
      clear ok_code.
      call method grid1->check_changed_data
        importing
          e_valid = v_valid.
    " After this system will automatically update your changed data into
    " internal table t_zthlog
      case save_ok.
        when 'EXIT'.
          perform f_exit_program.
        when 'CANC'.
          perform f_exit_program.
        when 'BACK'.
          perform f_exit_program.
        when 'SAVE'.
          perform f_save_data.
      endcase.
    endmodule.                               " Pai INPUT
    aRs

  • Declaring the internal table in ABAP objects

    Hi every1,
    Please any one let me know how to declare an internal table in class (ABAP objects). Bcos i am new to this classes.
    help me out.
    Regards,
    Madhavi

    Hi,
    Check this example..
    TYPES: BEGIN OF TYPE_DATA,
                   MATNR TYPE MATNR,
                   WERKS TYPE WERKS_D,
                 END OF TYPE_DATA.
    DATA: T_DATA TYPE STANDARD TABLE OF TYPE_DATA.
    DATA: WA_DATA TYPE TYPE_DATA.
    Adding rows to the internal table.
    WA_DATA-MATNR = 'AA'.
    APPEND WA_DATA TO T_DATA.
    Processing the interna table
    LOOP AT T_DATA INTO WA_DATA.
    ENDLOOP.
    Thanks,
    Naren

  • Passing an internal table WITH HEADER LINE to abap object

    Hi. In another thread, it was explained how to pass an internal table to an abap object method. Is it possible to pass an internal table that has a header line, and RETAIN the header line once the table has been passed?
    My problem is, that I can pass the table, update it, but the read buffer is not populated when returning from the object's method. This is the result of being able to pass a STANDARD TABLE type, but not a STANDARD TABLE WITH HEADER LINE.
    This means that I have to read the table into a work area instead of doing a READ TABLE LKNA1 within the method, which is what I need to do.
    Thanks.

    Please check this sample program, notice that it is modifing the internal table and passing it back modified as well as passing the "work area" or "header line" back thru the exporting parameter.
    report zrich_0001.
    *       CLASS lcl_app DEFINITION
    class lcl_app definition.
      public section.
        types: t_t001 type table of t001.
        class-data: it001 type table of t001.
        class-data: xt001 like line of it001.
        class-methods: change_table
                                    exporting ex_wt001 type t001
                                    changing im_t001 type t_t001.
    endclass.
    data: w_t001 type t001.
    data: a_t001 type table of t001 with header line.
    start-of-selection.
      select * into table a_t001 from t001.
      call method lcl_app=>change_table
                 importing
                     ex_wt001 = w_t001
                 changing
                     im_t001  = a_t001[] .
      check sy-subrc  = 0.
    *       CLASS lcl_app IMPLEMENTATION
    class lcl_app implementation.
      method change_table.
        loop at im_t001 into xt001.
          concatenate xt001-butxt 'Changed'
               into xt001-butxt separated by space.
          modify im_t001 from xt001.
        endloop.
        ex_wt001 = xt001.
      endmethod.
    endclass.
    Regards,
    Rich Heilman

  • Wa in ABAP Objects

    Hello!
    How can I write wa in ABAP Objects?
    CLASS money DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: wa TYPE zaa_sflight,
        wa1 TYPE TABLE OF wa.
        CLASS-METHODS zmoney.
    ENDCLASS.
    The program says, wa is unknown. How can I write it correct?
    Thanks!!

    Hi Andrei Algaier,
        This is because wa is not defined as datatype in datadictionary or in program with types statement.
    example:
    types : wa type c.
    data : xyz type wa.
    xyz will be of type c.
    This might be helpful.
    Regards,
    Kalyan.

Maybe you are looking for

  • How do i get free games for my ipod classic?

    Please can someone help me? I love to play games but when I downloading them on the Itunes store and try to get them on my Ipod classic, they aren't sycronist on it! What can I do?

  • Can Calendar Alerts Be Changed?

    Hi, I'm a very happy iPhone user, in fact it is probably the best little device I have ever owned. Apart from the main features it has to offer, alot of the enjoyment I get from it is due to the quirky sounds & tones you can choose for a new SMS, and

  • I cannot access the internet. When I type in a search nothing happens.

    My yahoo homepage opens ok. I can access mail. However, when I type in a search for a web site nothing happens. It says its connecting for 3-5 minutes then just stops and I am not connected. This just started about an hour or so ago.

  • How can I get this effect in FCPX

    https://www.youtube.com/watch?v=MkxYnzGWV4w I want to key frame the color of a character like this one was changed for me.

  • Clarification in VF11

    Gurus, The invoice having line items 100, 200, 300 and the requirement is to reverse line 200, since single invoice have been raised for group deliveries, User need to cancel the particular delivery and subsequent doc. In VF11, the reversing happens