Describe statement in abap

how to use this descibe statement.can any one please explain me with example

Hi Rajeev, write Describe and press F1 in the ABAP editor..u ll get the different functionalities for describe..
this is one of them
DESCRIBE - Return attributes of an internal table
Basic form
DESCRIBE TABLE itab.
Effect
Returns the attributes of the internal table itab. You must use at least one of the additions listed below:
Note
The DESCRIBE statement cannot be used for all ABAP types. In connection with ABAP Objects, SAP has introduced a RTTI concept based on system classes to determine type attributes at runtime. This concept applies to all ABAP types and as such covers all the functions of the DESCRIBE TABLE statement.
Extras:
1. ... LINES n
2. ... OCCURS n
3. ... KIND   k
Addition 1
... LINES n
Effect
Places the number of filled lines of the table t in the field lin. The value returned to lin has type I.
Note
The number of filled lines of the table itab can also be ascertained using the predefined function lines( itab ).
Example
DATA: N    TYPE I,
      ITAB TYPE TABLE OF I.
CLEAR ITAB.
APPEND 36 TO ITAB.
DESCRIBE TABLE ITAB LINES N.
Result: N contains the value 1.
Addition 2
... OCCURS n
Effect
Passes the size of the OCCURS parameter from the table definition (as defined with DATA) to the variable n. The value returned to n has type I.
Example
DATA: N1    TYPE I,
      N2    TYPE I,
      ITAB1 TYPE TABLE OF I INITIAL SIZE 10,
      ITAB2 TYPE I OCCURS 5.
DESCRIBE TABLE ITAB1 OCCURS N1.
DESCRIBE TABLE ITAB2 OCCURS N2.
Result: OCC contains the value 10 and N2 the value 5.
Addition 3
... KIND k
Effect
Writes the table type from itab to the variables n. The value returned to k is of type C. The constants SYDES_KIND-STANDARD, SYDES_KIND-SORTED and SYDES_KIND-HASHED are defined in the type group SYDES for the return values.
Example
Generic FORM routine any table type
TYPE-POOLS: SYDES.
FORM GENERIC_FORM USING ITAB TYPE ANY TABLE.
  DATA: K TYPE C.
  DESCRIBE TABLE ITAB KIND K.
  CASE K.
    WHEN SYDES_KIND-STANDARD.
    WHEN SYDES_KIND-SORTED.
    WHEN SYDES_KIND-HASHED.
  ENDCASE.
ENDFORM.
Notes
Performance: The runtime for executing the DESCRIBE TABLE statement is approximately 4 msn (standardized microseconds).
The DESCRIBE TABLE statement also passes values to the SY-TFILL and SY-TLENG System fields
Additional help
Determining the Attributesof Internal Tables

