Internal table to define condition range

Hi
  Can someone tell me what is the internal table where condition(BEx Analizer) variable range is defined
Thanks
Sheetal

Hi,
Try out this link.....
Dynamic Where Clause
or u can try with the following......
sample code:
append 'loop at tab2 into wa2 ' to prog.
  loop at formel."customize-table
    concatenate 'wa1-' formel-feld1 into dbfeld.
    if sy-tabix = 1.
      concatenate 'where' formel-feld1 formel-operator dbfeld
       into prog-line separated by space.
    else.
      concatenate 'and' formel-feld1 formel-operator dbfeld
       into prog-line separated by space.
    endif.
    append prog.
data:  lr_bukrs type range of bseg-bukrs,  lr_gjahr type range of bseg-gjahr,  lr_belnr type range of bseg-belnr.*** filll range(s) dynamically **** ...* ...loop at itab where bukrs in lr_bukrs               and gjahr in lr_gjahr               and belnr in lr_belnr.* do somethingendloop.
Because a where-condition on an empty range is always true, empty ranges will be ignored
and only the ranges with values will be used for comparison.
To fill a range, you may use
PERFORM append_range       USING 'IEQ' '2006' ''       CHANGING lr_gjahr.
using this universal reusable lightning-fast form
&----&      Form  append_range&--**       append selection range*--
FORM append_range  USING    p_signopt     TYPE c                            p_low         TYPE any                            p_high        TYPE any                   CHANGING pt_range      TYPE table.  FIELD-SYMBOLS:    <range>                               TYPE ANY,    <sign>                                TYPE ANY,    <option>                              TYPE ANY,    <low>                                 TYPE ANY,    <high>                                TYPE ANY.  DATA:    l_ref                                 TYPE REF TO data.  CREATE DATA l_ref                       LIKE LINE OF pt_range.  ASSIGN l_ref-> TO <range>.  CHECK sy-subrc                          = 0.  ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>.  CHECK sy-subrc                          = 0.  ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>.  CHECK sy-subrc                          = 0.  ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>.  CHECK sy-subrc                          = 0.  ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>.  CHECK sy-subrc                          = 0.  <sign>                                  = p_signopt(1).  <option>                                = p_signopt+1(2).  <low>                                   = p_low.  <high>                                  = p_high.  READ TABLE pt_range WITH KEY table_line = <range>    TRANSPORTING NO FIELDS BINARY SEARCH.  CHECK sy-subrc                          <> 0.  INSERT <range> INTO pt_range INDEX sy-tabix..ENDFORM.                    " append_range
Warm Regards
Suma Humberi

