Como requisito, es necesario tener definida en el sistema local la conexión a la BD del sistema remoto. Esto se hace a través de la transacción DBACOCKPIT. Una vez configurada y probada, podemos probar el siguiente código:
report yjr_remote_db.
parameters: p_table type dd02l-tabname.
*----------------------------------------------------------------------*
* CLASS lc_remote_db DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lc_remote_db definition.
public section.
class-methods main.
private section.
class-data: result_tab type ref to data.
class-methods display.
endclass. "lc_remote_db DEFINITION
*----------------------------------------------------------------------*
* CLASS lc_remote_db IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lc_remote_db implementation.
method main.
data: sql type ref to cl_sql_statement,
result type ref to cl_sql_result_set,
err type ref to cx_sql_exception,
connec type ref to cl_sql_connection,
cols type adbc_column_tab,
dref type ref to data,
query type string.
create data result_tab type standard table of (p_table).
try.
connec = cl_sql_connection=>get_connection( con_name = 'REMOTE_DB' ).
catch cx_sql_exception into err.
message err type 'I' display like 'E'.
endtry.
create object sql
exporting
con_ref = connec.
query = `SELECT * FROM ` && p_table.
try.
result = sql->execute_query( query ).
result->set_param_table( itab_ref = result_tab
* corresponding_fields = cols
).
if result->next_package( ) > 0.
display( ).
endif.
catch cx_sql_exception into err.
message err type 'I' display like 'E'.
endtry.
endmethod. "main
method display.
data alv type ref to cl_salv_table.
data err type ref to cx_salv_msg.
field-symbols <table> type any table.
assign result_tab->* to <table>.
try.
cl_salv_table=>factory(
importing r_salv_table = alv
changing t_table = <table> ).
alv->display( ).
catch cx_salv_msg into err.
message err type 'I' display like 'E'.
endtry.
endmethod. "display
endclass. "lc_remote_db IMPLEMENTATION
start-of-selection.
lc_remote_db=>main( ).
Referencias:
- Documentación interna de SAP: ABAP - Reference -> Processing External Data -> ADBC - ABAP Database Connectivvity
3 comentarios:
Really Good article.provided a helpful information.keep updating...
E-mail marketing company in india
This information really worth saying, i think you are master of the content and thank you so much sharing that valuable information and get new skills after refer that post.
Journal Of Computer Science
Journal Of Management
Plagiarism service
Engineering Journal
Journal Of Chemistry
Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well I really get amazed to read this. It's really good.
I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!.
mobile phone repair in Fredericksburg
iphone repair in Fredericksburg
cell phone repair in Fredericksburg
phone repair in Fredericksburg
tablet repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair Fredericksburg
iphone repair Fredericksburg
cell phone repair Fredericksburg
phone repair Fredericksburg
Publicar un comentario