Similar Messages

  • Help with provide statement In ABAP HR

    Hi to all experts,
    My requirement is to display locked  records with start date and end date
    But the problem when i select the period as current month im getting the start date of the current month and enddate of the current month
    PROVIDE * FROM p0008 BETWEEN pn-begda AND pn-endda.
            IF  p0008-sprps = 'X'.
              gs_final-pernr = p0008-pernr.
              gs_final-cname = w_name.
              gs_final-inftyp = '0008'.
              gs_final-begda = p0008-begda.
              gs_final-endda = p0008-endda.
              gs_final-uname = p0008-uname.
              gs_final-aedtm = p0008-aedtm.
              APPEND gs_final TO gt_final.
            ENDIF.
    the current month is selected in the period im getting the begda as 01.11.2009 and endda as 30.11.2009 but the start date and enddate should be 02.11.2009 and 31.12.2009 . after the provide the values are changed

    Hi!
    Provide "cuts" the date borders as described in the abap-documentation.
    You can use the following:
    loop at p0008 where ( begda le pn-begda and endda ge pn-endda ) or
                                       ( begda between pn-begda and pn-endda ) or
                                       ( endda between pn-begda and pn-endda ).
    move fields to gs_final
    append gs_final to gt_final.
    endloop.
    I hope this helps!
    Kind regards
    Peter

  • Merge Statement in ABAP

    Dear Gurrus,
    i am having a trouble in using oracle merge statement in abap, the moment i use where clause in the bottom it  gives me an oracle error
    EXEC SQL.
      MERGE INTO SAP_GL_ACCOUNT@GETZDB a
      USING SKA1 b
        ON (A.gl_code= B.SAKNR)
      WHEN MATCHED THEN
        UPDATE SET a.posting_block =  B.XSPEB,
                   a.locked        =  B.XSPEA,
                   A.BALANCE_SHEET =  B.XBILK
         WHEN NOT MATCHED THEN
           insert   (gl_code,
                     DESCRIPTION,
                     posting_block,
                     locked,
                     balance_sheet)
          VALUES (b.SAKNR,'shadab',B.XSPEB,B.XSPEA,B.XBILK)
          where b. mandt = 950      I am talking about this line
             ENDEXEC.
    the Moment  i include WHERE clause in the botton before ENDEXEC it generates as error
    " Database error text........: "ORA-00904: "A3"."MANDT": invalid  identifier#ORA-02063: preceding line from GETZDB".
    although its a basic feature of Oracle to inclue where clauses in insert or update in merge, but here it is generating an error.

    Hello Shadab,
    As per my understanding of this oracle native sql code.
    everything is fine except the use of direct value i.e 950 .
    System is not able to process this value .
    This normally happens even in normal abap sql statements also.
    The better solution could be to declare a variable with the
    same data type as "mandt" and then pass this "950" value into that
    variable and then use this variable in the where clause instead of directly
    passing the value.
    i.e data:l_var type mandt vlaue '950'.
    The other option could be to use the same hard coded
    value but use this value in the where clause in quotations i.e.,
    '950' instead of 950.
    I hope this would solve your purpose, If not please reply me back.
    thanks,
    M.Naveen Kumar.

  • Submit statement in ABAP program

    Hi All,
          I am using two submit statements in my program for two different reports. When i run the program i get the output screens of the two reports at the ouptut. Is there any way i can hide the user seeing the output screens of the two programs and display only the output screen of my program. If you have any clues please post it.
    Thanks & Regards,
    Rahul Rathi

    You can call executable programs from other ABAP programs using the following statement:
    SUBMIT <rep>|(<field>) [AND RETURN] [<options>].
    You can either specify the name of the program you want to call statically by entering the program name in the code of the calling program, or dynamically by specifying the name of a field (in parentheses) containing the name of the program. If the system cannot find the specified executable program when trying to execute the SUBMIT statement, a runtime error occurs.
    If you omit the AND RETURN addition, all data and list levels of the calling program (the entire internal session) are deleted. After the called executable program has finished, control returns to the level from which you started the calling program.
    If you use AND RETURN, the system stores the data of the calling executable program and returns to the calling after processing the called program. The system resumes executing the calling program at the statement following the call.
    The SUBMIT statement has a set of additions <options> for passing data to the called program and specifying various other processing options. Some of them are described in the following sections:
    Have a look at below link. It will help you.
    http://www.sapdevelopment.co.uk/reporting/rep_submit.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9dd035c111d1829f0000e829fbfe/content.htm
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • Export statement in ABAP Objects

    Hi All,
    I am using A Statment like this a BADI.
    EXPORT XXXXX TO MEMORY ID 'YYY'.
    But this statement is not supported in ABAP Objects can any one please let me know how i can use export statment is abap objects?
    Thanks in advance.

    I have pass a structure to the memory.
    Here is my structure : ztest.
    And i am using like this
    EXPORT ZTEST TO MEMORY ID 'HK'.
    Its not supporting in ABAP Objects.
    Can you please more clear with your answer?
    Thanks

  • ABAP list processing statements in ABAP Objects

    Hi,
    Based on the Online help "The ABAP statements used for list processing are not yet fully available in ABAP Objects".
    Is there any chnage planned about this for the next WAS release?
    Thanks,
    Peter

    Hi Peter
    I believe, most of the measures taken are for some compatibility and performance issues. So, there is no need to expect great changes about this.
    *--Serdar

  • URGENT : select from table statement in ABAP OO

    Hi all,
    I am an absolute ABAP OO beginner and need some quick help from an expert. How can I make a selection from an existing table (eg MARA) in an BADI which is programmed according to ABAP OO principles.
    In the old ABAP school you could make a TABLES statement at the beginning and the do a SELECT¨* FROM but this does not work in ABAP OO.
    How should i define such simple selections from existing tables. Anyone ?
    Thanks a lot,
    Eric Hassenberg

    *define internal table
    data: i_mara like standard table of mara.
    *select to this table
    select * from mara into table i_mara.
    Also you have to define work area for this internal table in order to use it.
    data:w_mara like line of i_mara.

  • Can we use is null in our select statement in ABAP program

    hi,
    I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data. Can anyone resolve this.

    Hi,
    I think you've posted your question on the wrong forum. This is the SAP Business One development forum which is not part of ERP and doesn't include any ABAP or Netweaver programming.
    For a list of forums please see here:
    http://forums.sdn.sap.com/index.jspa
    Kind Regards,
    Owen

  • UNION statement in ABAP SQL

    Hi,
    How to achieve the UNION SQL operation results in ABAP? To be specific, I want to retrieve STCD1 field value from vendor master table (LFA1) for all vendors (LIFNR) that exist in table BSIK or BSAK.
    And I want to achieve the results in single SQL statement. So in essence, the resultant SQL would be something like:
    SELECT STCD1
    INTO TABLE my_internal_table
    FROM LFA1
    WHERE LIFNR IN (SELECT DISTINCT LIFNR
                                                FROM BSIK
                                UNION
                                SELECT DISTINCT LIFNR
                                               FROM BSAK)
    But the UNION is not a valid keyword in ABAP. Any idea how to achieve this?
    Regards,
    Chetan

    hi chetan,
    do you have any where condition to filter the records from bsak and bsik?
    your requirement cannot be realized in a single statement.
    you have to use two separate selects from bsak and bsik, then, collect all the vendors in one internal table and at last you have to use this table to get the vendor info from lfa1.
    regards,
    ravi

  • Loop statement in ABAP OO

    Hi,
    I am trying to change a BADI interface and since BADIs use ABAP OO, a simple loop statement fails to work.
    I need to loop through an internal table and for each record in the internal table I need to read another db table which has a field in common with the internal table.
    Ideally,
    Loop at lt_selections
    select logsys from /bic/mzcs_unit where /bic/zcs_unit = lt_selections-cs_unit
    endloop.
    But this piece of code fails to work in BADI because of OO concepts.
    Can anyone help me out here?
    THank you

    As Alejandro said, if you are getting a syntax error, it is probably because <b>header lines are not allow in OO</b>.
    data: wa_selections like line of lt_selections.
    Loop at lt_selections into wa_wa_selections.
    select logsys from /bic/mzcs_unit
         where /bic/zcs_unit = wa_selections-cs_unit.
    endloop.
    Regards,
    Rich Heilman
    Message was edited by: Rich Heilman

  • How to use  'is null' in select statement of ABAP program

    hi,
    I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data.
    SELECT * FROM mara INTO TABLE it_mara
          WHERE volum IS NULL .
    Can anyone resolve this.

    Hi PKB,
    Check the below thread for NULL and Space value in ABAP . It will help you
    NULL and Space value in ABAP
    Regards,
    Pawan

  • Insert Statement in ABAP

    Hi,
    I am new to ABAP Programming., i had created a function module with 5 import parameters enableing
    optional and pass value options. I need to insert values to database. But function module contains only
    the following statemet.
    FUNCTION ZEMP_CREATE_NAME.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(EMPID) TYPE  ZEMPID OPTIONAL
    *"     VALUE(NAME1) TYPE  ZNAME1 OPTIONAL
    *"     VALUE(ORT01) TYPE  ORT01_GP OPTIONAL
    *"     VALUE(REGIO) TYPE  REGIO OPTIONAL
    *"     VALUE(TELF1) TYPE  TELF1 OPTIONAL
    *"     VALUE(STATUS) TYPE  ZSTATUS OPTIONAL
    *"     VALUE(EPOSITION) TYPE  ZPOSI OPTIONAL
    insert into zemptable values('EMPID','NAME1','ORT01','REGIO','TELF1','ZSTATUS','ZPOSI')).
    ENDFUNCTION.
    Is this statement correct? Could someone guide me how to resolve this?
    Thanks & Regards
    Vijay

    Check the F1 help for insert.
    If you already Checked the program you know it's not right.
    That looks ok for Standard SQL, but ABAP uses a special set of sql commands called open sql.
    *edit
    Sorry, didn't saw you were new at this, you don't want to pass that many parameters.
    IF those 7 parameters make up the whole table is better to do either something like...
    w_zemptable type zemptable in the importing parameters and then in the code just do
    insert into zemptable values w_zemtables.
    .... or better
    in the tables section declare
    i_zemptable like zemptable
    and in the code
    insert zemptable from table i_zemptable.
    Edited by: Ramiro Escamilla on May 9, 2008 3:23 PM

  • SQL Statements in ABAP and meaning

    Hello Friends,
    Please, can anybody provide me a documentation on the different ABAP SQL statements and there usage/meanings.
    Thanks,
    Shreekant

    hi,
    goto abapdocu->abap Database access->open Sql you will get examples.
    for documnetation got se38->specify the command and press F1.
    SELECT:
    Put the curson on that word and press F1 . You can see the whole documentation for select statements.
    SELECT result
    FROM source
    INTO|APPENDING target
    [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
    Effect
    SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
    The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
    The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
    Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
    System Fields
    The SELECT statement sets the values of the system fields sy-subrc and sy-dbcnt.
    sy-subrc Relevance
    0 The SELECT statement sets sy-subrc to 0 for every pass by value to an ABAP data object. The ENDSELECT statement sets sy-subrc to 0 if at least one row was transferred in the SELECT loop.
    4 The SELECT statement sets sy-subrc to 4 if the result set is empty, that is, if no data was found in the database.
    8 The SELECT statement sets sy-subrc to 8 if the FOR UPDATE addition is used in result, without the primary key being specified fully after WHERE.
    After every value that is transferred to an ABAP data object, the SELECT statement sets sy-dbcnt to the number of rows that were transferred. If the result set is empty, sy-dbcnt is set to 0.
    Notes
    Outside classes, you do not need to specify the target area with INTO or APPENDING if a single database table or a single view is specified statically after FROM, and a table work area dbtab was declared with the TABLES statement for the corresponding database table or view. In this case, the system supplements the SELECT-statement implicitly with the addition INTO dbtab.
    Although the WHERE-condition is optional, you should always specify it for performance reasons, and the result set should not be restricted on the application server.
    SELECT-loops can be nested. For performance reasons, you should check whether a join or a sub-query would be more effective.
    Within a SELECT-loop you cannot execute any statements that lead to a database commit and consequently cause the corresponding database cursor to close.
    SELECT - result
    Syntax
    ... lines columns ... .
    Effect The data in result defines whether the resulting set consists of multiple rows (table-like structure) or a single row ( flat structure). It specifies the columns to be read and defines their names in the resulting set. Note that column names from the database table can be changed. For single columns, aggregate expressions can be used to specify aggregates. Identical rows in the resulting set can be excluded, and individual rows can be protected from parallel changes by another program.
    The data in result consists of data for the rows lines and for the columns columns.
    SELECT - lines
    Syntax
    ... { SINGLE }
    | { { } } ... .
    Alternatives:
    1. ... SINGLE
    2. ... { }
    Effect
    The data in lines specifies that the resulting set has either multiple lines or a single line.
    Alternative 1
    ... SINGLE
    Effect
    If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.
    An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
    Note
    When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
    Alternative 2
    Effect
    If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.
    If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:
    If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW
    If the system tries to access pool or cluster tables and single columns are specified in columns.
    Note
    When specifying DISTINCT, note that you have to carry out sort operations in the database system for this.
    SELECT - columns
    Syntax
    | { {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ... }
    | (column_syntax) ... .
    Alternatives:
    1. ... *
    2. ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    3. ... (column_syntax)
    Effect
    The input in columns determines which columns are used to build the resulting set.
    Alternative 1
    Effect
    If * is specified, the resulting set is built based on all columns in the database tables or views specified after FROM, in the order given there. The columns in the resulting set take on the name and data type from the database tables or views. Only one data object can be specified after INTO.
    Note
    If multiple database tables are specified after FROM, you cannot prevent multiple columns from getting the same name when you specify *.
    Alternative 2
    ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    Effect
    A list of column labels col1 col2 ... is specified in order to build the resulting list from individual columns. An individual column can be specified directly or as an argument of an aggregate function aggregate. The order in which the column labels are specified is up to you and defines the order of the columns in the resulting list. Only if a column of the type LCHAR or LRAW is listed does the corresponding length field also have to be specified directly before it. An individual column can be specified multiple times.
    The addition AS can be used to define an alternative column name a1 a2 ... with a maximum of fourteen digits in the resulting set for every column label col1 col2 .... The system uses the alternative column name in the additions INTO|APPENDING CORRESPONDING FIELDS and ORDER BY. .
    http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm

  • Oracle Describe Statement and CGI

    Hello,
    First of all,
    I would like to thank everyone that helped me out. It really
    made my much easier.
    Second,
    General Question.
    describe command in Oracle will display a specified table's
    definition.
    Now, I have a CGI program that will execute any SQL statement
    that has to do with tables on Oracle Database.
    i.e. select , update, insert, delete. Now when I tried
    describe student, i got an error (in httpd error log file:
    "invalid SQL statement". why?
    here is a code from my program,
    assuming: $fields{'sqlString'} = describe student
    $sth = $dbh->prepare($fields{'sqlString'})
    $sth->execute;
    Thanks Alex
    null

    Matt Surico (guest) wrote:
    : Alex Korneyev (guest) wrote:
    : {snip}
    : : General Question.
    : : describe command in Oracle will display a specified table's
    : : definition.
    : : Now, I have a CGI program that will execute any SQL
    statement
    : : that has to do with tables on Oracle Database.
    : : i.e. select , update, insert, delete. Now when I tried
    : : describe student, i got an error (in httpd error log file:
    : : "invalid SQL statement". why?
    : : here is a code from my program,
    : : assuming: $fields{'sqlString'} = describe student
    : : $sth = $dbh->prepare($fields{'sqlString'})
    : : $sth->execute;
    : : Thanks Alex
    : "describe" is a SQL*Plus command, not a SQL command. Other
    : SQL*Plus commands are column, spool, ttitle, etc...
    : If the Oracle user by which you execute the CGI above has
    access
    : to the data dictionary, you can issue the following command:
    : SELECT column_name, nullable, data_type, data_length
    : FROM dba_tab_columns
    : WHERE table_name = 'STUDENT'
    : AND owner = '{fill in the owner name in CAPS}'
    : If the Oracle user in your CGI doesn't have full access to the
    : data dictionary, you or the DBA could minimally grant SELECT on
    : DBA_TAB_COLUMNS to that user.
    : Hope that helps!
    : Matt Surico
    : Oracle 7.3 Certified DBA
    Thanks, that helps.
    Speaking of permissions. How do i set permissions for a user?
    acctually add user? for testing my CGI i am using orcl database
    with scott/tiger permissions. How do i view user's permissions?
    Also, I have this weird problem. Well I know the anser to it,
    but i need a way to go around it. Here it goes.
    Assuming following:
    alextable = (fname char (20), lname char(20))
    If I do the following from within SQL/Plus
    insert into alextable values('Alex','Was Here');
    then select * from alextable, i can see it. BUT if i do the same
    thing from CGI, I won't see, until i quit SQL/Plus. But if i
    issue the same command from CGI script and then do "select"
    statement, I will see the changes from SQL/Plus and CGI levels.
    I know that some databases use that as a "Rollback" feature.
    Is ther anyway to modify, maybe user permissions, or something
    else,so i would be able to see changes right away, no matter
    where i make them.
    thanks
    alex
    null

  • Sql statement from abap query

    is there any chance to get the sql statement (not program) from any abap query created via SQ01?
    I can get the code of program that generated by system, but I cannot get pure sql statement.
    any answer will be appreciated

    I see no parameters, and in the abstract that SQL ought to work.
    However, I halfway suspect that either User, Users, Password, or pass is a reserved word and somebody is getting confused. Try renaming your columns and table...

Maybe you are looking for