Class/Method to check if table exists in SE11 or not?

6.5k views Asked by At

I want to check if a table exists in SE11 or not through ABAP.

Their are some FM's available like "C_TABLE_EXISTENCE".... But i can't use FM's. I want to use or have to use Class and its methods in my software.

Please suggest me, how can i check existence of a table without using any FM. Preferably Class and Method.

4

There are 4 answers

1
Piyush aggarwal On BEST ANSWER

You can use the class cl_rebf_ddic_tabl

It's exists will return you X if the object (Table, Structure or View) exists i SE11

EG:

CALL METHOD cl_rebf_ddic_tabl=>exists
  EXPORTING
    id_name     = [table name]
    id_tabclass = 'TRANSP'  " For table
*    if_noview   = ABAP_FALSE
  receiving
    rf_exists   = yes
    .
0
vwegert On

The official API to check whether a dictionary data type exists is the function module DDIF_NAMETAB_GET. It features a rather comprehensive documentation. Be aware that it will work for various kinds of tables and data structures and make sure you check the DDOBJTYPE.

If for whatever reason (maybe this is a homework assignment..?) you have to restrict yourself to method calls, you can use the RTTI classes (descendants of CL_ABAP_TYPEDESCR) - but be aware that this is a bit more work because you have to ensure that what you got is actually a table. The RTTI classes will return descriptors of any data type, even the internal ABAP runtime types, while DDIF_NAMETAB_GET is restricted to dictionary types.

0
user11095995 On

You should take a look at the function module DD_OBJECT_EXISTS , it will be helpful.

0
Michael Biermann On
  CALL METHOD cl_abap_structdescr=>describe_by_name
    EXPORTING
      p_name = tabname
    EXCEPTIONS
      OTHERS = 1.
  IF sy-subrc <> 0.
    WRITE: `Table ` && tabname && ` does not exist`.
    RETURN.
  ENDIF.

To validate results manually, call SE11 (or SE16, table DD02L).