How to define a TYPE REF TO data into my local variable/structure?

Hello,
I am trying to implementing a BADI, in its signature part,
c_accit TYPE REF TO data.
My pseudo code goes like,
DATA: l_itm_details TYPE REF TO data.
l_itm_details = c_accit.
l_itm_details-koart = 'D' =====> here am getting error!
* Do processing
ENDIF.
Here am getting error that, l_itm_details is not a structure! Pls. let me know how to fix it?
Thank you

Hello,
c_accit TYPE REF TO data.
C_ACCIT is a "data reference" parameter. In order to access its components you have to "de-reference" it!
FIELD-SYMBOLS: <l_itm_details> TYPE ANY,
<l_value> TYPE ANY.
ASSIGN c_accit->* TO <l_itm_details>."De-reference the data reference
ASSIGN COMPONENT 'KOART' OF STRUCTURE <l_itm_details> TO <l_value>.
If you know the structure of the data reference variable you can define your field-symbol <l_itm_details> of that type directly, else you can define a generic type as mentioned in the code snippet.
BR,
Suhas

Similar Messages

  • How to use record type for inserting data into a table

    I've read through the web the following tip:
    "When working with a large number of columns, using variables of type RECORD is a better approach. With this approach, you do not have to list anything in the INSERT statement, because you are inserting a variable into the table that is defined as a row from the same table."
    I usually define a variable as
    r_mytable     mytable%ROWTYPE;
    and inside my procedure I'll set the fields I need as
    r_mytable.field1 := 1;
    r_mytable.field3 := 7;
    and then I perform the insert as
    insert into mytable
    (field1,
    field3)
    values
    (r_mytable.field1,
    r_mytable.field3);
    According to the tip I've copied above, how can I use the TYPE RECORD of pl/sql for achieving the same result but perhaps in a smarter way?
    Thanks in advance!

    Hi,
    Are you looking for this?
    SQL> create table table1 (id number, descr varchar2(30));
    Table created
    SQL>
    SQL> DECLARE
      2   my_rec table1%rowtype;
      3  BEGIN
      4   my_rec.id := 1;
      5   my_rec.descr := 'TEST';
      6   insert into table1 values my_rec;
      7  END;
      8  /
    PL/SQL procedure successfully completed
    SQL> select * from table1;
       ID DESCR
        1 TESTWorks with UPDATE too :
    SQL> DECLARE
      2   my_rec table1%rowtype;
      3  BEGIN
      4   my_rec.id := 2;
      5   my_rec.descr := 'TEST2';
      6   update table1 set row = my_rec where id = 1;
      7  END;
      8  /
    PL/SQL procedure successfully completed
    SQL> select * from table1;
       ID DESCR
        2 TEST2

  • Add line to type ref to data field - type table

    HI All,
    I have field that is defined as type ref to data ,and the type of it is table with data inside of it lr_data.
    I have the also the table type of lr_data and I want to add additional line to the type ref to data field.
    How can i do that ?
    For example
    TYPES: BEGIN OF bank_list,
             country_key type string,
             bank_key    type string ,
             bank_name   type string,
             bank_city  type string    ,
           END OF bank_list.
    data lt_bank type table of bank_list.
    data lr_data data  ref to data.
    Now lr_datae is  type lt_bank " in _Runtine
    and contain 4 entries .
    I get the lr_data with 4 entries and I want to add new entry to the table.
    How can I do that?
    Thanks,
    Joy
    Edited by: Joy Stpr on Feb 8, 2012 10:05 PM

    Hello Joy,
    You can check this code snippet to get an idea on how to proceed with your requirement:
    CLASS lcl_add_data DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS add_data CHANGING ch_data TYPE REF TO data
                               EXCEPTIONS err_invalid_type.
    ENDCLASS.                    "lcl_add_data DEFINITION
    *       CLASS lcl_add_data IMPLEMENTATION
    CLASS lcl_add_data IMPLEMENTATION.
      METHOD add_data.
        DATA: lo_tabdescr   TYPE REF TO cl_abap_tabledescr,
              lo_strucdescr TYPE REF TO cl_abap_structdescr,
              ls_component  TYPE abap_compdescr.
        FIELD-SYMBOLS: <lt_data>      TYPE STANDARD TABLE,
                       <ls_data>      TYPE any,
                       <lv_fieldval>  TYPE any.
        IF ch_data IS BOUND.
    *     Get the runtime type object
          lo_tabdescr  ?= cl_abap_typedescr=>describe_by_data_ref( ch_data ).
    *     Check  if supplied param is table
          IF lo_tabdescr->type_kind NE cl_abap_typedescr=>typekind_table.
            RAISE err_invalid_type.
          ENDIF.
        ELSE.
          RETURN.
        ENDIF.
        ASSIGN ch_data->* TO <lt_data>. "Dereferencing the data reference
    *   Get the line type of table
        lo_strucdescr ?= lo_tabdescr->get_table_line_type( ).
        DO 2 TIMES.
    *     Add initial line to the table
          APPEND INITIAL LINE TO <lt_data> ASSIGNING <ls_data>.
          CLEAR <ls_data>.
    *     Loop on the fields of the structure & populate them
          LOOP AT lo_strucdescr->components INTO ls_component.
            ASSIGN COMPONENT ls_component-name OF STRUCTURE <ls_data> TO <lv_fieldval>.
            CASE ls_component-name.
              WHen 'COUNTRY_KEY'.
                <lv_fieldval> = `My Country`.
              WHEN 'BANK_KEY'.
                <lv_fieldval> = `123`.
              WHEN 'BANK_NAME'.
                <lv_fieldval> = `My Bank`.
              WHEN 'BANK_CITY'.
                <lv_fieldval> = `My City`.
            ENDCASE.
          ENDLOOP.
        ENDDO.
      ENDMETHOD.                    "add_data
    ENDCLASS.                    "lcl_add_data IMPLEMENTATION
    TYPES:
    BEGIN OF bank_list,
      country_key TYPE string,
      bank_key    TYPE string,
      bank_name   TYPE string,
      bank_city   TYPE string,
    END OF bank_list.
    DATA: lt_bank TYPE STANDARD TABLE OF bank_list,
          lr_data TYPE REF TO data.
    START-OF-SELECTION.
      GET REFERENCE OF lt_bank INTO lr_data. "Get reference
    * Add the data to the data reference
      lcl_add_data=>add_data( CHANGING    ch_data = lr_data
                              EXCEPTIONS  err_invalid_type = 1 ).
    BR,
    Suhas

  • Passing value from field symbol / variable type ref to data to variable

    hey ,
    DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
      DATA: RT_CARRID TYPE REF TO DATA.
      FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE
    .* Retrieve the data from the select option
      RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_WEIGHT).
    Assign it to a field symbol
      ASSIGN RT_CARRID->* TO <FS_CARRID>.
    how can i pass RT_CARRID or <FS_CARRID> to a varible with type vbap-netgrw ( net weight ) ?
    thanks
    ASA

    >
    ASA MOKED wrote:
    > hey ,
    >
    >
    > DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
    >   DATA: RT_CARRID TYPE REF TO DATA.
    >   FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE

    > .* Retrieve the data from the select option
    >   RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_WEIGHT).
    > * Assign it to a field symbol
    >   ASSIGN RT_CARRID->* TO <FS_CARRID>.
    create a work area of type <FS_CARRID>.
    field-symbol: <fs_wa> type line of <FS_CARRID>.
    loop at <FS_CARRID> into <fs_wa>.
    lv_netgr = <fs_wa>-netgr.

  • Data: stru_tab type ref to data? what data refers to?

    Dear friends,
                         Relatively iam new to WDA. can u please explain me below statement.
    data: stru_tab type ref to data.

    Actually there are not really any Web Dynpro sepecific data types.  The ones mentioned are simply data dictionary data types that are defined for use with WD, but can be used in any ABAP applications.  You should start your research with just ABAP data types.  Look in the ABAPDOCU transaction or search the keyword documentation for DATA. There is lots of documentation on the ABAP native data types.
    Here is a little bit of it:
    Predefined ABAP Types
    The table below shows the predefined ABAP types. Additional attributes can be found under value ranges and initial values.
    Type Length Standard length Description
    b 1 Byte   1 byte integer (internal)
    c 1 to 65,535 characters 1 character Text field
    cursor as i as i Database cursor
    d 8 characters   Date field
    f 8 bytes   Floating point number
    i 4 bytes   4 byte integer
    n 1 to 65,535 characters 1 character Numeric text
    p 1 to 16 bytes 8 bytes Packed number
    string variable   Text string
    s 2 bytes   2 byte integer (internal)
    t 6 characters   Time field
    x 1 to 65,535 bytes 1 byte Byte field
    xstring variable   Byte string
    These types are predefined in every ABAP program.
    All predefined ABAP types in this table are elementary.
    Apart from the types b and s, the predefined ABAP types can also be used to define your own data types and data objects and for typing. The types b and s cannot be specified directly in ABAP statements. Self-defined data types and data objects in ABAP programs are of the data type b and s if they are defined with reference to data elements to the ABAP Dictionary which are of the external data types INT1 or INT2.
    The predefined data types string and xstring describe data objects of variable length (dynamic data objects). While the length of data objects in all other elementary data types is determined for its whole lifetime, the length of text and byte strings varies according to their content (the maximum size of a string is determined by profile parameter ztta/max_memreq_MB, see Maximum size of dynamic data objects).
    The program-globally predefined data type cursor is currently synonymous with the predefined ABAP type i. This is required for the declaration of a cursor variable for database cursor handling.
    All predefined ABAP types for which a length interval is specified in second column in the table are generic, which means that the length is not part of the type description. For the type p, the fractional portion is indefinite as well as the length.
    The entries in the standard length column specify the length that is used for the corresponding generic data type when declaring data objects, if no explicit length is specified in the relevant statement.
    In Unicode systems, the length must either be specified in characters and bytes. In non-Unicode systems, the length of a character is one byte, but in Unicode systems the length of a character depends on which Unicode character representation is used.
    Generic ABAP Types
    The following table shows the predefined generic ABAP types. A generic data type is an incomplete type specification that includes several complete type specifications. The generic types can be used for the typing of field symbols and formal parameters. The only generic type that can be used for typing of data references is the predefined type data. The predefined generic type for object references is object. When a data object is assigned to generically typed field symbols using the statement ASSIGN, or to a formal parameter in procedure calls, the system checks whether its concrete data type is a of the generic type, or is compatible with it.
    Type Description
    any Any data type (suitable for any type)
    any table Internal table of any table type
    c Text field of generic length
    clike Character-type (c, d, n, t, string and character-type flat structures); in non- Unicode programs also x, xstring and any flat structures
    csequence Text-type (c, string)
    data Any data type
    hashed table Hashed table
    index table Index table
    n numeric text of generic length
    numeric Numeric (b, i, p, f, s)
    object Any object type (root class of the inheritance hierarchy)
    p Packed number of generic length and generic number of decimal places
    simple Elementary data type including structured types with exclusively character-type flat components
    sorted table Sorted table
    Standard table Standard table
    table Standard table
    x Byte field of generic length
    xsequence byte-type (x, xstring)
    The genric types clike, csequence, numeric,simple, and xsequence are available as of release 6.10.
    Notes
    The generic type any currently has the same effect in typing as the generic type data. When declaring references, any cannot yest be specified after REF TO. Generic data references (REF TO data) or generic object references (REF TO object) are possible. The generic type object can currently only be specified after REF TO.
    Except for the built-in generic types illustrated in the table above, there are at the moment no self-defined generic types in ABAP with only one exception: A table type defined with TYPES - TABLE OF or defined in the ABAP Dictionary without completely specifying the table key, is also generic.
    Predefined Types in the ABAP Dictionary
    The following table lists the predefined types in the ABAP Dictionary. These types cannot be used directly in ABAP programs, and are therefore known as external data types. Instead, they are used in the ABAP Dictionary for the definition of data types to which ABAP programs can refer. The predefined data types of the ABAP Dictionary must also be taken into account in Open SQL statements and when working with screens: Open SQL statements work with database tables defined in the ABAP Dictionary whose colums have external data types. Screen fields are also declared in the Screen Painter with reference to external data types.
    Type Permitted Places m Meaning ABAP Type
    ACCP 6 Accounting period n(6)
    CHAR 1-255 Character string c(m)
    CLNT 3 Client c(3)
    CUKY 5 Currency key c(5)
    CURR 1-31 Currency field p((m+1)/2)
    DATS 8 Date d
    DEC 1-31 Calculation/amount field p((m+1)/2)
    FLTP 16 Floating point number f(8)
    INT1 3 1 byte integer b
    INT2 5 2 byte integer s
    INT4 10 4 byte integer i
    LANG 1 Language c(1)
    LCHR 256-... Long character string c(m)
    LRAW 256-... Long byte string x(m)
    NUMC 1-255 numerischer Text n(m)
    PREC 2 Accuracy of a quantity field s
    QUAN 1-31 Quantity field p((m+1)/2)
    RAW 1-255 Byte sequence x(m)
    RAWSTRING 256-... Byte sequence xstring
    SSTRING 1-255 Character string string
    STRING 256-... Character string string
    TIMS 6 Time t
    UNIT 2-3 Unit key c(m)
    For types LCHR and LRAW, the maximum number of places in a transparent database table is the value of the preceding INT2 field.
    The types RAWSTRING and STRING have a variable length. A maximum length for these types can be specified, but has no upper limit.
    The type SSTRING is available as of release 6.10 and it has a variable length. Its maximum length must be specified and is limited to 255. The advantage of this type compared with CHAR, is that it is assigned to the ABAP type string.
    The table below shows the data types of the ABAP Dictionary that are based on the predefined types in the above table, and that can be addressed in an ABAP program. The elementary components of these data types are converted to predefined ABAP data types according to the final column in the above table, whereby the number of places m of each type is converted to lengths.
    Data types in the ABAP Dictionary Data types in ABAP
    Data element Elementary data type, Reference type
    Structure, Database table, View Structured data type
    Table type Table type
    Note
    As of release 6.20, a component of structures or database tables that has the type LANG can be identified as a text language. The text language is used for the conversion of character-type components of the structure when importing data from data clusters and for RFC between MDMP systems and Unicode systems.

  • How to insert more than 32k xml data into oracle clob column

    how to insert more than 32k xml data into oracle clob column.
    xml data is coming from java front end
    if we cannot use clob than what are the different options available

    Are you facing any issue with my code?
    String lateral size error will come when you try to insert the full xml in string format.
    public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
      boolean isUpdated = true;
      Connection connection = null;
      try {
      connection = ConnectionManager.getConnection ();
      //connection.setAutoCommit ( false );
      PreparedStatement PREPARE_STATEMENT = null;
      String sqlQuery = "UPDATE " + tableName + " SET " + columnName + "  = ?  WHERE ID =" + id;
      PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
      // converting string to reader stream
      Reader reader = new StringReader ( strContents );
      PREPARE_STATEMENT.setClob ( 1, reader );
      // return false after updating the clob data to DB
      isUpdated = PREPARE_STATEMENT.execute ();
      PREPARE_STATEMENT.close ();
      } catch ( SQLException e ) {
      e.printStackTrace ();
      finally{
      return isUpdated;
    Try this JAVA code.

  • How to select data into multiple bind variables

    Hi,
    I need to load data into multiple bind variable how to do that
    As of now i am using this
    select a , b into :a, :b from dual
    But i want even a to be loaded into both :a and :c also b to be loaded into :b and :d Please suggest
    Thanks
    Sudhir.

    Thanks much it worked
    Thanks
    Sudhir

  • How to define complex type with table per record?

    Hi,
    for one of my tasks I'm dealing with XML export. After short investigation of the postings in the forum I found an acceptable solution:
    Re: Convert ABAP to XML and Vice versa
    The issue is that I need an XML file like this:
    <plant>
      <material>
        <purchases>data</purchases>
        <purchases>data</purchases>
        <purchases>data</purchases>
        <sales>data</sales>
        <sales>data</sales>
        <sales>data</sales>
      </material>
      <next material>
      </next material>
    </plant>
    So here are the questions:
    1. Is it possible (and how) to define such deep structured type where for each record (means material) there is at least 1 internal table connected to that record? That would let me use a record-2-DOM conversion and a standard DOM-2-XML renderer.
    2. Could anyone please provide a very simple and short example?
    Of course, I could write my own XML renderer and achieve what I need (without using DOM, simply write to file all the desired XML tags while looping at my *nested* tables), but if there is a way to define such a structured type and further to fill it with data, it would help me learn a little bit more about abap opportunities and would save me a bit more time to create a renderer.
    Many thanks in advance.
    Regards,
    Ivaylo Mutafchiev

    Hi,
    You can declare deep structure as below
    TYPES : BEGIN OF ty_address,
              house(10) TYPE c,
              street(10) TYPE c,
            END OF ty_address.
    TYPES : BEGIN OF ty_itab,
             name(10) TYPE c,
             age      TYPE i,
             address  TYPE ty_address OCCURS 0,
            END OF ty_itab.
    DATA : i_address TYPE STANDARD TABLE OF ty_address,
           i_itab    TYPE STANDARD TABLE OF ty_itab.
    DATA : wa_address TYPE  ty_address,
           wa_itab TYPE  ty_itab.
    CLEAR :  wa_address,
             wa_itab.
    wa_address-house = 'House1'.
    wa_address-street = 'Street1'.
    APPEND wa_address TO i_address.
    wa_address-house = 'House2'.
    wa_address-street = 'Street2'.
    APPEND wa_address TO i_address.
    wa_itab-name = 'Test'.
    wa_itab-age  = 10.
    wa_itab-address[] = i_address[].
    APPEND wa_itab TO i_itab.
    Also check structure BSPL_GRID_FIELDCAT field CELL_COLOR

  • How to define a text index in data modeler

    Hello,
    how to define a text index (indextype is ctxsys.context) in data modeler?
    The SQL-command would be:
    create index P1_TEXT_BESCHR_SPRACHE on P1_PDM_MODUL_SPRACHE(BESCHREIBUNG) indextype is ctxsys.context
    parameters ('lexer global_lexer language column LANGUAGE format column FORMAT STORAGE PDMSTORE')
    online
    Thanks in advance for any help.
    Monika

    Hi Monika,
    After creating relational model, you'll have to create physical one. In physical model there is index properties dialog, where you can adjust context index properties.

  • How to define reminder letter before due date

    Dear Expert,
    How to define dunning procedure in FBMP (for tcode F150) for this condition:
    1st reminder letter should be generated 7 days before due date.
    Currently the setting for dunning level is 4 (days in arrears: blank, 14, 60, 180)
    But I confuse how to be set in 'Days in Arrears' for the first reminder letter?(I set blank since could not set as negative, e.g -7 (7 days before due dates)
    Kindly advice
    Thank you.

    Hi
    maintain Denning Level like Below
    Days in arrears            0    7  53   173
    Calculate interest
    Print Parameters
    Always dun?
    Print all items
    Payment deadline      7     7     7   7
    hope it will resolve your issue
    satish

  • How to define DefaultTableModel to use vector data?

    Hi ...
    I want to show files data in a jtable which consist of files (Name,size,path) I want to use vectors for remove and add methods. The problem is with data vector I tried to define it as
    Vector <Vector[][]>data;I get always an error when I tried to add data to data vector so where is my problem?
    Thanks.
    Feras

    Vector <Vector[][]>data;You are confusing 2Dimensional arrays with Vectors. When using Vectors you need to create a Vector of Vectors. The code should be something like this;
    Vector<Vector> data = new Vector<Vector>();
    Vector<Object> row1 = new Vector<Object>();
    row1.add(name);
    row1.add(size);
    row1.add(path);
    data.add(row);Presumably the code to add the rows would be in a loop.

  • How do I put and sort string data into an array?

    I have a txt file that has the following sample data:
    Sample.txt----
    Jones Bill 12,500 Salesperson
    Adams Frank 34,980 Manager
    Adams John 23,000 Salesperson
    Thompson Joe 59,500 Trainee
    I need to incorporate each line of data into an individual array element, while using a user-defined method
    (ex. setAllValues(String last, String first, String salary, String job)
    How do I loop the data into the array to be displayed and what is the best way to do sorts on this sample data. Any code or clues would be super helpful.
    Sanctos

    If you set up an array of Strings you can use the java.util.Arrays.sort() method to sort it. If you need to sort arbitrary Objects (i.e. your 3 strings as a whole entity) your 3-way object will have to either implement Comparable or you could write a Comparitor class to do the ordering. Not much to it, though.
    Dom.

  • How to import Filenames and File creation Date into Table..

    Hi Folks,
    I am importing Differennt Excels Files into table. my require ment is after importing completed I need to insert all these Filenames ,File creation date into table. (for Auditing).
    Can you please give me any ideas or reference link.  Thanks In Advance.

    Hi Folks,
    I am importing Differennt Excels Files into table. my require ment is after importing completed I need to insert all these Filenames ,File creation date into table. (for Auditing).
    Can you please give me any ideas or reference link.  Thanks In Advance.
    You can also prepare dir command and then exeucte it by using XP_CMDSHELL. This gives you file name, modified date, creation date information.
    Please refer:
    https://sqljourney.wordpress.com/2010/06/08/get-list-of-files-from-a-windows-directory-to-sql-server/
    https://hernandezpaul.wordpress.com/2013/02/15/store-file-names-and-modified-dates-in-a-table-without-a-foreach-loop-task-sql-server-ssis/
    Cheers,
    Vaibhav Chaudhari
    [MCP],
    [MCTS], [MCSA-SQL2012]

  • JSP/BC4J app: How to get view object row data into a scriplet variable?

    I have a JSP application using BC4J data tags. Within a rowsetiterate tag, how can I get the data value of an attribute for the current row into a scriplet variable?
    Thanks,
    Steve

    Using the <jbo:Row> tag like this:
      <jbo:RowsetIterate .... >
        <%--
         | Establish a scriptable variable "curRow" for the current row
         +-->
        <jbo:Row id="curRow" action="current"/>
        <%
          String foo = (String)curRow.getAttribute("YourAttrName");
        %>

  • How to show NULL value when import data into excel

    when retrieve data from sql server and import these data into excel.
    data source  is like : select a ,b c from tab
    if a,b,c is nullable. when import these NULL value into excel, it becomes blank value, there is nothing in the excel cell.
    if i don't want to use select isnull(a,'NULL') as a to convert the values.
    what's else can i do to make it? is there a way to prevent changing the NULL to blank ?
    or is there an easy solution to replace all the blank value to NULL in the excel ?

    help me ~

Maybe you are looking for