Select query for picking data in a dynamic internal table

Dear All,
Please help.
<u>The code is :</u>
p_table1 = itab_final-tabname1.
        p_field1 = itab_final-fieldname1.         
        SELECT (p_field1) FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <dyntable1>.      
It is working fine when the domain is of CHAR
The piece of code is not working where domain is DATS, CURR, DEC, etc.
What shall I do so that it works for other domains also. Please its urgent......
<u>ERROR that came:</u>
An exception occurred. This exception will be dealt with in more detail
below. The exception, assigned to the class 'CX_SY_OPEN_SQL_DB', was not
caught, which                                                         
led to a runtime error. The reason for this exception is:             
The data read during a SELECT access could not be inserted into the    
target field.                                                          
Either conversion is not supported for the target field's type or the  
target field is too short to accept the value or the data are not in a 
form that the target field can accept

Check below code
REPORT zpwtest .
*** Tables
DATA: lt_data TYPE REF TO data.
DATA: lt_fieldcatalog TYPE lvc_t_fcat.
data : p_field type string ,
       p_table type string .
*** Structure
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
*** Data References
DATA: new_line TYPE REF TO data.
*** Field Symbols
FIELD-SYMBOLS: <fs_data> TYPE REF TO data,
               <fs_1> TYPE ANY TABLE,
               <fs_2>,
               <fs_3>.
ls_fieldcatalog-fieldname = 'MANDT'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CONNID'.
ls_fieldcatalog-inttype = 'N'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'FLDATE'.
ls_fieldcatalog-inttype = 'D'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'PRICE'.
ls_fieldcatalog-inttype = 'P'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CURRENCY'.
ls_fieldcatalog-inttype = 'C'.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
     EXPORTING
       it_fieldcatalog = lt_fieldcatalog
     IMPORTING
       ep_table = <fs_data>
     EXCEPTIONS
       generate_subpool_dir_full = 1
       OTHERS = 2
IF sy-subrc <> 0.
ENDIF.
*** So <FS_1> now points to our dynamic internal table.
ASSIGN <fs_data>->* TO <fs_1>.
*** Next step is to create a work area for our dynamic internal table.
CREATE DATA new_line LIKE LINE OF <fs_1>.
*** A field-symbol to access that work area
ASSIGN new_line->*  TO <fs_2>.
<b>
p_field = 'mandt carrid connid fldate price currency' .
p_table = 'sflight' .
*** And to put the data in the internal table
SELECT (p_field)
  FROM (p_table)
  INTO CORRESPONDING FIELDS OF TABLE <fs_1>.
</b>
*** Access contents of internal table
LOOP AT <fs_1> ASSIGNING <fs_2>.
  ASSIGN COMPONENT 5 OF STRUCTURE <fs_2> TO <fs_3>.
  WRITE: / <fs_3>.
ENDLOOP.