Similar Messages

  • To count number of records in an internal table for a condition

    Hello All,
            I want to count number of records in an internal table for a condition.
    For e.g. -- I have one internal table IT which having fields F1, F2, F3, F4, F5.
                     Now, I want number of records in itnternal table IT where F1 = 'ABC'.
    Is it possible to do..?? If yes, then how.??
    Thanks in advance...!!
    Regards,
    Poonam.

    Hi,
    If you mean an internal table, there are a few ways to do this.
    1 One would be to loop over the table with a WHERE clause and increment a counter.
    data: lv_counter type i.
    clear lv_counter.
    loop at itab where fld1 = 'ABC'.
    lv_counter = lv_counter + 1.
    endloop.
    lv_counter now has the number of rows per the condiction.
    2  Well, you may want to try this as well, and compare to the LOOP way. Not sure what kind of overhead you may get doing this way. Here ITAB is our main internal table, and ITAB_TMP is a copy of it. Again I think there may be some overhead in doing the copy. Next, delete out all records which are the reverse of your condition. Then whatever is left is the rows that you want to count. Then simply do a LINES operator on the internal table, passing the number of lines to LV_COUNT.
    data: itab type table of ttab.
    data: itab_tmp type table of ttab.
    itab_tmp[] = itab[].
    delete table itab_tmp where fld1  'ABC'.
    lv_count = lines( itab_tmp ).
    Thanks & Regards,
    ShreeMohan

  • How to append  row in internal table for perticular condition

    Hi,
    I have 4 records in my internal table and i want to append row
    after second row when condition will match.
    please guide me.
    thanks in advancs
    regards
    SND

    hi,
    using key word INDEX u can insert a record in aspecified position as
    if internal table is with header line.
    INSERT <internaltable> index SY_INDEX [or index no if u  know where to insert]
    with out header line.
    INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u  know where to insert]
    if condition is true.
    insert itab index 2.
    endif.
    if helpful reward some points.
    with regards,
    Suresh.A

  • Calcullating no. of records in an internal table based on condition

    Hi,
    i have several records in an internal table. i need to calculate the number of records which meets a condition. is there any simple logic to find the records which meet the required criteria apart from looping into the internal table.
    your help would be appreciated.
    Thanks,
    kranthi.

    Hi,
    U can use sy-dbcnt after the select querry.
    DBCNT  Number of elements in edited dataset with DB operations
    WRITE: /12 'Number of selected records:', SY-DBCNT CENTERED.
    REPORT ZZZ_TEST1 .
    Tables: mara.
    Types: begin of ty_mara,
           matnr like mara-matnr,
          end of ty_mara.
    DATA: i_mara TYPE STANDARD TABLE OF ty_mara.
    DATA: v_cnt like sy-dbcnt.
    SELECT-OPTIONS: s_matnr FOR MARA-matnr.
    SELECT matnr from mara into table i_mara.
    if sy-subrc = 0.
    v_cnt = sy-dbcnt.
    WRITE: /12 'Number of selected records:', v_cnt CENTERED.
    endif.
    Hope this helps u.
    Thanks & Regards,
    Judith.

  • Internal table in where condition

    Hello friends,
    I have an internal table LT_PO populated with data.
    I have written the below piece of code and i am getting an error message "The IN operator with LT_PO is neither followed by an internal table nor by a value list.
    SELECT ekbe~arewr ekbe~bamng ekbe~belnr ekbe~bewtp ekbe~budat ekbe~buzei
           ekbe~bwart ekbe~dmbtr ekbe~ebeln ekbe~ebelp ekbe~elikz ekbe~ernam
           ekbe~gjahr ekbe~matnr ekbe~menge ekbe~vgabe ekbe~waers ekbe~werks
           ekbe~wrbtr ekko~aedat ekko~bedat ekko~bsart ekko~bstyp ekko~bukrs
           ekko~ebeln ekko~ekgrp ekko~ekorg ekko~ernam ekko~lifnr ekko~loekz
           ekko~waers ekko~zterm ekpo~brtwr ekpo~ebeln ekpo~ebelp ekpo~inco1
           ekpo~inco2 ekpo~infnr ekpo~insmk ekpo~knttp ekpo~ktmng ekpo~lmein
           ekpo~matkl ekpo~matnr ekpo~meins ekpo~netpr ekpo~plifz ekpo~werks
    INTO (ekbe-arewr , ekbe-bamng , ekbe-belnr , ekbe-bewtp , ekbe-budat ,
          ekbe-buzei , ekbe-bwart , ekbe-dmbtr , ekbe-ebeln , ekbe-ebelp ,
          ekbe-elikz , ekbe-ernam , ekbe-gjahr , ekbe-matnr , ekbe-menge ,
          ekbe-vgabe , ekbe-waers , ekbe-werks , ekbe-wrbtr , ekko-aedat ,
          ekko-bedat , ekko-bsart , ekko-bstyp , ekko-bukrs , ekko-ebeln ,
          ekko-ekgrp , ekko-ekorg , ekko-ernam , ekko-lifnr , ekko-loekz ,
          ekko-waers , ekko-zterm , ekpo-brtwr , ekpo-ebeln , ekpo-ebelp ,
          ekpo-inco1 , ekpo-inco2 , ekpo-infnr , ekpo-insmk , ekpo-knttp ,
          ekpo-ktmng , ekpo-lmein , ekpo-matkl , ekpo-matnr , ekpo-meins ,
          ekpo-netpr , ekpo-plifz , ekpo-werks )
    FROM ( ekbe
           INNER JOIN ekko
           ON ekko~ebeln = ekbe~ebeln
           INNER JOIN ekpo
           ON ekpo~ebeln = ekbe~ebeln
           AND ekpo~ebelp = ekbe~ebelp )
           WHERE ekbe~bewtp IN s_bewtp
             AND ekbe~budat IN s_budat
             AND ekbe~bwart IN s_bwart
             AND ekbe~ebeln IN s_ebeln
             AND ekbe~ebelp IN s_ebelp
             AND ekbe~gjahr IN s_gjahr
             AND ekbe~matnr IN s_matnr
             AND ekbe~vgabe IN s_vgabe
             AND ekbe~werks IN s_werks
             AND ekko~lifnr IN s_lifnr
             AND ekpo~knttp IN s_knttp
             AND ekko~ekorg IN r_ekorg
             AND ekbe~vgabe IN r_vgabe
             AND  ekko~ebeln IN lt_po
             AND ( ekbe~cpudt GT lv_zdate OR
                   ekbe~cpudt EQ lv_zdate AND
                   ekbe~cputm GT lv_ztime ).
    Thanks for your help.
    Salil

    Are you trying to use FOR ALL ENTRIES, if so this will be better.
    <b>check not lt_po[] is initial.
    sort lt_po by ebeln.</b>
    SELECT ekbearewr ekbebamng ekbebelnr ekbebewtp ekbebudat ekbebuzei
           ekbebwart ekbedmbtr ekbeebeln ekbeebelp ekbeelikz ekbeernam
           ekbegjahr ekbematnr ekbemenge ekbevgabe ekbewaers ekbewerks
           ekbewrbtr ekkoaedat ekkobedat ekkobsart ekkobstyp ekkobukrs
           ekkoebeln ekkoekgrp ekkoekorg ekkoernam ekkolifnr ekkoloekz
           ekkowaers ekkozterm ekpobrtwr ekpoebeln ekpoebelp ekpoinco1
           ekpoinco2 ekpoinfnr ekpoinsmk ekpoknttp ekpoktmng ekpolmein
           ekpomatkl ekpomatnr ekpomeins ekponetpr ekpoplifz ekpowerks
    INTO (ekbe-arewr , ekbe-bamng , ekbe-belnr , ekbe-bewtp , ekbe-budat ,
          ekbe-buzei , ekbe-bwart , ekbe-dmbtr , ekbe-ebeln , ekbe-ebelp ,
          ekbe-elikz , ekbe-ernam , ekbe-gjahr , ekbe-matnr , ekbe-menge ,
          ekbe-vgabe , ekbe-waers , ekbe-werks , ekbe-wrbtr , ekko-aedat ,
          ekko-bedat , ekko-bsart , ekko-bstyp , ekko-bukrs , ekko-ebeln ,
          ekko-ekgrp , ekko-ekorg , ekko-ernam , ekko-lifnr , ekko-loekz ,
          ekko-waers , ekko-zterm , ekpo-brtwr , ekpo-ebeln , ekpo-ebelp ,
          ekpo-inco1 , ekpo-inco2 , ekpo-infnr , ekpo-insmk , ekpo-knttp ,
          ekpo-ktmng , ekpo-lmein , ekpo-matkl , ekpo-matnr , ekpo-meins ,
          ekpo-netpr , ekpo-plifz , ekpo-werks )
    FROM ( ekbe
           INNER JOIN ekko
           ON ekkoebeln = ekbeebeln
           INNER JOIN ekpo
           ON ekpoebeln = ekbeebeln
           AND ekpoebelp = ekbeebelp )
    <b>       FOR ALL ENTRIES IN LT_PO
           WHERE     ekko~ebeln = lt_po-EBELN</b>
             and  ekbe~bewtp IN s_bewtp
             AND ekbe~budat IN s_budat
             AND ekbe~bwart IN s_bwart
             AND ekbe~ebeln IN s_ebeln
             AND ekbe~ebelp IN s_ebelp
             AND ekbe~gjahr IN s_gjahr
             AND ekbe~matnr IN s_matnr
             AND ekbe~vgabe IN s_vgabe
             AND ekbe~werks IN s_werks
             AND ekko~lifnr IN s_lifnr
             AND ekpo~knttp IN s_knttp
             AND ekko~ekorg IN r_ekorg
             AND ekbe~vgabe IN r_vgabe
    <b>         AND ( ekbe~cpudt GT lv_zdate OR
                   ( ekbe~cpudt EQ lv_zdate AND
                   ekbe~cputm GT lv_ztime ) ).</b>
    Regards,
    RIch Heilman

  • Internal table - select if in range ?

    Hello ABAP Experts,
    I have a internal i_gl_account table which has some of the following fields:
    glacctfrom, glacctto, flag
    i have to select a record from this internal table based on a fixed gl_account_fix.
    i cannot write this statement
    read table i_gl_account with key
               glacctfrom >= gl_account_fix
               glacctto <= gl_account_fix
    since read does not allow the '>' or '<' operators.
    one alternative possible is:
    loop i_gl_account.
      if ( glacctfrom >= gl_account_fix and
           glacctto <= gl_account_fix).
      exit.
      endif.
    endloop.
    This solutions, lookups at each and every record one by one and then does the if comparisions. Incase the i_gl_account is large then this is huge cost and processing.
    wondering if there is any other possible method of achieving the same with lesser processing and cost.
    Any suggetions are appreciated.
    Thanks,
    BWer

    You could also something simular to this sample program.  If know that the start point is in the table.  Here the program is reading the first line where the start value is =,  then it is reading each line after that untill it reaches the end point.  But it is not reading the entire internal table.
    report  zrich_0001.
    data: begin of itab occurs 0,
          field1(10) type c,
           field2(10) type c,
           field3(10) type c,
          end of itab.
    itab-field1 = 'A'.
    itab-field2 = '1'.
    itab-field3 = '001'.
    append itab.
    itab-field1 = 'A'.
    itab-field2 = '2'.
    itab-field3 = '123'.
    append itab.
    itab-field1 = 'A'.
    itab-field2 = '3'.
    itab-field3 = '124'.
    append itab.
    itab-field1 = 'A'.
    itab-field2 = '4'.
    itab-field3 = '125'.
    append itab.
    itab-field1 = 'A'.
    itab-field2 = '5'.
    itab-field3 = '999'.
    append itab.
    sort itab ascending by field1 field2 field3.
    data: index type sy-index.
    data: start like itab-field3 value '123'.
    data: end like itab-field3 value '125'.
    read table itab with key field3 = start.
    if sy-subrc  = 0.
      write:/ itab-field1, itab-field2, itab-field3.
      index = sy-tabix + 1.
      while sy-subrc = 0.
        read table itab index index.
        if sy-subrc = 0
            and itab-field3 <= end.
          write:/ itab-field1, itab-field2, itab-field3.
        else.
          sy-subrc  = 4.
        endif.
        index = index + 1.
      endwhile.
    endif.
    Regards,
    Rich Heilman

  • How to select data from an internal table

    material                          norm                    date last modified
    B2-SP HEAT                 50.000               20090420
    BF COKE                                 575.000               20090419
    GROSS COKE                 200.000               20090419
    B2-SP HEAT                 100.000               20090419
    TWT                                 33.000               20090330
    B7-SP HEAT                 2.000               20090310
    B1-SP HEAT                 1.000               20090309
    B7-SP HEAT                 615.000               20090308
    B2-SP HEAT                 585.000               20090308
    B1-SP HEAT                 100.000               20090308
    B3-SP HEAT                 610.000               20090308
    BF COKE                                 68.500               20090308
    GROSS COKE                 72.600               20090308
    B8-SP HEAT                 600.000               20090308
    B9-SP HEAT                 625.000               20090308
    BX-SP HEAT                 615.000               20090308
    B9-SP HEAT                 58.000               20090307
    B1-SP HEAT                 100.000               20090307
    B6-SP HEAT                 350.000               20090306
    B2-SP HEAT                 888.000               20090306
    Like above there r numerous data in a table :
    how will i select data into another internal table where material above is not repeated with latest modified date.please help.

    Hi Sonu,
    The main task is to move the contents of the one internal table to another with some condition.
    First sort and delete the duplicate entries from the First Internal table like below : 
    sort it_tab by material ascending date_modified descending.
    delete adjacent duplicates from it_tab.
    Then move that Internal table contents to another internal table.
    Define another internal table with the same structure as you have first internal table and then
    Second Step :
    it_itab1 = it_itab.
    If you are using seperate Header line and Body then you can do like below :
           it_itab1[] = it_itab[].
    This will fix the issue.
    Please let me know if you need any further explonation.
    Regards,
    Kittu
    Edited by: Kittu on Apr 24, 2009 12:21 PM

  • Inner join on internal table

    HI all,
    How to access data from two internal table using join condition ?
    suppose i have tow internal table itab and jtab and i want to access data by using inner join on this tow table.
    please tell .
    thanx..

    hi,
    You can use PROVIDE ENDPROVIDE statements in ABAP to achive this.
    Check the below documenttaion.
    PROVIDE
    Syntax
    PROVIDE FIELDS {*|{comp1 comp2 ...}}
                   FROM itab1 INTO wa1 VALID flag1
                   BOUNDS intliml1 AND intlimu1
                   [WHERE log_exp1]
            FIELDS {*|{comp1 comp2 ...}}
                   FROM itab2 INTO wa2 VALID flag2
                   BOUNDS intliml2 AND intlimu2
                   [WHERE log_exp2]
            BETWEEN extliml AND extlimu
            [INCLUDING GAPS].
    ENDPROVIDE.
    Effect
    The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables itab1 itab2 ... are processed together. A single table can appear several times. For every table itab you must specify a FIELDS clause. After FIELDS you must specify the character * for all components or a list comp1 comp2 ... for specific components of the relevant table. The names of the components comp1 comp2 ... can only be specified directly.
    To be able to process internal tables using PROVIDE, all tables itab1 itab2 ... must be fully typed index tables and contain two special columns that have the same data type (d, i, n, or t) for all relevant tables. For every table you must specify the names intliml1 intliml2 ... and intlimu1 intlimu2 ... of these columns using the addition BOUNDS.
    The columns intliml1 intliml2 ... and intlimu1 intlimu2 ... in every row of the relevant internal tables must contain values that can be interpreted as limits of closed intervals. Within a table, the intervals specified in these columns must not overlap and must be sorted in ascending order. The intervals therefore make up a unique key for every row.
    For every table you must specify a work area wa1 wa2 ... compatible with the row type and a variable flag1 flag2 ..., for which a character-type data type with length 1 is expected. In the PROVIDE loop, the components specified after FIELDS are filled with values in the relevant work areas wa1 wa2 ... for every specified internal table. The variables flag1 flag2 ... are also filled. A work area wa1 wa2 ... or a variable flag1 flag2 ... cannot be specified more than once.
    With the BETWEEN addition you must specify an interval extliml, extlimu. It must be possible to convert the data objects extliml and extlimu into the data types of the respective columns intliml1 intliml2 ... and intlimu1 intlimu2 ... of the individual tables.
    The interval limits intliml1 intliml2 ... and intlimu1 intlim2 for every row of all relevant internal tables itab1 itab2 ... that are within the closed interval made up by extliml and extlimu divide the latter into new intervals and every interval limit closes one interval in the original direction. If, within a relevant table, a lower interval limit follows an upper interval limit with no space or gap between them and the components of the corresponding rows specified after FIELDS have the same content, the two intervals are combined and the corresponding interval limits intliml1 intliml2 ... and intlimu1 intlimu2 ... are ignored for the new intervals.
    For every interval that is created in such a way and overlaps with at least one of the intervals of a table involved, the PROVIDE loop is passed once. The components of every work area wa1 wa2 ... specified after FIELDS and the variables flag1 flag2 ... are filled with values as follows:
    The components intliml1 intliml2 ... and intlimu1 intlimu2 ... of every work area wa1 wa2 ... are filled with the interval limits of the current interval.
    If the current interval overlaps with one of the intervals of an involved table, the remaining components of the corresponding work area are assigned the contents of the relevant components of this table row and the variable flag1 flag2 ... is set to the value "X". Otherwise, the work area components and the variables flag1 flag2 ... are set to their Initial value.
    Except for intliml1 intliml2 ... and intlimu1 intlimu2 ..., the components not specified after FIELDS are always set to their initial value. The components intliml1 intliml2 ... and intlimu1 intlimu2 ... are always assigned.
    The ABAP runtime environment checks for every table involved, whether the condition of sorted and non-overlapping intervals is met within the interval made up by extliml and extlimu and, if necessary, triggers an exception that can be handled.
    If the INCLUDING GAPS addition is specified, the system passes the PROVIDE loop for every interval, that is also when the current interval does not overlap with at least one of the intervals of an involved table. In the latter case, the variable flag is of initial value for every relevant table.
    You can use the WHERE addition to specify a condition for every table itab1 itab2 ... involved. After WHERE, you can specify any logical expression log_exp1 log_exp2 ... ; the first operand of every comparison must be a component of the internal table. As such, all logical expressions except for IS ASSIGNED, IS REQUESTED, and IS SUPPLIED are possible. You can only specify components that are in the list after FIELDS. Here it is not possible to specify a component using character-type data objects in brackets. The table entries for which the condition is not met are ignored by the PROVIDE loop. You can leave the PROVIDE loop following the instructions in the section Leaving loops.
    System fields
    The system fields sy-subrc and sy-tabix are set to the value 0 before every loop pass and at ENDPROVIDE. Only if the loop is not passed once, is sy-subrc set to 4 at ENDPROVIDE.
    Notes
    The relevant internal tables should not be modified in the PROVIDE loop.
    The WHERE condition can be used to remove overlaps between the tables involved or to ensure the sorting of the intervals.
    In two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
    |01|02|03|04|05|06|07|08|09|10|11|12|13|14|
    |   Itab1 Int1    |     |Itab1 Int2 |     |
    |        |      Itab2 Int1       |        |
    |  |          ... BETWEEN ...             |
    |  | i1  |   i2   | i3  |   i4   |i5|     |
    The interval specified in the BETWEEN addition to the PROVIDE statement is shown in the fourth row. It serves as a basis for the five intervals in the fifth row represented by i1 to i5. These can be processed in the PROVIDE loop.
    Because each of the five intervals overlaps with one of the intervals from rows two and three, the PROVIDE loop is passed five times.
    Only the component col3 of wa1 is filled in the first pass, only the component col3 of wa2 in the third pass, and the components col3 of both work areas in the second and fourth passes. The fields valid1 and valid2 are set accordingly.
    DATA: BEGIN OF wa1,
            col1 TYPE i,
            col2 TYPE i,
            col3 TYPE string,
          END OF wa1.
    DATA: BEGIN OF wa2,
            col1 TYPE i,
            col2 TYPE i,
            col3 TYPE string,
          END OF wa2.
    DATA: itab1 LIKE STANDARD TABLE OF wa1,
          itab2 LIKE STANDARD TABLE OF wa2.
    DATA: flag1(1) TYPE c,
          flag2(1) TYPE c.
    wa1-col1 = 1.
    wa1-col2 = 6.
    wa1-col3 = 'Itab1 Int1'.
    APPEND wa1 TO itab1.
    wa1-col1 = 9.
    wa1-col2 = 12.
    wa1-col3 = 'Itab1 Int2'.
    APPEND wa1 TO itab1.
    wa2-col1 = 4.
    wa2-col2 = 11.
    wa2-col3 = 'Itab2 Int1'.
    PROVIDE FIELDS col3 FROM itab1 INTO wa1
                                   VALID flag1
                                   BOUNDS col1 AND col2
            FIELDS col3 FROM itab2 INTO wa2
                                   VALID flag2
                                   BOUNDS col1 AND col2
            BETWEEN 2 AND 14.
      WRITE: / wa1-col1, wa1-col2, wa1-col3, flag1.
      WRITE: / wa2-col1, wa2-col2, wa2-col3, flag2.
      SKIP.
    ENDPROVIDE.
    The list output is as follows:
       2           3  Itab1 Int1 X
       2           3
       4           6  Itab1 Int1 X
       4           6  Itab2 Int1 X
       7           8
       7           8  Itab2 Int1 X
       9          11  Itab1 Int2 X
       9          11  Itab2 Int1 X
      12          12  Itab1 Int2 X
      12          12
    Exceptions
    Catchable Exceptions
    CX_SY_PROVIDE_INTERVAL_OVERLAP
    Cause: In one of the involved tables there are overlapping intervals within extlim1 and extlim2.
    Runtime Error: UNCAUGHT_EXCEPTION
    CX_SY_PROVIDE_TABLE_NOT_SORTED
    Cause: One of the involved tables is not sorted in ascending order by the intervals within extlim1 and extlim2.
    Runtime Error: UNCAUGHT_EXCEPTION
    Edited by: Velangini Showry Maria Kumar Bandanadham on Apr 28, 2008 1:36 PM

  • Structure & Internal Tables

    What is the difference between Structure & Internal Tables,
    Regards.

    Hi chidambar,
    to say simply the internal table can have data within it but a structure is that which can be used by an internal table to define its columns ,it cannot have data on its own
    coming to thoery this may help you,but dont confuse more with the theory
    Structures
    A structure is a sequence of any elementary types, reference types, or complex data types.
    You use structures in ABAP programs to group work areas that logically belong together. Since the elements of a structure can have any data type, structures can have a large range of uses. For example, you can use a structure with elementary data types to display lines from a database table within a program. You can also use structures containing aggregated elements to include all of the attributes of a screen or control in a single data object.
    The following terms are important when we talk about structures:
    Nested and non-nested structures
    Flat and deep structures
    A nested structure is a structure that contains one or more other structures as components. Flat structures contain only elementary data types with a fixed length (no internal tables, reference types, or strings). The term deep structure can apply regardless of whether the structure is nested or not. Nested structures are flat so long as none of the above types is contained in any nesting level.
    Any structure that contains at least one internal table, reference type, or string as a component (regardless of nesting) is a deep structure. Accordingly, internal tables, references, and strings are also known as deep data types. The technical difference between deep structures and all others is as follows. When you create a deep structure, the system creates a pointer in memory that points to the real field contents or other administrative information. When you create a flat data type, the actual field contents are stored with the type in memory. Since the field contents are not stored with the field descriptions in the case of deep structures, assignments, offset and length specifications and other operations are handled differently from flat structures.
    Internal Tables
    Internal tables consists of a series of lines that all have the same data type. Internal tables are characterized by:
    The line type, which can be any elementary type, reference type, or complex data type.
    The key identifies table rows. It is made up of the elementary fields in the line. The key can be unique or non-unique.
    The access method determines how ABAP will access individual table entries. There are three access types, namely unsorted tables, sorted index tables and hash tables. For index tables, the system maintains a linear index, so you can access the table either by specifying the index or the key.
    Hashed tables have no linear index. You can only access hashed tables by specifying the key. The system has its own hash algorithm for managing the table.
    You should use internal tables whenever you need to use structured data within a program. One imprint use is to store data from the database within a program.
    plz reward if helpful,
    plz get back to me for further queries.
    thanks and regards,
    srikanth tulasi.

  • BRFplus: Problem updating values in an internal table in a loop expression

    Hi
    I'm looking into the loop expression type of BRFplus and I have come across a problem updating an internal table, I'm trying to create and populate the table using a loop, here is the functionality I'm trying to achieve:
    In a rule set create an internal MONTH_TBL table containing 12 rows of two columns: MONTH_NUM containing values 1 through 12 and MONTH_VAL containing an amount (initially 0,00 EUR in all 12 rows).
    After initializing the table traverse through SFLIGHT table and for each row add PRICE from the table to MONTH_VAL in the row of MONTH_TBL corresponding to the month of FLDATE field in SFLIGHT.
    The initialization of MONTH_TBL works as intended, as does the traversal of and retrieval of values from SFLIGHT. The problem however is the update of the internal table MONTH_TBL (defined as result data object for the function). I don't get an error, but the tables does not get updated, and I cannot seem to find out what the problem is. I would have attached an XML extract of the function + ruleset for information, but it dosen't seem like that is possible, I could e-mail it on request (for SAP employees with access to system QU5 the function is LOOP_TEST in application Z_KLAUS_TEST).
    I hope that this is sufficient information to understand the issue that I'm dealing with.
    best regards
    Klaus Stenbæk, KMD

    Hi Klaus,
    The Loop expression is part of NW 7.02 which is not yet released. When you experience the problem as part of a test you should have a contact at SAP for dealing with problems/errors. Usually SAP-internal messages are used for this purpose. Please clarify with your SAP contact how the model is.
    BR,
    Carsten

  • Maximum record length in internal table?

    Is there a maximum record length in an internal table?  Please note:  My question is NOT related to table space.  I'm referring only to the length of an individual record (A.K.A. row length).
    I am using a work area to insert data into an internal table.  Both the work area and internal table are defined by the same structure.
    The structure has a total length of 672 bytes.  For the sake of this discussion I'll point out that at the end of the structure, bytes 669, 670, 671, and 672 are four separate fields of 1 character each.
    When viewing the work area record in the debugger I'm seeing all the fields and all the values.  When viewing the internal table in the debugger after a record is inserted, the internal table ends with the field defined at Byte 670.  The internal table does not include the two fields defined at Bytes 671 and 672.
    Am I to assume from the above explanation that the length of a record ( A.K.A. row) in an internal table cannot exceed 670 bytes?
    Thank you.

    Manish,
    False alarm!  While, technically, you didn't answer my question, your request for code ended up helping me answer my own question.
    To provide you with some code I wrote a simple test program using the record layout referred to above, with a DO loop to put some records into the internal table, followed by a LOOP AT, with accompanying WRITE statements to display the contents of the internal table and demonstrate that the last two fields weren't being stored.
    However, when I ran the test program, the last two fields were being displayed.
    It was at that point, when stepping through the debugger that I noticed the scroll arrows above the last column of my internal table that allowed me to scroll to the right and see my final two fields.
    Apparently, because of the large number of fields in my internal table I had reached the default display length of the debugger.  While I was obviously aware of the scroll bar found at the bottom of the display, I had never worked with an internal table of that width in the past and hadn't even noticed the scroll arrows above the last column before.
    Thanks for taking the time to respond helping me get to the solution.

  • Retrieving data into internal table

    Hi,
         I am struck at a point where i have to retrieve data from 4 database table to a single internal table with some conditions. can anyone please help me in resolving this issue. your help will be highly appreciated.
    some details are: tables used are-linv,mch1,makt,ausp.
    data:  begin of t_outtab,--final internal table.---output to be displayed
          lgnum  LIKE linv-lgnum,
          ivnum  LIKE linv-ivnum,
          werks  LIKE linv-werks,
          lgtyp  LIKE linv-lgtyp,
          matnr  LIKE linv-matnr,
          bestq  LIKE linv-bestq,
          charg  LIKE linv-charg,
          maktx  LIKE makt-maktx,
          vfdat  LIKE mch1-vfdat,
          atwrt  LIKE ausp-atwrt,
          END OF t_outtab.
    input parameters:-- linv-lgnum and linv-ivnum.
    conditions:1. Where MAKT-MATNR = LINV-MATNR and MAKT-SPRAS = ‘logon language user’
    2. Where MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR)
    3. SELECT AUSP-ATWRT Where AUSP-OBJEK = MCH1- CUOBJ_BM and MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR
    Regards
    Victor

    Hi Victor,
    data: begin of t_outtab,--final internal table.---output to be displayed
    lgnum LIKE linv-lgnum,
    ivnum LIKE linv-ivnum,
    werks LIKE linv-werks,
    lgtyp LIKE linv-lgtyp,
    matnr LIKE linv-matnr,
    bestq LIKE linv-bestq,
    charg LIKE linv-charg,
    maktx LIKE makt-maktx,
    vfdat LIKE mch1-vfdat,
    atwrt LIKE ausp-atwrt,
    END OF t_outtab.
    <b>SELECT</b> 
    linv~lgnum,
    linv~ivnum,
    linv~werks,
    linv~lgtyp,
    linv~matnr,
    linv~bestq,
    linv~charg,
    makt~maktx,
    mch1~vfdat,
    ausp~atwrt,
    <b>FROM  ( ( ( LINV JOIN MAKT ) ON</b>  
      MAKTMATNR = LINVMATNR
       <b> INNER JOIN MCH1 )  ON</b> 
    MCH1CHARG = LINVCHARG AND
      MCH1MATNR = LINVMATNR
    <b> INNER JOIN AUSP ) ON</b>
    AUSPOBJEK = MCH1 CUOBJ_BM
    MCH1CHARG = LINVCHARG
    MCH1MATNR = LINVMATNR
    <b>where MAKT-SPRAS = ‘logon language user’.</b>

  • How to handle field symbols internal table values?

    HI all,
              I declared field string as below.The below code is working fine.
    Data : ITAB TYPE STANDARD TABLE OF YAPOPLN, (Custom table).
              wa_itab like line of ITAB.
    field-symbol : <fs> type ITAB.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But my requirement is that I dont want all the fields of the table YAPOPLN.My output contains only 2 fields of the table YAPOPLN,which contains total 4 fields.According to my requirement only 2 fields will be getting into one parameter PARAM(this is function module parameter,which is from ALV classes) from the user entered output,which contains only 2 fields.So the above code is not working properly because wa_itab contains 4 fields and giving short dump.
    If I am declaring the internal table with the required fields(only 2 fields) and referring that internal table to field symbol <FS>
    Data : BEGIN OF ITAB1 OCCURS 0,
             FIELD1 LIKE YAPOPLN-FIELD1,
             FIELD2 LIKE YAPOPLN-FIELD2,
             END OF ITAB1.
    field-symbol : <fs> LIKE ITAB1 OR  <FS> TYPE ANY.
    DATA :WA_ITAB1 LIKE LINE OF ITAB1.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But when I am compiling this code i am getting the below error.I am gettting the same below error when even <FS> is also declared as <FS> TYPE ANY.
    .'FS' is not an internal table or defined in TABLES.
    Can anyone help me in this regard?
    Thanks,
    Balaji

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • Rearrange  the data in internal tables

    hai experts .
    my internal table is
    item    condition     qty
    10       z001          10
               z002          20
               z003          30
    20       z003          20
    30       z001         10
               z002          20
    my requirement is
    item      z001  z002  z003
    10      10         20      30
    20                             30
    30      10          20
    plese explain.
    thanks in advace.

    plese explain.
    Well, it is you who should receive this question, as we don't have to much details what you really need.
    Anyhow I think you need to create a pivot table. Refer then Create a dynamic internal table horizontally from another internal table
    Regards
    Marcin

  • Briefly about internal tables

    briefly about internal tables
    standerd internal tables
    hash internal tables
    sorted internal tables
    index internal tables

    Hi,
    Internal tables : Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs.
    Types of internal tables :
    The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:
    Standard tables have an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries.
    Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique or non-unique. When you define the table, you must specify whether the key is to be UNIQUE or NON-UNIQUE. Standard tables and sorted tables are known generically as index tables.
    Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, you must specify the key as UNIQUE.
    Creating Internal Tables
    You define internal tables first as an abstract data type in the program or ABAP Dictionary, and then as a data object based on that, or they are declared directly as a fully specified data object. When you create an internal table as a data object, you should ensure that only the administration entry which belongs to an internal table is declared statically. The size of table headers for initial tables is currently 8 bytes. This should be heeded whenever internal tables occur as components of complex data objects. Also, empty tables can use up a relatively high amount of storage space as components of tables. The size of the entire storage space required for an internal table is not defined in the declaration – as is the case for data objects of the type string or xstring. Table rows are added to and deleted from the table dynamically at runtime by the various statements for adding and deleting records.
    Structure of internal tables :
    STRUCTURE OF INTERNAL TABLE
    TYPES : BEGIN OF ITAB,
                    PERNR TYPE PERSNO,
                    WERKS TYPE WERKS,
                   END OF ITAB.
    INTERNAL TABLE DECLARATION FOR THE ABOVE STRUCTURE
    DATA : INT_TAB TYPE STANDARD TABLE OF ITAB,
                WA_TAB TYPE ITAB.        "WORK AREA OF THE INTERNAL TABLE
    Thanks,
    Sakthi C
    Rewards if useful *

Maybe you are looking for