Query to check internal table

hi all,
I have to check an internal table data(it_tab)
It holds records like
A       B     C       D       E        F
325     1     1     512     0     0010
325     1     1     548     36     0010
325     1     1     554     42     0010
325     2     2     512     0     0011
325     2     2     548     36     0011
325     2     2     554     42     0011
325     3     3     512     0     0012
325     3     3     554     42     0012
800     3     1     512     0     0011
800     3     1     530     18     0011
800     4     2     512     0     0012
800     4     2     532     20     0012
800     4     2     533     21     0012
800     4     2     538     26     0012
800     4     2     556     44     0012
800     5     3     512     0     0013
800     5     3     532     20     0013
800     5     3     538     26     0013
800     5     3     556     44     0013
I have to check whether the number generated in D is  increasing one by one
for eg D : 512, 513, 514,...
Here it is not in the sequence
So i need to check whther it is in sequence if not so i should delete the record
Could you suggest the way to check the in_tab?
Regards
senthil

Hi,
Try the follwoing:
You just need to use AT NEW control break after the loop statement.
DATA: Var1(5)    TYPE n.
DATA: Var2(5)    TYPE n.
DATA: Count(5)  TYPE n.
DATA: it_tab2     type table of it_tab.
clear: count.
LOOP at it_tab.
AT NEW a
Clear: count, Var1, Var2.
Count = Count + 1.
IF Count >= 2.
var2 = it_tab-D.
If var2 = var1 + 1.
append it_tab to it_tab2.
endif.
endif.
var1 = it_tab-D.
ENDAT
Endloop.
Reward points if helpful answer.
Ashvender

