‎2006 Aug 25 8:18 AM
Hi all,
My requirement is:
Read all of data from table SYSCAT.TABLES for all OBJECTNAME and TYPE = "N",
Assumption:
OBJECTNAME is in the table LT_OBJECTNAME.
I must write a native SQL to get these data; I dont know how to write this native SQL? Could you give a solution?
Thanks a lot, Andrew
‎2006 Aug 25 8:21 AM
Hi
You can check the below native sql code..to get an idea...
Regards,
Raj
DATA: BEGIN OF wa,
c_locid(3),
c_locname(50),
c_locstate(5),
END OF wa.
EXEC SQL.
CONNECT TO 'RAJ' AS 'V'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'V'
ENDEXEC.
*- Get the data from MS-SQL Server
EXEC SQL.
open C1 for
select
loc_id,
loc_name,
loc_state
from ho_loc_mast
ENDEXEC.
DO.
EXEC SQL.
FETCH NEXT C1 into :wa-c_locid, :wa-c_locname, :wa-c_locstate
ENDEXEC.
IF sy-subrc = 0.
PERFORM loop_output.
ELSE.
EXIT.
ENDIF.
ENDDO.
EXEC SQL.
CLOSE C1
ENDEXEC.
ENDFUNCTION.
&----
*& Form LOOP_OUTPUT
&----
Output
----
FORM loop_output .
WRITE: /5 wa-c_locid, 10 wa-c_locname, 65 wa-c_locstate.
CLEAR wa.
ENDFORM. " LOOP_OUTPUT
‎2006 Aug 25 8:32 AM
Hi Rajasekhar,
Thank you for this solution.
Just now I change the program you provide to match my requirement, but I find I dont know the fields name of the table SYSCAT.TABLES, Do you know how to know that? or using which tool in the R/3 to know that?
Thanks , Andrew
‎2006 Aug 25 8:36 AM
Hi,
You need to check on the system this table is located.
Or try the SQL command which gives table fields of ur table...in native sql...
Raj
‎2006 Aug 25 8:40 AM
Hi Raj,
If I using SQL command to get fields name, but how to get type of these field?
Thanks, Andrew