Application Development 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: 

SQL Table

Former Member
0 Kudos

can i read SQL tables using my ABAP Programming in SAP.

if so how pl. quote with some example.

2 REPLIES 2

andreas_mann3
Active Contributor
0 Kudos

Hi,

look F1 for <b>EXEC SQL</b> and that link:

Andreas

0 Kudos

Connect to the server which must be configured in table DBCON. Check OSS as there is note for this as the DNS name must be updated.

Define a connection parameter called P_NAME.

PARAMETER: P_NAME type DBCON-CON_NAME.

select-options: s_matnr for mara-matnr.

*--- Check if connection has already been opened

EXEC SQL.

SET CONNECTION :P_NAME

ENDEXEC.

IF SY-SUBRC <> 0.

*--- Connection not yet opened

EXEC SQL.

CONNECT TO :P_NAME

ENDEXEC.

*--- Can't open connection

IF SY-SUBRC <> 0.

MESSAGE E025(Q2).

ENDIF.

ENDIF.

  • Selects the data

loop at s_matnr.

EXEC SQL PERFORMING APPEND_DATA. "This is a form

SELECT extable1.product,

extable1.uom

INTO

:I_MAT-LCLCODE,

:I_MAT-UOM

FROM extable1

WHERE extable1.product = :S_MATNR-LOW

ENDEXEC.

ENDLOOP.

form append_data.

append i_mat.

endform.