Skip to Content
avatar image
Former Member

describe statement in abap

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

11 Answers

  • avatar image
    Former Member
    Apr 18, 2006 at 12:17 PM

    Hi rajeev,

    1. simple.

    2. go get the record count in internal table,

    3. just copy paste

    REPORT abc.

    data : t001 like table of t001 with header line.

    select * from t001 into table t001.

    describe table t001.

    write :/ ' Number of records ' , sy-tfill.

    regards,

    amit m.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2006 at 12:17 PM

    HI rajeev,

    just use like this..

     data : len type i
     data a(10) type c.
     data type(1).
     DESCRIBE FIELD a LENGTH len type typ.

    now the len will have length which is 10 and typ will have the type which is 'c'.

    just the basic use

    there are lot of other additional options for this statement..

    regards

    satesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2006 at 12:18 PM

    Rajeev,

    DESCRIBE is used to get the number of filled lines of an internal table.

    Ex:DATA: N TYPE I,

    ITAB TYPE TABLE OF I.

    ...

    CLEAR ITAB.

    APPEND 36 TO ITAB.

    DESCRIBE TABLE ITAB LINES N.

    The result is stored in N.

    see ABAP documentation for more help..

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2006 at 12:19 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2006 at 12:19 PM

    Hi Rajeev,

    Just check this link to SAP Help, which gives you the various uses of DESCRIBE statement.

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3145358411d1829f0000e829fbfe/content.htm

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm

    Hope this helps.

    Regards,

    SP.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2006 at 12:22 PM

    Hi Rajeev

    This statment is used to find attributes of internal table at run time that were not available statically.

    The syntex is

    DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].

    <l> gives number of records in itab

    <n> Initial size of the table and

    <k> give itab type i.e standard(T), sorted (S) and (H) Hashed table

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 24, 2006 at 07:05 AM

    Hai

    Try with this Document

    Return attributes of a field

    - DESCRIBE FIELD f.

    Return attributes of an internal table

    - DESCRIBE TABLE itab.

    Determine distance between two fields

    - DESCRIBE DISTANCE BETWEEN f1 AND f2 INTO f3.

    Return attributes of a list

    - DESCRIBE LIST NUMBER OF LINES lin.

    - DESCRIBE LIST NUMBER OF PAGES n.

    - DESCRIBE LIST LINE lin PAGE pag.

    - DESCRIBE LIST PAGE pag.

    Describe table itab lines v_lines.

    If itab is initial.

    <……….>

    Endif.

    tables : mara.

    data : itab like mara occurs 0 with header line.

    data : v_lines type i.

    parameters : p_mtart like mara-mtart.

    select * from mara into table itab

    where mtart = p_mtart.

    describe table itab lines v_lines.

    if not itab[] is initial.

    write : / v_lines.

    endif.

    Thanks & Regards

    Sreenivasulu P

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 06, 2007 at 12:46 PM

    hi rajeev,

    see this ll give some idea.

    this is the i have develop for only

    &----


    *& Report ZAS_HOLLYWOOD

    *&

    & description ticket to hollywood----


    *& use of DESCRIBE is shown below

    *& Author the don

    &----


    REPORT ZAS_HOLLYWOOD.

    data itab type table of mara with header line.

    data: lv_lines type i.

    parameter s_matnr like mara-matnr.

    select * from mara into corresponding fields of table itab

    where matnr = s_matnr.

    describe table itab lines lv_lines.

    loop at itab.

    write : / itab-matnr,lv_lines,itab-ernam.

    endloop.

    reward if helpful

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 06, 2007 at 12:46 PM

    hi rajeev,

    see this ll give some idea.

    this is the i have develop for only

    &----


    *& Report ZAS_HOLLYWOOD

    *&

    & description ticket to hollywood----


    *& use of DESCRIBE is shown below

    *& Author the don

    &----


    REPORT ZAS_HOLLYWOOD.

    data itab type table of mara with header line.

    data: lv_lines type i.

    parameter s_matnr like mara-matnr.

    select * from mara into corresponding fields of table itab

    where matnr = s_matnr.

    describe table itab lines lv_lines.

    loop at itab.

    write : / itab-matnr,lv_lines,itab-ernam.

    endloop.

    reward if helpful

    anuj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 06, 2007 at 03:51 PM

    Hi rajeev dv,

    much more powerful are the OO classes

    cl_abap_structdescr

    cl_abap_elemdescr

    with methods like ->get_ddic_field_list or ->get_components or =>describe_by_data_ref, just to give a few names.

    SAP uses these classes for automatic building the field catalog in ALV object model; compare class CL_SALV_COLUMNS.

    You can get the same information as with DESCRIBE statement but most is much easier. Because many info you can get with DESRIBE ... INTO itab only and this very difficult to interpret.

    Regards,

    Clemens

    Regards

    Add comment
    10|10000 characters needed characters exceeded