2008 Mar 07 7:03 AM
Hi all,
i want to insert some records into SQL table but not SAP database table. This table is only present in SQL database &
not present in SAP database.
i want to write a program in SAP to update the SQL table(not present in SAP database). is it possible?
if yes, plz give me the query for inserting records into SQL table.
Regards
2008 Mar 07 7:16 AM
Hi,
you want to work with an internal table, right?
Or where is the other table you want to update?
Regards
Nicole
Hi all,
i want to insert some records into SQL table but not SAP database table. This table is only present in SQL database &
not present in SAP database.
i want to write a program in SAP to update the SQL table(not present in SAP database). is it possible?
if yes, plz give me the query for inserting records into SQL table.
Regards
2008 Mar 07 7:16 AM
Hi,
you want to work with an internal table, right?
Or where is the other table you want to update?
Regards
Nicole
2008 Mar 07 7:41 AM
Thanks yar.
other table is present in SQL database but not in SAP database.
2008 Mar 12 1:38 PM
Hello,
working on the same issue:
Try this:
*----
DATA : Begin Of XY Occurs 1000,
id(15) TYPE C,
Name(50) TYPE C,
ArtNr(50) TYPE C,
lieferant TYPE I,
End Of XY.
*----
*----
Fill this internal Table with the SAP-Table
*----
*----
START Connection to your Database
EXEC SQL.
Connect TO 'TEST_FH'
ENDEXEC.
IF SY-SUBRC EQ 0.
EXEC SQL.
Set Connection 'TEST_FH' " <-- this is defines with TCode dbco
ENDEXEC.
IF SY-SUBRC EQ 0.
Else.
" OUT_Msg = '... won't connect'.
Exit.
EndIf. " Else IF SY-SUBRC EQ 0
Else.
" OUT_Msg = 'Error at Set Connection Test_FH'.
Exit.
EndIf. " IF SY-SUBRC EQ 0
ENDE Connection to your Database
*----
*----
START Insert your table XY to an external database
Loop AT XY.
Try.
EXEC SQL.
INSERT INTO stoff
(id, name , artnr, lieferant)
VALUES
( :XY-ID, :XY-Name, :XY-ArtNr, :XY-Lieferant )
ENDEXEC.
COMMIT WORK AND WAIT. " <=== Maybe VERY important
CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
Concatenate 'Table-INSERT: ' error_text Into error_text.
MESSAGE error_text TYPE 'I'.
ENDTRY.
ENDLoop. " Loop AT XY
END Insert your table XY to an external database
*----
*----
START: Clear Connection
EXEC SQL.
DISCONNECT 'TEST_FH'
ENDEXEC.
END : Clear Connection
*----
Hope it works
Best wishes
Frank
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |