I. Linking SQL Server database
Execute the transaction code DBCO, click the New Entry button, fill in the information as shown
The connection information here is close to the SQL Server connection string, but the parameter names are slightly different. Specify the host IP, database name.
Second, link DB2 database
Execute the transaction code DBCO, click the New Entry button, fill in the information as shown
The connection information appears to be more direct, namely the database name, port number, host IP address.
Third, link Oracle database
Execute the transaction code DBCO, click the New Entry button, fill in the information as shown
The connection information is cryptic, you must install the Oracle Client on the SAP application server, and then set up the connection, and here the connection information is specified in accordance with the connection name.
In order to prevent garbled, we should also add the following parameters after linking information: ZHS16GBK
The format is as follows: ORCL.WORLD:ZHS16GBK
Iv. Linked MaxDB Database
Execute the transaction code DBCO, click the New Entry button, fill in the information as shown
MaxDB is SAP's own database, which is a connection created by default in the NetWeaver Developer version
accessing external databases
1. Example: SAP system access to PeopleSoft database
*&----------------------------------------------------------------------------------------------------- &*
*& Defining Constants &*
*&------------------------------------------------------------------------------------------------------ &*
CONSTANTS:CNS_YGJK TYPE C LENGTH VALUE ' Hr9dev '.
* * Open Connection
EXEC SQL.
CONNECT TO:CNS_YGJK
Endexec.
Get Personnel data
TRY.
EXEC SQL performing pf_get_rs.
SELECT Mandt,
ZID,
Otype,
Infty,
Zupdate,
OPERA,
Zdata
Into:wa_hr01-mandt,
: Wa_hr01-zid,
: Wa_hr01-otype,
: Wa_hr01-infty,
: Wa_hr01-zupdate,
: Wa_hr01-opera,
: Wa_hr01-zdata
From Z00HRJZLCH01
WHERE sap_get = ' '
Endexec.
* * Processing of personnel data
IF it_hr01[] is not INITIAL.
LOOP at It_hr01 to Wa_hr01.
EXEC SQL.
UPDATE z00hrjzlch01
SET sap_get = ' X '
WHERE Mandt =: Wa_hr01-mandt
and ZID =: Wa_hr01-zid
Endexec.
IF SY-SUBRC = 0.
Updating ERP database tables
EXEC SQL.
COMMIT
Endexec.
MODIFY z00hrjzlch01 from Wa_hr01.
COMMIT work.
ENDIF.
Endloop.
ENDIF.
* * Close Connection
EXEC SQL.
Disconnect:cns_ygjk
Endexec.
* * Get exception
CATCH Cx_sy_native_sql_error into Cl_exec_ref.
EXIT.
CATCH cx_sql_exception into Cl_sqlerr_ref.
EXIT.
Endtry.
*&---------------------------------------------------------------------*
*& Form Pf_get_zz
*&---------------------------------------------------------------------*
* Organize incremental data
*----------------------------------------------------------------------*
FORM Pf_get_zz.
APPEND Wa_hr02 to It_hr02.
EndForm.
Transaction code: DBCO View, existing connection of SAP system
The program uses a connection " Hr9dev. World, double-click the line as shown:
Edit TNS file in SAP bottom Oracle database, generally by basis configuration, configuration path:dir_orahome->network->admin->tnsnames.ora; after configuration we can use transaction code: AL11 See if the configuration is correct, AL11 view the connection "Hr9dev. World "Specific configuration
Implement SAP link external database and read routines using transaction code DBCO