2005 Aug 16 11:32 AM
can i read SQL tables using my ABAP Programming in SAP.
if so how pl. quote with some example.
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.
2005 Aug 16 11:38 AM
2005 Aug 16 2:24 PM
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.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |