Check an internal table is initial or not..

Hello experts,
I need to check whether an internal table is initial or not in AMDP.....
Lets say i have an internal table IT_TAB[].
I need a statement similar to IT_TAB[] IS NOT INITIAL (in ABAP)
I already tried with COUNT(*), but it returns me an internal table with a column name COUNT with the total number of entries and found it not useful.
Thanks in Advance,
Ramesh

Well do it by below way.
DECLARE LV_LINE VARCHAR(3);
SELECT COUNT(*) INTO LV_LINE FROM :IT_TAB;
Regards,
Amol

Similar Messages

  • I need to add check whether 21 fields of a internal table are empty or not.

    Hello,
    I need to add check whether 21 fields of a internal table are empty or not.How can we write a code for the same wand what would be the correct syntax for it.
    I tried entering all the fields in the IF loop with AND condition but its giving syntax error.Perhaps this is because the lenght of the IF condition would be more than the allowed one.

    Hi,
    After the select quiery.
    If not itab is initial.
    Message 'Table is not empty'    type 'I'.
    Endif.
    Regards,
    Jagadish.

  • How to check two internal table fields

    Hi all,
    I need to check two internal table fields are equal or not means which statement i can use.
    Not internal table ,table contents i need to check i.e
    it1-pernr = it2-pernr.
    like this
    if i put loop it'll check one table field for one loop.
    if i put two loop means some fields reflecting 2 in it1 then it'll pring 4 times like that.i want to print whatever in internal table only .
    pernr(0001) two times there in it1 means
    it1-pernr = it2-pernr then
    it's printing
    0001
    0001
    0001
    0001
    like this but actually in it1 only two records.
    Anybody know solution.tell me.
    Thanks
    Regards,
    Nandha

    Hi,
    code for your view
    data : begin of it1 occurs 0,
           z_pernr like pa9012-pernr,
           z_fac_c like pa9012-zz_fac_c,
           end of it1.
    data : it2 like Zsc1 occurs 0 with header line,
    It1 data
    pernr   FAC C
    0001   5555
    0001   5555
    0002   4444
    0003   3333
    0006   8888
    It2 data
    pernr   FAC C
    0001   5555
    0001   5555
    0005   6666
    0003   3333
    output(My code)
    loop at it2 .
    loop at it1 where pernr = it2-pernr.
      write:/01 it1-1pernr,
            10 it1-z_fac_c.
    endloop.
    endloop.
    out put i need.
    0001   5555
    0001   5555
    0002   4444
    0003   3333
    Thanks,
    Nandha

  • Checking of internal tables

    hi all,
    I have two internal tables and I want to check whether the data present in both the
    internal tables is same or not.
    how to do that.
    Thanks,
    Satish.

    if itab1[] = itab2[].
    ~Suresh

  • Extended Program check for internal table

    TYPES:BEGIN OF TY_FINAL,
            VBELN TYPE VBAP-VBELN,
            VBELV TYPE VBAP-VBELV,
            POSNV TYPE VBAP-POSNV,
            WERKS TYPE VBAP-WERKS,
            ZZ_MODEL_NO TYPE VBAP-ZZ_MODEL_NO,
            VKORG TYPE VBAK-VKORG,
            TEXT(70) TYPE C,
          END OF TY_FINAL.
    Declaration of Variables                                            *
    DATA: IT_VBAK  TYPE STANDARD TABLE OF TY_VBAK ,
          IT_VBAP  TYPE STANDARD TABLE OF TY_VBAP ,
          IT_FINAL TYPE STANDARD TABLE OF TY_FINAL WITH HEADER LINE.
    DATA: W_VBAK         TYPE TY_VBAK            ,
          W_VBAP         TYPE TY_VBAP            ,
          W_FINAL        TYPE TY_FINAL           ,
          W_LAYOUT       TYPE SLIS_LAYOUT_ALV    ,
          W_VARIANT_SAVE TYPE C                  ,
          W_REPID        TYPE  SY-REPID          .
    In the above code i have declared IT_FINAL TYPE STANDARD TABLE OF TY_FINAL WITH HEADER LINE. in extended program check iam getting error as( Tables with headers are no longer supported in the OO context.
    can any one plz suggest me to avoid this error.
    Thanks in Advance.
    Moderator message - Duplicate post locked
    Edited by: Rob Burbank on May 19, 2009 9:12 AM

    Hi,
    DATA: IT_VBAK TYPE STANDARD TABLE OF TY_VBAK ,
    IT_VBAP TYPE STANDARD TABLE OF TY_VBAP ,
    " If you declare the internal table with header line in OO context it wll give you error. As OO wil not
    " support the header line concept. Declare Internal table without header line and create the work area
    " for the internal table
    IT_FINAL TYPE STANDARD TABLE OF TY_FINAL. "  WITH HEADER LINE.
    DATA: W_VBAK TYPE TY_VBAK ,
    W_VBAP TYPE TY_VBAP ,
    W_FINAL TYPE TY_FINAL ,                    " Use this work area
    W_LAYOUT TYPE SLIS_LAYOUT_ALV ,
    W_VARIANT_SAVE TYPE C ,
    W_REPID TYPE SY-REPID

  • How to check if internal table exists in dynamical called subroutine ?

    Hi,
    in a dynamically called subroutine i'm using a internal table, but in some calls this table is not exist.
    How can i check in the code whether the internal table exist or not ?
    regards,
    Hans

    In Horst Keller's blog /people/horst.keller/blog/2005/05/27/abap-geek-10--everything-functions-150-but-how my issue is talked about :
    All other parameters are handled in a way as they were declared as global data objects in the top include of the function group, that can be used only during the execution of the function module: They are visible throughout the function group but you can access them only while the function module is active. If you access such a parameter and the respective function module is not executed, you get the runtime error GETWA_NOT_ASSIGNED (Why? Well, technically thos guys are represented via field symbols which are valid only during the runtime of the function module).
    The code is in SD pricing. Sometimes the code is called from function module PRICING_BUILD_XKOMV or PRICING_SUBSCREEN_PBO where TKOMV is defined as globalized parameter.
    And sometimes it is called from function module PRCING_CHECK where TKOMV is NOT defined as parameter.
    In the call of last function the dump occures on the ASSIGN statement :
         data: ls_tkomv like line of tkomv,
                  lv_tablename(30) type c value 'TKOMV[]'.
        field-symbols: <lfs> type any table.
         assign (lv_tablename) to <lfs>.
         if <lfs> is assigned.
    Any suggestions to solve the issue ?
    regards,
    Hans

  • How to check if date field is initial or not in script layout?

    hi all,
    i have a requirement, i need to check if a particular field is initial or not in script.
    i am checking like this
    /: if &VTTK-DALEN& is initial.
    its not working
    even if not .... is initial is also not working.
    i have used all capital letters only....
    thanks in advance.

    You can not use that syntax in sapscript.  You might try this.
    /: IF &VTTK-DALEN& = ' '
    Regards,
    Rich Heilman

  • Where I can check the internal table memory that have the system?

    Hi
    I have some jobs that cancel with this error:  No storage space available for extending an internal table.
    Where I can check the amount of space memory that have the system and if I can resolve this problem if I put a commit work or something like that?
    The dump stop when I make a import:
    IMPORT TIMES DHIST3 SUM3 FROM DATABASE MONI(DB) ID MONIKEY.
    Thanks for the help!

    hi,
    goto:
    sm04 - goto- memory
    A.
    Message was edited by:
            Andreas Mann

  • How to Check whether a table is indexed or not?

    Hi all,
    I am writing a c++ program where i have to create an Index if Index not exists.
    Oracle 10.2 is the oracle version and i am using oracle text for indexing.
    table -- create table xmltable (versionnumber number,instance xmltype);
    index -- create index configindex on xmltable (instance) indextype is ctxsys.context;
    drop -- drop index configindex force;
    My algorithm should something like,
    if(configindex is exists)---------->What i have to write here to check if index is present.
    { drop index  configindex force; }
    create index configindex on xmltable (instance) indextype is ctxsys.context;
    Thanks......

    Hi,
    You could check the system view ALL_INDEXES .
    HTH,
    Chris

  • Internal table content not retained in statefull BSP application.

    Hi Forum,
    I have a statefull BSP application with two pages.I fill an internal table ITAB in the OnInputProcessing eventhandler of first page and then transfer this ITAB to second page , but when i navigate back from second page to first page , the internal table ITAB is cleared.I need the data in ITAB when i come back to first page.
    The internal tables that i fill in the OnCreate eventhandler of the first page are intact but this  ITAB that  i fill in OnInputProcessing is cleared.
    I tried using
    runtime->keep_context = 1.
    but it is not helping either...and i have checked the code carefully to ensure that ITAB is not cleared anywhere using CLEAR ITAB.
    ITAB is declared in PAGE ATTRIBUTES using a tabletype.
    What might be the problem?
    Thanks,
    Anubhav.

    Hi Heth,
    I carried out a small test application as follwos:
    1)Filled an internal table ITAB_ZSCMG in OnCreate event of first page.
    2)Filled an internal table ITAB_MATERIALS in OnInputProcessing for the OnClick of button event.
    When my application was stateless the internal table ITAB_ZSCMG was initial in the OnInputProcessing event .
    When i switched to STATEFULL mode , it contained data in the OnInputProcessing .
    3)Crearted one more page SECOND.HTM.
    4)in the OnClick event for button in OnInputProcessing eventhandler i navigated back to FIRST.HTM .
    Found that all the internal tables were initial , although my page was statefull.
    All these ITABs were declared using Page Attributes.
    So i guess , a statefull application just means that DATA is retained between different eventhandlers of the SAME PAGE and not if we navigate from that page....
    Hence in my case i have to transfer the ITAB back to first page again using SERVER SIDE COOKIES..
    Please correct me if my derivations are wrong!!!
    But the question still remains....
    How to retain data after navigation?
    Do we have a solution in BSP or we need to use SET/GET or EXPORT/IMPORT or COOKIES?
    Thanks,
    Anubhav.
    Edited by: Anubhav Jain on Jun 19, 2008 9:04 AM

  • Data is not coming in internal table

    Hello Abapers,
    Data is not coming in my internal table.
    Plz tell me where I m wrong
    SELECTION-SCREEN BEGIN OF  BLOCK blk.
    PARAMETERS:       compcode LIKE vbrk-bukrs OBLIGATORY.
    PARAMETERS:       billtype LIKE vbrk-fkart OBLIGATORY.
    SELECT-OPTIONS:   billdate FOR  vbrk-fkdat OBLIGATORY.
    PARAMETERS :      acgrpc   LIKE vbrk-ktgrd OBLIGATORY.
    PARAMETERS:       acgrpm   LIKE vbrp-ktgrm OBLIGATORY.
    PARAMETERS:       taxcode  LIKE konv-mwsk1 OBLIGATORY.
    SELECT-OPTIONS:   plant FOR vbrp-werks .
    SELECT-OPTIONS:   bussarea FOR vbrp-gsber .
    SELECTION-SCREEN END OF BLOCK blk.
    START-OF-SELECTION.
    SELECT avbeln afkart aknumv afkdat abelnr aktgrd abukrs axblnr
    amwsbk  bgsber bwerks bktgrm
    FROM ( vbrk AS a INNER JOIN vbrp AS b ON
    avbeln EQ bvbeln  )
    INTO CORRESPONDING FIELDS OF TABLE vbrk_vbrp
    WHERE ( a~fkart EQ billtype )  AND
    ( a~fkdat IN billdate ) AND
    ( a~ktgrd EQ acgrpc ) AND
    ( a~bukrs EQ compcode ) AND
    ( b~gsber EQ bussarea ) and
    ( b~werks EQ plant ) AND
    ( b~ktgrm EQ acgrpm ) .
    Ravi

    Hi,
    write ur query this way :
    SELECT avbeln afkart aknumv afkdat abelnr aktgrd abukrs axblnr amwsbk bgsber bwerks bktgrm
    FROM ( vbrk AS a INNER JOIN vbrp AS b ON
    avbeln EQ bvbeln )
    INTO CORRESPONDING FIELDS OF TABLE vbrk_vbrp
    WHERE ( a~fkart EQ billtype ) AND
    ( a~fkdat IN billdate ) AND
    ( a~ktgrd EQ acgrpc ) AND
    ( a~bukrs EQ compcode ) AND
    ( b~gsber IN bussarea ) and
    ( b~werks IN plant ) AND
    ( b~ktgrm EQ acgrpm ) .
    even plz check then internal table ' vbrk_vbrp ' if they have all the fields of select query and even the order is same as select , since you are using ' into corresponding fields of table ' clause in select statement.
    hope this helps.
    thanx,
    dhanashri.
    Edited by: Dhanashri Pawar on Aug 26, 2008 6:14 AM

  • 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

  • Best way to check if table is empty or not

    Hi. I had to check if a table was empty or not, and found different solutions.
    One of them called my atention, I readed it was the best way to do it (some 'dual' trick from Steven Feuerstein, they say) :
    SELECT 1 FROM DUAL WHERE EXISTS (SELECT 'X' FROM TABLE);
    Plan
    SELECT STATEMENT ALL_ROWSCost: 4 Cardinality: 1           
         3 FILTER      
              1 FAST DUAL Cost: 2 Cardinality: 1
              2 INDEX FAST FULL SCAN INDEX (UNIQUE) TABLE.UB_PK Cost: 2 Cardinality: 1
    But doing some tests I found this query to have lower cost:
    SELECT 1 FROM TABLE WHERE ROWNUM=1;
    Plan
    SELECT STATEMENT ALL_ROWSCost: 2 Cardinality: 1           
         2 COUNT STOPKEY      
              1 INDEX FAST FULL SCAN INDEX (UNIQUE) TABLE.UB_PK Cost: 2 Cardinality: 1
    So, what about that dual table trick? Should I keep the 'select 1 where rownum=1' as best possible way?
    I know it shouldn't matter much, but just wanna know what method works best for checking empty tables :)
    Thanks.

    As already mentioned, you cannot just base it on cost, as the cost is not specifically a good indicator of the amount of work that will need to be done, it's just an internal figure calculated for that query and isn't really that comparible across different queries.
    If you're intending to see if there is data in a table because you want to know whether to query it or not, you are actually better to just try and query the data and capture the NO_DATA_FOUND exception and handle that.  In that case it requires no effort or cost up front.

  • FM to check if table (eg BUT000) is not locked

    Hi experts,
    Any idea which FM can check if the table (eg BUT000) is not being locked before attempting to write record into table?
    Thanks

    HI
    go to SM12 transaction
    You can use function ENQUEUE_READ.also you can use the function module GET_LOCKLIST_ADA
    hope this helps you

  • New Line after every 900 lines in internal table

    HI,
    I have an internal table and that is sorted by company code. i.e it is grouped according to company code.
    Now i want to check in particular groups of company code if the lines of internal table is > 900 or not.
    And if it > 900 i have to insert new line.
    How to do that?

    Hi
    Please check  the code..I think it will solve ur problem
    TYPES : BEGIN OF x_data,
             name TYPE char10,
            END OF x_data.
    data: i_data  TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
          wa_data TYPE x_data,
          counter TYPE n LENGTH 2 .
    DO 5 TIMES.
    CLEAR : wa_data.
      counter = counter + 1.
    CONCATENATE 'subha' counter INTO wa_data-name.
    APPEND wa_data to  i_data.
    ENDDO.
    CLEAR : counter,
            wa_data .
    DESCRIBE TABLE i_data LINES counter.
    IF counter > 4.
      counter = 5.
      wa_data-name = 'TEST'.
    INSERT wa_data INTO i_data INDEX counter.
    ENDIF.
    CLEAR: wa_data.
    LOOP at i_data INTO wa_data .
      WRITE : / wa_data-name.
    ENDLOOP.
    Use 900 instead  4 and 901 instead of 5.

Maybe you are looking for