Skip to Content
0
Former Member
Dec 19, 2006 at 09:40 AM

hi regarding native SQL statements

22 Views

Hi Experts,

i am trying to fetch data from the non sap system by connecting the non sap data base, i want to fetch 5 fields from the ORD table which is non sap table by using native SQL. when i am trying to fetch it goes to dump

could u please suggest me how to fetch the data.

following is the sample code

DATA: go_manu TYPE REF TO zcl_manuscm.

CREATE OBJECT go_manu.

data: begin of it_ord occurs 0,

id(12) type c,

source_id(12) type c,

early_avl type sy-datum,

late_avl type sy-datum,

dest_id(12) type c,

end of it_ord.

data: wa_ord like it_ord.

data lv_fdate type sy-datum.

data lv_tdate type sy-datum.

select-options: s_fdate for sy-datum.

go_manu->connect( ).

lv_fdate = s_fdate-low .

lv_tdate = s_fdate-high .

EXEC SQL.

open ord_cursor for select id, source_id, late_avl, early_avl, dest_id

from ord where late_avl = :lv_fdate ;

endsql.

do.

exec sql.

fetch next ord_cursor into :wa_ord-id, :wa_ord-source_id, :wa_ord-late_avl, :wa_ord-early_avl, :wa_ord-dest_id

endsql.

if sy-subrc <> 0.

exit.

endif.

append wa_ord to it_ord.

enddo.

exec sql.

close ord_cursor.

endexec.