Similar Messages

  • How many records are  fetched my query into my internal tables

    Hi
    I am in the debugger, would like to know, how many records are  fetched my query into my internal tables. How do I  find out ?
    thanks
    siva

    Hi,
    Do the following,
    Step 1:
      Fill your internal table with select query.
    Step 2 : Use DESCRIBE statement with LINE addition to get the no of rows in the internal table.
    for further informations, check
    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
    Regards,
    Anirban

  • Query related to Internal Table

    Hi ,
          I have a small query related to internal table , can we dump millions of records to an internal .
    The actual requirment is like i need to develop a report in BI side where i have to dump records into an internal table  from PSA tables without filtering .
    Can we do so ....
    or do we have any other option to dump the data to an internal tables .
    need some tips on the same .
    Thanks ,
    VInay.

    Hello Vinay,
    I believe the following extract will give you a brief idea on the size limitations for an internal table.......
    Internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. <u><i>The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries.</i></u>
    Hope it proved useful
    Reward if helpful
    Regards
    Byju

  • Extracting the result of a query into a internal table

    Hi,
    Does anyone knows or have an idea how to extract the result of a query into a internal table, is there a function module or BAPI?
    Thanks in advance,
    CK

    So then normally I would use a statment like:
    IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>BAPI_SALESORDER_GETLIST</b>");
    to call a particluar function, but I tried using
    IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>BAPI_MDDATAPROVIDERBW_GETCATALOGS</b>");
    and it did not seem to work. I also tried -
    IFunctionTemplate ftemplate = repository.getFunctionTemplate("<b>MDDataProviderBW.GetCatalogs</b>");
    How do I format the function?
    Thanks
    Paul

  • How to check internal table sorted or not

    Hi all
    I need to check internal table sorted or not which is without header line and having only one field and six values. please let me know how to check it is sorted or not because i need to display message if it is not sorted.
    thanks,
    Minal

    Hi Minal,
    Go through  this info.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    Stable sort
    The option
    SORT <itab> ... STABLE.
    allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort.
    Examples
    DATA: BEGIN OF LINE,
            LAND(3)  TYPE C,
            NAME(10) TYPE C,
            AGE      TYPE I,
            WEIGHT   TYPE P DECIMALS 2,
          END OF LINE.
    DATA ITAB LIKE STANDARD TABLE OF LINE WITH NON-UNIQUE KEY LAND.
    LINE-LAND = 'G'.   LINE-NAME   = 'Hans'.
    LINE-AGE  = 20.    LINE-WEIGHT = '80.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Nancy'.
    LINE-AGE  = 35.    LINE-WEIGHT = '45.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Howard'.
    LINE-AGE  = 40.    LINE-WEIGHT = '95.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'GB'.  LINE-NAME   = 'Jenny'.
    LINE-AGE  = 18.    LINE-WEIGHT = '50.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'F'.   LINE-NAME   = 'Michele'.
    LINE-AGE  = 30.    LINE-WEIGHT = '60.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'G'.   LINE-NAME   = 'Karl'.
    LINE-AGE  = 60.    LINE-WEIGHT = '75.00'.
    APPEND LINE TO ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB STABLE.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB DESCENDING BY LAND WEIGHT ASCENDING.
    PERFORM LOOP_AT_ITAB.
    FORM LOOP_AT_ITAB.
      LOOP AT ITAB INTO LINE.
        WRITE: / LINE-LAND, LINE-NAME, LINE-AGE, LINE-WEIGHT.
      ENDLOOP.
      SKIP.
    ENDFORM.
    ************rewords some points if it is helpful.
    Rgds,
    P.Naganjana Reddy

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Checking internal table

    Hi Experts,
    i have a scenario like this:
    move a to b.
    But before doing this i have to check whether 'a' is contained in the it1 internal table's field val.( ie 'a' is contained in it1-val).
    without looping is there any method.
    Points will be rewarded.
    Regards,
    Soumya.

    hi
    try this
    <b>Read itab into wa.with key itab-val = 'a'.
    if sy-subrc = 0.
    valuer is in itab
    else
    move a to b.
    endif.</b>
    <b>hope it clears ur doubt</b>
    regards
    ravish
    <b>plz dont forget to reward points if useful</b>

  • Query statement for internal table

    is it possible to use a select statement to select data from an internal table? if yes, can anyone show me the codes to it? thx

    Hi Daphne,
    You use SELECT statement to read data from database table but not from Internal table.
    For reading data from Internal table, you have to use READ statement.
    Syntax:
    READ TABLE itab { table_key
                    | free_key
                    | index } result.
    Effect of using read statement:
    This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
    If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
    Reward if usefull
    thanks
    swaroop

  • SAP query change the internal table extracted after a join instruction

    Hi Gurus
    I would like to know if it is possible to change the data in internal table after that the
    join instruction has been executed .
    I should have to delete some lines extracted if some conditions are satisfied.
    Do you think that it is not possible and it is better to crete a program?
    Thanks in advance

    HI,
    use select and end select.
    select single msegbukrs msegwerks msegmatnr msegmenge msegaufnr msegsmbln msegbwart msegshkzg mseg~meins
             afkorsnum afpoverid
             maststlnr maststlal stpoidnrk stpomenge stpomeins stkobmeng
         into (itab-mblnr,
               itab-budat,
               itab-bktxt,
               itab-bukrs,
               itab-werks,
               itab-matnr,
               itab-menge,
               itab-aufnr,
               itab-smbln,
               itab-bwart,
               itab-shkzg,
               itab-meins,
               itab-rsnum,
               itab-verid,
               itab-stlnr,
               itab-stlal,
               itab-matnr_r,
               itab-bdmng,
               itab-meins_r,
               itab-bmeng)
         from mkpf
         inner join mseg on msegmblnr eq mkpfmblnr and mkpfmjahr eq msegmjahr
         inner join mara on maramatnr eq msegmatnr
         inner join afpo on afpoaufnr eq msegaufnr
         inner join mast on mastmatnr eq msegmatnr and mastwerks eq msegwerks
         inner join afko on afkoaufnr eq msegaufnr and afkostlal eq maststlal
         inner join stko on stkostlnr eq maststlnr and stkostlal eq maststlal
         inner join stpo on stpostlnr eq stkostlnr
         inner join stas on stasstlnr eq maststlnr and stasstlal eq maststlal and stasstlkn eq stpostlkn
         where mseg~werks in s_werks
         and mseg~matnr in s_matnr
         and mkpf~budat in s_budat
         and mseg~aufnr in s_aufnr
         and mseg~bwart eq '101'
         and mast~stlan eq '1'
         and stko~stlty eq 'M'
         and stpo~stlty eq 'M'.
    if condtion .
        append: itab.
    endif.
        clear: itab.
      endselect.
    Edited by: ZAHID HAMEED on Oct 12, 2011 3:56 PM

  • How to fetch the data from query to internal table ?

    Dear all ,
             I would like to fetch the query data(sq01) into my internal table ? is it possible to do that ?
    Best Regards,
    Carlos

    Hi
    Try this <b>RRW3_GET_QUERY_VIEW_DATA</b>
    Also, you can have a look at this...
    <a href="/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-ii Query results into Internal table</a>
    Regards
    Raj

  • Data selection from internal table.

    Hi all,
    Can anyone suggest me the replacement of the statement:
    Select sum( col1 ) from table into var1 where col2 = 'abc' and col3 like '1.%' or col3 = 1.
    above statement works on database table but i need the same query on an internal table.
    please tell me.
    Thanks in advance
    Rahul

    PLEASE HELP !
    points will be awarded.

  • Multiple internal table display

    Hi All,
    I have query regarding the internal tables,
    Is it possible to display more than one internal table in ABAP List view
    one beneath another......in the same page.....?
    thanks in advance.....

    Hi,
      Yes,   in classical  do like this
      loop at itab.
    write:/
    endloop.
      loop at itab1.
    write:/
    endloop.
    and in alv refer this code.
    *&      Form  sub_alv_display                                          *
    This form displays the output using REUSE_ALV_GRID_DISPLAY          *
    function module                                                     *
    FORM sub_alv_display .
    *--Local Variables
      DATA : lv_index LIKE sy-tabix.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
           EXPORTING
                i_callback_program = v_repid.
      wa_layout1-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
           EXPORTING
                is_layout                  = wa_layout1
                it_fieldcat                = it_fieldcat[]
                i_tabname                  = 'it_final'
                it_events                  = it_events
           TABLES
                t_outtab                   = it_final
           EXCEPTIONS
                program_error              = 1
                maximum_of_appends_reached = 2
                OTHERS                     = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      LOOP AT it_fieldcat INTO wa_fieldcat.
        lv_index = sy-tabix.
        IF wa_fieldcat-fieldname = 'ERDAT'.
          wa_fieldcat-fieldname = 'TITLE'.
          wa_fieldcat-seltext_m = text-026.
          wa_fieldcat-outputlen = 10.
        ENDIF.
        MODIFY it_fieldcat FROM wa_fieldcat INDEX lv_index TRANSPORTING
                                            fieldname seltext_m outputlen.
        CLEAR : wa_fieldcat.
      ENDLOOP.
      wa_layout2-no_colhead = 'X'.
      wa_layout2-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
           EXPORTING
                is_layout                  = wa_layout2
                it_fieldcat                = it_fieldcat[]
                i_tabname                  = 'it_total'
                it_events                  = it_event1
           TABLES
                t_outtab                   = it_total
           EXCEPTIONS
                program_error              = 1
                maximum_of_appends_reached = 2
                OTHERS                     = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      wa_layout3-no_colhead = 'X'.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
           EXPORTING
                is_layout                  = wa_layout3
                it_fieldcat                = it_fieldcat2[]
                i_tabname                  = 'it_ship'
                it_events                  = it_event2
           TABLES
                t_outtab                   = it_ship
           EXCEPTIONS
                program_error              = 1
                maximum_of_appends_reached = 2
                OTHERS                     = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      IF NOT it_final IS INITIAL OR
         NOT it_total IS INITIAL OR
         NOT it_ship IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
             EXCEPTIONS
                  program_error = 1
                  OTHERS        = 2.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDIF.
    ENDFORM.                                  "sub_alv_display
    Regards,
    Prashant

  • Internal Table dynamic query

    Hello,
    I have an internal table which needs to be queried with set of attributes which change dynamically. How can I do it?
    Eg: Internal Table i_tab contains attributes a,b,c,d,e etc... Now I should extract a single line from the table based based on the values I supply for the attributes.
    Say if I give a=23 b='' c='abc' d='' e=''. Then the query should be able to return be the line where all the initial field attributes (here in this case b,d, and e) should not be considered for the query.
    It shoud be
    read table i_tab with key a= 23 c='abc'.
    The next time a query can be shooted with the foll values
    a='' b='SAP' c='ERP' d='' e=''.
    Then the query shd be
    read table i_tab with key b= 'SAP' c='ERP'.
    In short can I get the functionality of the "select statement dynamic search string"?
    select * from tab where ( search string ) .
    and search string would be generated dynamically based on the inputs?
    I would be really thankful if you can provide me an immediate answer.
    Thanks and Regards,
    Sandhya

    I think one of the simplest way is to define ranges for the variables a, b, c, d and e.
    ranges : r_a for a, r_b for b...r_e for e.
    refresh : r_a, r_b, r_c, r_d, r_e. 
    clear :  r_a, r_b, r_c, r_d, r_e. 
    if a is not initial.
       r_a-sign = 'I'.
       r_a-option = 'EQ'.
       r_a-low = value.
       append r_a.
    endif.
    ....similarly build for b, c, d and e.
    Loop at itab.
      check itab-a in r_a.
      check itab-b in r_b.
      check itab-e in r_e.
      move-corresponding itab to <b>urval</b>.
      exit.
    endloop.

  • How to Query Internal tables in PCR

    Hi Experts,
    When I tried by using operation u201CVAKEYu201D to query the Internal tables, but it was not working
    I would like to write one PCR in the Indian Payroll
    Please can anyone help me on the same?
    The requirement as below;
    u201CIf the DDNTK table filled with amount (Assume that DDNTK table may contains more than one WT)u201D
    u201CAdd this total amount (with same sign) to WT /110 net deductionsu201D
    Thanks in Advance!
    Thanks and Regards
    Cheera

    I have never worked with Indian Payroll and I am not aware of a function or operation that allows to check on table DDNTK,
    but you could check PCR XDPR and function PRDNT.

  • How to check  if all values from a dataset  has come to  an internal table

    How to check  if all values from a dataset  has come to  an internal table ?

    Hi,
    After OPEN DATASET statement check if sy-subrc = 0 if its success then proceed with split statement and save the dataset values into a internal table and while debugging the internal table you will find that whether all values get into internal table.
    Checking sy-subrc after OPEN DATASET statement is must to fill up the values in the internal table.
    For e.g.
    OPEN DATASET p_inpfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        WRITE :/ 'No such input file' .
        EXIT.
      ELSE.
    READ DATASET p_inpfile INTO loc_string.
          IF sy-subrc NE 0.
            EXIT.
          ELSE.
            CLEAR loc2.
    *Spliting fields in the file-
            REPLACE ALL OCCURRENCES OF '#' IN wa_string WITH ' '.
           SPLIT wa_string AT const INTO loc2-pernr
                                           loc2-werks
                                           loc2-persk 
                                           loc2-vdsk1.
    Hope you get some idea.
    Thanks,
    Sakthi C