Similar Messages

  • How to transfer data from a dynamic internal table

    Hi All
    I want to transfer data from a dynamic internal table<dyn_table>
    to a non dynamic internal table itab which should have the same structure as <dyn_table>.
    How can this be done?
    Regards,
    Harshit Rungta

    As stated earlier this can be done only through field symbols...
    You cannot create an non dynamic internal table with ANY structure...using DATA statement
    If the strucutre is defined well and good...you can create an non-dynamic internal table...
    If you do not know the structure then the internal table has to be dynamic...and to be generated using field symbols
    DATA: lv_ref TYPE REF TO data.
    FIELD-SYMBOLS: <fs_dyn_table> TYPE STANDARD TABLE.
    * You create a dynamic internal table...
    CREATE DATA lv_ref LIKE (your_dynamic_internal_table).
    ASSIGN lv_ref->* TO <fs_dyn_table>.
    Now...do the transfer.
    <fs_dyn_table> = "your_dynamic_internal_Table
    Hope it helps!

  • To populate data in a dynamic internal table

    Hi,
    I have an internal table <FS_1> which I have created dynamically. Now i need to populate the columns (7th column onwards) in the internal table with my data in GT_REQMT which is an internal table.
    Data: L_IDX type I.
    L_IDX = 6.
    Loop at <FS_1> assigning <FS_2>.
      If sy-tabix = 1.
        Loop at GT_REQMT.
         Add 1 to L_IDX.
    *****I need to populate GT_REQMT-DATA to column 7 then 8 etc depending on the number of loops.
         Modify <FS_1> from <FS_2>.
        Endloop.
      Else.
    **do other things here**
      Endif.
    Endloop.
    I have search through the forums and weblogs but the solutions are catered to populating the internal tables from SAP database using SQL statements.
    I couldn't find anything on populating own data in dynamic table by looping it. Please help. THANKS!!
    Cheers,
    Chelsea

    Hi!
    I have used classes for dynamic internal table, SO i here give you my sample code for your help.
    DATA : new_table TYPE REF TO data,
           new_line  TYPE REF TO data.
    FIELD-SYMBOLS : <TAB1> type standard table,
                    <l_table> TYPE ANY TABLE,
                    <l_line>  TYPE ANY,
                    <l_field> TYPE ANY.
        count = count + 1.
        clear wa_fieldcat.
        wa_fieldcat-col_pos   = count.
        wa_fieldcat-fieldname = 'CONDITION'.
        wa_fieldcat-coltext   = 'Condition Value'.
        wa_fieldcat-ref_field = 'KWERT'.
        wa_fieldcat-ref_table = 'KONV'.
        wa_fieldcat-outputlen = 13.
        append wa_fieldcat to it_fieldcat.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
         it_fieldcatalog = it_fieldcat
       IMPORTING
         ep_table        = new_table.
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    ASSIGN COMPONENT KWERT OF STRUCTURE <l_line> TO <l_field>.
    <l_field> = t_kschlkonv-vtext.
    NOw u append internal table
    IF its helps you then dont forget to rewards points.
    Regards From
    Priyank

  • Select query for char data type

    Hi Gurus,
         I am trying to fetch records from Z table.
    Below the select query.
    lv_low = '0900001' 
    lv_high = '0900002'
    select matnr sernr into table lt_sernr
    from   zsd_upd_deldoc
    where  sernr >= lv_low and sernr <= lv_high.
    but out put shows
    9000010
    9000011
    900002
    900001
    9000010
    9000019
    9000019
    9000018
    9000017
    9000014
    9000018
    9000017
    Expecting O/P
    900001
    900002
    Regards
    Vinayak Sapkal

    tables: zsd_upd_deldoc.
    data: begin of lt_table occurs 0,
    sign(1),
    option(2),
    low(18),
    high(18),
    end of lt_table.
    DATA: ls_doc_id_range LIKE LINE OF lt_table.
    FIELD-SYMBOLS: <fs> LIKE LINE OF lt_table.
      ls_doc_id_range-sign = 'I'.
      ls_doc_id_range-option = 'BT'.
      ls_doc_id_range-low = lv_low.
      ls_doc_id_range-high = lv_high.
      INSERT ls_doc_id_range INTO TABLE lt_table.
    select matnr sernr into table lt_sernr
    from   zsd_upd_deldoc
    where  sernr >= lv_low and sernr <= lv_high.
      select matnr sernr into table lt_sernr
      from   zsd_upd_deldoc
      where  sernr in lt_table.
      loop at lt_sernr assigning <fs_sernr>.
        write: / <fs_sernr>-sernr.
      endloop.
    O/P
    9000010
    9000011
    900002
    900001
    9000010
    9000019
    9000019
    9000018
    9000017
    9000014
    9000018
    9000017
    Regards
    Vinayak Sapkal

  • Logic for retreiving the values from a dynamic internal table

    Hi all,
    I have an issue with the logic to fetch data from a dynamic internal table into fields. let me give you guys an example the sy-tfill = 9 (subject to vary). I need to populate the fields.
    Regards,
    Sukumar

    Hi,
    this is for printing out the info in a dynamic table,
    it will work likewise to insert data.
    PARAMETERS:
      p_tabnam TYPE tabname DEFAULT 'DB_TABLE_NAME'.
    DATA:
      lv_dref TYPE REF TO data,
      ls_dd03l LIKE dd03l,
      lt_fieldname TYPE TABLE OF fieldname,
      ls_fieldname TYPE fieldname.
    FIELD-SYMBOLS:
      <fs> TYPE STANDARD TABLE,
      <wa_comp> TYPE fieldname,
      <wa_data> TYPE ANY,
      <wa_field> TYPE ANY.
    REFRESH lt_fieldname.
    SELECT * FROM dd03l INTO ls_dd03l
                       WHERE as4local = 'A'
                         AND as4vers  = '0000'
                         AND tabname  = p_tabnam
                       ORDER BY position.
      ls_fieldname = ls_dd03l-fieldname.
      APPEND ls_fieldname TO lt_fieldname.
    ENDSELECT.
    IF NOT ( lt_fieldname[] IS INITIAL ).
      CREATE DATA lv_dref TYPE TABLE OF (p_tabnam).
      ASSIGN lv_dref->* TO <fs>.
      SELECT * FROM (p_tabnam) INTO TABLE <fs>.
      WRITE:
        / 'CONTENTS OF TABLE', p_tabnam.
      LOOP AT <fs> ASSIGNING <wa_data>.
        SKIP.
        WRITE:
          / 'LINE', sy-tabix.
        ULINE.
        LOOP AT lt_fieldname ASSIGNING <wa_comp>.
          ASSIGN COMPONENT sy-tabix OF STRUCTURE <wa_data> TO <wa_field>.
          WRITE:
            / <wa_comp>, <wa_field>.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
    grtz
    Koen

  • At end of field,  for dynamic internal table entries ?

    Dear All,
    I've data in my dynamic internal table.
    But, to understand in a better way I created a test program with static entries.
    Case 1 -->
    DATA: BEGIN OF itab OCCURS 0,
            year TYPE char4,
            name TYPE char10,
          END OF itab.
    DATA: BEGIN OF itab2 OCCURS 0 ,
            year TYPE char4,
            name TYPE char10,
            count TYPE i,
          END OF itab2.
    DATA: gv_count TYPE i,
          gv_flag TYPE char1.
    itab-name = 'AAAA'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'AAAB'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'AAAC'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'AAAD'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBB'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBA'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBC'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBD'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCC'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCA'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCB'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCD'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCE'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCf'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDD'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDA'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDB'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDC'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDE'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    SORT itab BY year.
    LOOP AT itab.
    * Counter
      gv_count = gv_count + 1.
      AT END OF year.
        itab2-count = gv_count.
        MOVE-CORRESPONDING itab TO itab2.
        APPEND itab2.
        CLEAR gv_count.
        WRITE:/ itab2-name,
        itab2-year,
        itab2-count.
        CLEAR itab2.
        CLEAR gv_flag.
      ENDAT.
    ENDLOOP.
    Now for the above program the Output is :
    Name     Year          Count
    ********** 2005          5
    ********** 2006          6
    ********** 2007          4
    ********** 2008          4
    " Forget about the asterisk values as it's an example !
    The above output is correct, But in my real case the table structure is not like the above .
    The order of the field are in reverse.
    i.e. The internal table is like this :
    Case 2 -->
    DATA: BEGIN OF itab OCCURS 0,
            name TYPE char10,
            year TYPE char4,
          END OF itab.
    DATA: BEGIN OF itab2 OCCURS 0 ,
            name TYPE char10,
            year TYPE char4,
            count TYPE i,
          END OF itab2.
    In this case if I'm using at end of year the output is coming wrong.
    Even on change of is also not working.
    Request you guys to help me out so that I can achieve the same output as of case 1 with the table declaration as of CASE 2.
    Regards,
    Deepu.k

    Hello Rich Heilman,
    Again you came for my rescue ............
    My code for this scenario is like this :
    DATA: BEGIN OF itab OCCURS 0,
            name TYPE char10,
            year TYPE char4,
          END OF itab.
    DATA: BEGIN OF itab2 OCCURS 0 ,
            name TYPE char10,
            year TYPE char4,
            count TYPE i,
          END OF itab2.
    DATA: gv_count TYPE i,
          gv_flag TYPE char1.
    itab-name = 'AAAA'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'AAAB'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'AAAC'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'AAAD'.
    itab-year = '2008'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBB'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBA'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBC'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'BBBD'.
    itab-year = '2007'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCC'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCA'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCB'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCD'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCE'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'CCCf'.
    itab-year = '2006'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDD'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDA'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDB'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDC'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    itab-name = 'DDDE'.
    itab-year = '2005'.
    APPEND itab.
    CLEAR itab.
    SORT itab BY year.
    LOOP AT itab.
    * Counter
      gv_count = gv_count + 1.
      IF sy-tabix GT 1.
        ON CHANGE OF itab-year.
          itab2-count = gv_count.
          MOVE-CORRESPONDING itab TO itab2.
          APPEND itab2.
          CLEAR gv_count.
          WRITE:/ itab2-name,
          itab2-year,
          itab2-count.
          CLEAR itab2.
          CLEAR gv_flag.
        ENDON.
      ENDIF.
    ENDLOOP.
    The Output is :
    DDDC       2005          2
    CCCf       2006          4
    BBBD       2007          6
    AAAD       2008          4
    The above output is wrong.
    Can u correct me where I'm doing wrong ?
    Regards,
    Deepu.K

  • Dynamic Internal table data

    Hi All,
    I was created program to generate Dynamic field catalog and internal table, here is confusion how to display below mentioned internal table data to final dynamic internal table based on document type headings
    This is Statsic internal table Data
    1 0000123  GBP  DA  S  6265.45
    2 0000123  GBP  DA  H  240.51
    3 0000123  GBP  DA  S  35.82
    4 0000123  GBP  D1  H  281.85
    5 0000123  GBP  D1  S  23.41
    6 0000123  GBP  D1  S  34.23
    7 0000123  GBP  RV  H  97.02
    8 0000123  GBP  RV  S  52.90
    9 0000123  GBP  RV  S  148.31
    Can anybody suggest me how to populate the amount based on Document type and posting (credit or debit)
    For Example
    CUST DAC       DAD         D1C       D1D     RVC     RVD
    123                  6265.45   240.51
                            35.82
    Thanks in Advance
    Sekhar
    Moderator message: please do not open multiple threads for the same or similar issue.
    Edited by: Thomas Zloch on Dec 9, 2011 4:17 PM

    Hi All,
    I was created program to generate Dynamic field catalog and internal table, here is confusion how to display below mentioned internal table data to final dynamic internal table based on document type headings
    This is Statsic internal table Data
    1 0000123  GBP  DA  S  6265.45
    2 0000123  GBP  DA  H  240.51
    3 0000123  GBP  DA  S  35.82
    4 0000123  GBP  D1  H  281.85
    5 0000123  GBP  D1  S  23.41
    6 0000123  GBP  D1  S  34.23
    7 0000123  GBP  RV  H  97.02
    8 0000123  GBP  RV  S  52.90
    9 0000123  GBP  RV  S  148.31
    Can anybody suggest me how to populate the amount based on Document type and posting (credit or debit)
    For Example
    CUST DAC       DAD         D1C       D1D     RVC     RVD
    123                  6265.45   240.51
                            35.82
    Thanks in Advance
    Sekhar
    Moderator message: please do not open multiple threads for the same or similar issue.
    Edited by: Thomas Zloch on Dec 9, 2011 4:17 PM

  • How to Copy data from field symbol to Dynamic Internal Table

    Hi,
    I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
    REPORT  ztest.
    DATA:
           gd_dref          TYPE REF TO data,
           gd_dref1          TYPE REF TO data.
    FIELD-SYMBOLS:  <fs1>   TYPE any,
                               <fs_wa> TYPE any,
                                <field>    TYPE any,                  
                                <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
    *Copy data from p_src to p_dest*
    PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                             p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
    *DATA : lt_csks LIKE p_dest WITH HEADER LINE.
    START-OF-SELECTION.
      CREATE DATA gd_dref TYPE (p_src).
      CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
       ASSIGN gd_dref->* TO <fs_wa>.
       ASSIGN gd_dref1->* TO <fs_wa1>.
       SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
    *Write out data from FIELD SYMBOLS TO Table.
       loop at <fs_wa1> into <fs_wa>.
         do.
           assign component  sy-index
              of structure <fs_wa> to <field>.
           if sy-subrc <> 0.
           exit.
           endif.
           if sy-index = 1.
             write:/ <field>.
           else.
           write: / <field>.
           endif.
         enddo.
       endloop.
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    *p_dest is a table having a similar structure to table p_src .
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    EXIT.
    Thanks in Advance.

    try this...
    I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
    Cheers...
    report  ztest.
    data:
      gd_dref type ref to data,
      gd_dref1 type ref to data,
      gd_dref_str type ref to data,
      gd_dref_tab type ref to data.
    field-symbols:
      <fs1> type any,
      <fs_wa> type any,
      <fs1_dest_str> type any,
      <fs_dest_tab> type any table,
      <field> type any,
      <fs_wa1> type any table.
    * contains data from p_src
    *Copy data from p_src to p_dest*
    parameters: p_src like dd02l-tabname default 'vbak',
    * name of dynamic internal table *
                p_dest like dd02l-tabname default 'vbap'.
    * name of dynamic internal table*
    *data : lt_csks like p_dest with header line.
    start-of-selection.
      create data gd_dref type (p_src).
      create data gd_dref1 type table of (p_src).
      assign gd_dref->* to <fs_wa>.
      assign gd_dref1->* to <fs_wa1>.
      select * from (p_src) into corresponding fields of table <fs_wa1>
      up to 3 rows
      where vbeln ne space.
      create data gd_dref_str type (p_dest).
      create data gd_dref_tab type standard table of (p_dest).
      assign gd_dref_str->* to <fs1_dest_str>.
      assign gd_dref_tab->* to <fs_dest_tab>.
    *write out data from field symbols to table.
      loop at <fs_wa1> into <fs_wa>.
        " break-point here - can see vbeln/waers/create date/ etc move over to new structure
        " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
        " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
        break-point.
        move-corresponding <fs_wa> to <fs1_dest_str>.
        insert <fs1_dest_str> into table <fs_dest_tab>.
    **    do.
    **      assign component  sy-index
    **         of structure <fs_wa> to <field>.
    **      if sy-subrc <> 0.
    **        exit.
    **      endif.
    **      if sy-index = 1.
    **        write:/ <field>.
    **      else.
    **        write: / <field>.
    **      endif.
    **    enddo.
      endloop.
      " write out some dest data from the dest table build from previous loop
      loop at <fs_dest_tab> assigning <fs1_dest_str>.
        do.
          assign component sy-index of structure <fs_wa> to <field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <field>.
          else.
            write: / <field>.
          endif.
        enddo.
      endloop.

  • Need urgent help on dynamic internal table.

    Hi experts,
    I got an editable dynamic internal table. When the value in 1 of the editable field has been changed, I will fire the the DATA_CHANGED event. In this event, I can get the row ID where the changes occur, but the problem is, how can I select back the data from the dynamic internal table using the row ID since index is not permitted to be used? I need to get the rest of the records form the ROW and then perform a database update accordingly. How can I select from the dynamic internal table given the row ID? THanks in advance.

    Hi
    I suppose it depends on the kind of internal table assigned to fieldsymbol, this sample works fine:
    FIELD-SYMBOLS: <FS> TYPE TABLE,
                   <WA> TYPE ANY.
    DATA: BEGIN OF ITAB OCCURS 0,
            FIELD,
          END   OF ITAB.
    DO 10 TIMES.
      ITAB-FIELD = 'a'.
      APPEND ITAB.
    ENDDO.
    ASSIGN ITAB[] TO <FS>.
    READ TABLE <FS> ASSIGNING <WA> INDEX 1.
    WRITE <WA>.
    It can't use the index with internal table of kind HASHED.
    Max

  • Can any one send select query for this?

    Hi,
    can any one plese send select query for the following query.please send as early as possible.
    Loop through the I_BSID internal table to fill records in I_OUTPUT.Combine data from I_BSID, I_KNKK, I_KNKK_KNKLI, I_KNA1 and I_KNVV into I_OUTPUT based on the linking conditions .Field Description Source are
    I_OUTPUT-BUKRS     Company code     I_BSID-BUKRS
    I_OUTPUT-KUNNR     Customer number     I_BSID-KUNNR
    I_OUTPUT-NAME1     Customer Name     I_KNA1-NAME1
    I_OUTPUT-KNKLI     Credit account     I_KNKK-KNKLI
    I_OUTPUT-KDGRP     Customer Group     I_KNKK-KDGRP
    I_OUTPUT-KLIMK     Credit Limit     I_KNKK_KNKLI-KLIMK
    I_OUTPUT-KVGR1     Business Unit     I_KNVV-KVGR1
    I_OUTPUT-REBZG     Invoice Number     I_BSID-REBZG
    I_OUTPUT-BLDAT     Invoice Date     I_BSID-BLDAT
    I_OUTPUT-WAERS     Document Currency     I_BSID-WAERS
    I_OUTPUT-DUE_DATE     Due Date     Based on below
    Calculation
      Get the Payment terms days combining I_BSID and I_T052 based on the linking conditions mentioned above.    Note : a) Baseline Date : If baseline date I_BSID-ZFBDT is blank , use the Document Date.b) Payment Term Days :If I_BSID-ZBD3T is not blank, take this as Payment Term Days for Due date calculation.
                       If I_BSID-ZBD3T is Blank, then get payment term days from I_T052 based on I_BSID-ZTERM. If there are more than one record in I_T052 for the given Payment term, get the day part from baseline date and select the first record where the day limit I_T052-ZTAGG is greater than the day part.If I_BSID-ZBD3T is blank and I_BSID-ZTERM is also blank, then take Y000 (Due Immediately) as Payment term and proceed with the above logic. Set the payment term field blank while printing.
    Calculate Due date : For Debits, Determine Due Date = Baseline Date + Payment term Days(not discount days)                                                          For  Credits  Due date = Baseline date.Then, move the amount I_BSID-DMBTR to respective buckets (Not yet Due, Current Due, Past due 1-30, Past Due 31-60 etc.)  Based on the due date.
    Thanks&Regards,
    praveen kumar.A

    HI,
    To get Open Items you can use Function module:
    data:i_items TYPE STANDARD TABLE OF rfpos.
    CALL FUNCTION 'CUSTOMER_OPEN_ITEMS'
    EXPORTING
    bukrs = p_bukrs
    kunnr = wa_customer-kunnr
    TABLES
    t_postab = i_items
    EXCEPTIONS
    no_open_items = 1
    OTHERS = 2.
    Table I_items will have all the open items for that Customer in the given company code.
    Well for Clear Items: Try
    GET_CLEARED_ITEMS or FMITPOFM_CLEARED_ITEMS_GET.
    Hope it helps.
    Manish

  • Select query for fetching from 3 tables.

    Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
    from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
    Regards,
    Shashank.

    Hi,
    If you have kunnr field in all the 3 tables then it is possible. use inner join as below
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    SELECT c~carrname p~connid f~fldate
           INTO CORRESPONDING FIELDS OF TABLE itab
           FROM ( ( scarr AS c
             INNER JOIN spfli AS p ON p~carrid   = c~carrid
                                  AND p~cityfrom = p_cityfr
                                  AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON f~carrid = p~carrid
                                    AND f~connid = p~connid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    <b>Reward Points if this helps,</b>
    Satish

  • Select Query Between two dates...

    Hi Guru's,
    I need a Select Query between two dates, also if the record not found for any in between date then it should return NULL or 0 ...
    for Example
    1. I am having two records in DB for date 2-10-2008 & 4-10-2008
    2. Now suppose I have given Query for date between 1-10-2008 to 5-10-2008
    Then it should return me 5 records with valid values for 2 & 4 and NULL for other 1,3,5
    Thanks.

    Try like this:
    with
      t as
          select date '2008-10-02' as dt, 'Record #1 (in DB)' as str from dual union all
          select date '2008-10-04' as dt, 'Record #2 (in DB)' as str from dual
    select v.dt, t.str
      from (
             select date '2008-10-01' + level - 1 as dt
               from dual
             connect by level <= (date '2008-10-05' - date '2008-10-01') + 1
           ) v
      left join t
        on v.dt = t.dt
    order by 1

  • Usage of 'Select for all entries' for dynamic internal tables..

    Hi all,
    I have a situation where I need to use select for all entries for a dynamic internal table.
    select * from /BIC/AZHSD_O1500 into i_table for all entries in <b>Dynamic_table</b> where doc_number = <dynamic_table????????>
    here iam not knowing how to match the <dynamic_table????????> doc_number ?
    the dynamic_table contains the doc_number as one field.
    here dynaimc_table is the internal table which is dynamic.
    I have tried various options but couldnot find the solution.
    Please resolve.
    Sidhartha.

    data : i_dyn_where type char72 occurs 0.
    field-symbols : <fs> type table.
    assign itab[] to <fs>.
    i_dyn_where = 'docno = <fs>-docno'.
    append i_dyn_where.
    select *
    from   vbak
    into   table t_vbak
    for    all entries in <fs>
    where  (I_dyn_where).   "Populate this where condition dynamically too
    Hope this will solve ur prob.

  • Select Query for smart form-invoice

    Hi Folks,
    I have to fetch the following fields as per the requirement for desiging a invoice smartform.I had copied lb_bill_invoice smartform into z format.
    Can anyone here please give me the select query for the same.
    fields to fetched are as follows:-
    1.vbrp-arktx,
    2.vbrp-fkimg,
    3.konv-kbetr with respect to vbrk-knumv
    4.konv-kwert.
    And also what all I have to give in format interface and global definitions of the smartform.
    please help  me in this regard.
    Points will be given.
    K.Kiran.

    Hi,
    declare the variables V_arktx(40) and v_Qty like vbrp-fkimp  and other varaibles for Kbetr, kwert, knumv on the global definitions.
    select  single arktx fkimg into (v_arktx, v_qty) from vbrp
    where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
    select single knumv into v_knumv from vbrk where where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
    this select has to fire in the item level and in the loop.
    so have to write in the correct place.
    select kbetr kwert into (v_kbetr, v_kwert) from konv
    where where knumv = v_knumv and kposn = LBBIL_IT_REFPURORD-ITM_NUMBER.
    regards,
    anji

  • How to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

Maybe you are looking for

  • Can I put a MacBook processor and hard drive in a PowerMacG5?

    I have a late 2008 MacBook that is showing its age and wear. The battery is worn out and the keys and mouse sometimes stick. I also have a PowerMac G5 which has an older operating system, but great working keyboard, mouse, and monitor. Can I put the

  • Sales order - Procurement Confirmation Wizard

    Hi everyone, I've a problem with a sales order and would like help of you. When create/update a sales order appears authorization [Procurement Confirmation Wizard]. I checked some parameters Logistics tab and Item Master Data, but i don't found any e

  • Urxvt - transparency - vim ? - SOLVED-

    I'm runnung urxvt with real transparency by putting this in my .Xdefaults: URxvt*depth: 32 URxvt*background: rgba:2121/2121/2121/aaaa vim gives me error codes when I try to run it in a transparent terminal: BadMatch (invalid parameter attributes) Vim

  • WRT54G v.2 connection problem

    I have 2 desktops wired to the router and 1 laptop wireless connected. Everything worked fine for years. After a bad storm knocked out our power my router wouldn't connect to the internet with both desktops connected. It works with one or the other b

  • Comcast mail on mavericks locked out

    Why comcast mail on mavericks locked out