10-15-2007 6:06 AM
HI all,
Can anyone please help me, in finding the name of the function module, which checks, if a table exists in DD02L. But the output should be only in the form of sy-subrc. I mean, if such a table exists, sy-subrc should be 0.
I am entering the table name in selection screen. So, I have to check if it exists or not. If it does, sy-subrc should be 0, else i'll display a popup.
I tried with RS_TABLE_LIST_CREATE. But it navigates directly to SE16 , if a table exists (Which is what I dont want).So, for this, which function module should I use ?
Kindly Suggest.
Regards ,
Neha.
10-15-2007 6:26 AM
Is it a must that you <b>have to</b> use a FM? Write your logic like this:
data: v_count type i.
select count(*) from dd02l
into v_count
where tabname = <your selection-screen input>
and as4local = 'A'. "Entry was activated
if v_count > 0.
"means table exists and is active in the database
else.
" means table doesn't exist as an Active table in the database
" call your popup here
endif.
Don't forget to reward points.
Cheers,
Sougata.
10-15-2007 6:13 AM
you can check the fm DD_EXIST_TABLE
or use select query on the table DD02L.
regards
shiba dutta
10-15-2007 6:15 AM
use this function module.
<b>SCPR_DB_TABLE_EXIST</b>
<b>DD_EXIST_TABLE</b>
where status field say like this.
<b>A Activity was generated or activated</b> use this.
L Lock entry
N Entry was edited but not activated
S Preveious active,backup copy
T Temporary version
Message was edited by:
Amit Singla
10-15-2007 6:15 AM
Hi,
Goto table TADIR. give the table name in object name. check whether you are getting the output. if yes, then use a select query on this table.
you can use object id also to restrict the database hit,
Regards,
Niyaz
10-15-2007 6:25 AM
The problem is, I only have to use a Function module for it, Cant directly write a query on dd02l or any other table.
10-15-2007 6:29 AM
<<The problem is, I only have to use a Function module for it, Cant directly write a query on dd02l or any other table. >>
and why is that??
10-15-2007 6:40 AM
Hi Neha,
U can use the Function Module 'DB_EXISTS_TABLE' for checking the table exists in data base or not.
It will return a parameter subrc 0 when table exists other wise returns 4.
Hope this will be helpfull in resolving the problem.
Regards,
Kasinath Babu
10-15-2007 6:41 AM
Hello Neha,
With SCPR_DB_TABLE_EXIST and DD_EXIST_TABLE you can find out whether the table is existing or not. After providing the table name to these functions just check the sy-subrc value. If its zero, you have your table available...
Thanks and Regards
Joe
10-15-2007 6:42 AM
You are not using the function modules i suggested???
it giving the result what you want ( DD_EXIST_TABLE)
in status hardcord 'A' always.
reward if useful..
Amit Singla
10-15-2007 6:26 AM
Is it a must that you <b>have to</b> use a FM? Write your logic like this:
data: v_count type i.
select count(*) from dd02l
into v_count
where tabname = <your selection-screen input>
and as4local = 'A'. "Entry was activated
if v_count > 0.
"means table exists and is active in the database
else.
" means table doesn't exist as an Active table in the database
" call your popup here
endif.
Don't forget to reward points.
Cheers,
Sougata.
10-15-2007 6:37 AM
You can try to ctach the system error:
try.
select a,b from (tabname).
catch cx_sy_sql_error.
perform error_handling.
end-try.
10-15-2007 6:44 AM
Thanks all, for answering my question and helping me. I am rewarding points to all those who've posted.