Maybe you are looking for

  • AR- Invoice- splitting line item positngs

    Hello,    we have a scenario in the AR invoice. The business invoices the customer on a weekly basis, for the week at month-end few days if the week fall into the next month( for e.g Oct 28th week , thursday and friday fall into Nov month, they want

  • JCo Server does not start

    Hi, I'm trying to create and start a JCoIDoc.Server on a Web Application Server 700 system. Because I could not find the required classes in the trfc.jar archive on the server I downloaded and packaged the required java connector classes sapidoc.jar

  • I have a iPhone 3GS and the power connection prongs are damaged and it won't charge or sync.  Is there any way to repair?

    I have a iPhone 3GS and the power connection prongs are damaged and it won't charge or sync.  Is there any way to repair?  Or, at least is there a way to charge so I can write down phone numbers and othe rinformation.  My power charge is totally out

  • Midlet gives java.lang.ClassCastException

    Hi all! This is the web service WSDL link -- http://jupiter.webspiders.com/event2mobile/services/entityservice.asmx?WSDL3 which I am using for accessing a web service. The problem is that in my Midlet it give out Exception: java.lang.ClassCastExcepti

  • Upgradation from 4.6c to ECC

    I need some documents for the Risks involved in Upgradation. I searched but,i could not find any useful thing. Can anyone help me plz.