Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

native SQL

Former Member
0 Likes
555

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 don’t know how to write this native SQL? Could you give a solution?

Thanks a lot, Andrew

4 REPLIES 4
Read only

Former Member
0 Likes
516

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

Read only

0 Likes
516

Hi Rajasekhar,

Thank you for this solution.

Just now I change the program you provide to match my requirement, but I find I don’t 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

Read only

Former Member
0 Likes
516

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

Read only

0 Likes
516

Hi Raj,

If I using SQL command to get fields name, but how to get type of these field?

Thanks, Andrew