0
A
回答
2
對於你的任務,你可以使用一個功能模塊(SE37),也可以使用模塊池,或報告(SE38,SE80) 。檢查此報告:
report zinsertdb.
data: oref type ref to cx_root,
p_conex type dbcon_name value 'YOUR_DB_CONNECTION_STRING', " Ask the basis for this
lv_sw type c,
errormessage type string.
data it_mydata type standard table of mara.
start-of-selection.
perform connect.
perform insert_into_db.
perform disconnect.
form connect.
try.
EXEC SQL.
CONNECT TO :p_conex
ENDEXEC.
lv_sw = 'X'.
catch cx_sy_native_sql_error into oref.
lv_sw = space.
errormessage = oref->get_text().
endtry.
endform.
form disconnect.
clear errormessage.
if lv_sw = 'X'.
try.
EXEC SQL.
COMMIT
ENDEXEC.
catch cx_sy_native_sql_error into oref.
errormessage = oref->get_text().
endtry.
endif.
endform.
form insert_into_db.
data wa_mydata like line of it_mydata.
data zcount type i.
select * from mara into corresponding fields of table it_mydata.
if sy-subrc EQ 0.
loop at it_mydata into wa_mydata.
try .
exec sql.
EXECUTE PROCEDURE sp_get_data (IN :wa_mydata-EAN11, IN :wa_mydata-MEINS, OUT :zcount)
endexec.
if zcount eq 0.
exec sql.
INSERT INTO "Your_Database".dbo.[Your_table]
(Field1, Field2, Field3, FieldN)
VALUES (:wa_mydata-matnr,
:wa_mydata-ean11,
:wa_mydata-matkl,
:wa_mydata-meins)
endexec.
lv_sw = 'X'.
endif.
catch cx_sy_native_sql_error into oref.
lv_sw = space.
errormessage = oref->get_text().
endtry.
endloop.
endif.
endform.
希望它有幫助。
1
你不知道你想做什麼。我假設你的意思是你想要將整個SQL表(或其中的某些條目)讀入程序存儲器中?也許你可以在這裏擺脫更多的光線?
如果出現這種情況,則可以簡單地聲明一個內部表,該表的結構中包含數據的SQL表。
DATA: table_name TYPE STANDARD/HASHED/SORTED TABLE OF name_of_sql_table.
FIELD-SYMBOLS <structure> TYPE name_of_sql_table.
SELECT * FROM name_of_sql_table INTO TABLE table_name.
從那裏它只是從內部表中讀取數據。
READ TABLE table_name ASSIGNING <structure> WITH KEY table_key_field(s) = condition(s).
但作爲賈格爾說:小心你的表有多大。
相關問題
- 1. SAP abap循環插入表
- 2. 如何使用SAP ABAP
- 3. ABAP:讀取itab並顯示其值
- 4. 將數據從SAP導出到SQL Server
- 5. 導入SQL Server表到HDFS
- 6. 下拉式SAP ABAP
- 7. 將SAP HANA數據導入到SQL Server中
- 8. SQL Server導入表
- 9. 如何在abap中讀取和打印通用itab?
- 10. 如何導入excel到sql server 2008?
- 11. 如何將數據導入到SAP
- 12. ABAP:循環在<itab>到<wa>其中<cond>
- 13. 動態申報表參數SAP ABAP
- 14. SAP ABAP - 與對照表處理
- 15. 如何將Sql Server 2008數據庫導入到SQL Server 2012中
- 16. 將數據導入到SQL Server表
- 17. 導入訪問2013表到SQL Server
- 18. 導入日期到SQL Server表
- 19. 從Excel導入數據到SQL Server表
- 20. 將xsl導入到SQL Server表中
- 21. 批量導入到SQL Server表
- 22. 如何從SAP表導入數據到Excel表
- 23. ABAP/SAP中XSLT的特性?
- 24. SQL Server:如何導出表
- 25. 將excel文件導入到SAP表格
- 26. SAP/ABAP的時間估計
- 27. SAP ABAP URL大寫字母
- 28. 在SAP ABAP中解析XML
- 29. 導入Excel到SQL Server CE
- 30. 導入Excel到SQL Server 2008
是的。不,也許。也許,也許不是。你能否給我們一個更清晰的畫面,說明你想要做什麼以及你已經嘗試和研究過什麼? – vwegert 2013-02-23 15:56:54
'SELECT * FROM INTO TABLE '?但是,你必須確保這個數據庫表非常小,並且不包含太多的記錄。 –
Jagger
2013-02-24 14:59:34