Get Example source ABAP code based on a different SAP table
Possible Database Connections When AB_SQL , Native SQL, or AMDP is used in an ABAP program, the database interface> uses a database connection> of the current work process> to access a database. Every work process always has a standard connection to the standard database. In addition, secondary connections to other databases or database schemas can be defined. Service connections can also still be opened to the standard database. ITOC
Standard Connection Each AS ABAP work process always has a standard connection to the standard database> and this connection cannot be closed. It is shared by all ABAP_ISESSNS >. If the standard connection is used, the work process acts as a database user> to which the ABAP database schema> is assigned.
By default, AB_SQL >, Native SQL>, and AMDP> all use the standard connection to access the ABAP database schema of the standard AS ABAP database.
In all places where a database connection can be specified explicitly in ABAP, the standard connection can also be specified using the predefined name DEFAULT>.
Example ABAP Coding
Specifies the standard connection explicitly in AB_SQL . It would not be necessary to specify the connection in the statements DELETE> and INSERT>. The statement COMMIT CONNECTION>>, however, makes an explicit database commit> possible on the standard connection. ABEXA 01182 ABAP_EXAMPLE_END
Secondary Connections A secondary connection is a database connection to a secondary database> defined by an entry in the database table DBCON> >. The table key CON_NAME> of the table DBCON> is the name of the secondary connection in uppercase letters under which it can be specified explicitly in ABAP. The remaining columns describe the properties of the secondary connection, such as the database system>, the database user>, and the physical address. Entries in the database table DBCON> are created and modified using the central DBA Cockpit> tool. If the DBA Cockpit tool is not available in a system for some reason, transaction DBCO>> can be used instead, but this requires some expertise. DBCON> should not be accessed in any other way. More specifically, the table DBCON> cannot be displayed using the Data Browser> tool. The database user name> of the database user> used to log on the database connection to the database system is part of the definition of a secondary connection in the table DBCON>. An AB-SQL statement that uses a secondary connection accesses only that database schema> that is assigned to this user. A secondary connection must be specified explicitly before it can be used in AB_SQL > or Native SQL>. If possible, the secondary connection is opened for the current work process or an existing inactive secondary connection with the same name is reused. Secondary connections cannot be used in AMDP>. Secondary connections between an AS ABAP that has a SAP HANA database as its standard database and other non-SAP HANA secondary databases are now obsolete. SAP HANA Smart Data Access (SDA)> should be used instead (see SAP Note 2626805>). In SDA, secondary databases are addressed from the SAP HANA database using special qualified names or by using virtual tables. If a SAP HANA database is used as a standard AS ABAP database, ABAP programs can use these names via the standard connection. This is only possible using AMDP and Native SQL, since no qualified names can be specified in AB_SQL .
Latest notes:
Secondary connections can address any number of database schemas> in the standard database> or databases other than the standard database as secondary databases>. An AS ABAP can, for example, access the SAP HANA database of an independently operated SAP HANA appliance.
The prerequisite for a secondary database > is that it must be a database system supported by SAP. Only this system has software for AB_SQL and Native SQL access as a shared library.
If the secondary database> is a database system other than the standard database of the current AS ABAP, the Database Shared Library (DBSL) provided for this database by SAP and client software provided by the database vendor must be installed here before an access using a secondary connection from the table DBCON >. Information about creating the DBCON> entry and installing the additional software is described in the standard SAP Notes for every supported database system.
Once all reads on secondary database, except SAP HANA databases, have been replaced by SDA>, Shared Libraries (DBSL) are no longer required. ABAP_HINT_END
Example ABAP Coding
Use of a secondary connection in AB_SQL . The connection can be entered, and a check is made to see whether it exists in the database table DBCON>>. If no secondary connection exists in AB_SQL , the uncatchable exception DBSQL_UNKNOWN_CONNECTION> is raised. ABEXA 01183 ABAP_EXAMPLE_END
Service Connections to the Standard Database A service connection is a database connection defined by specifying its name in an ABAP program. The name of a service connection is R/3*name> and consists of the prefix R/3*> in uppercase letters and a definable case-sensitive name> that can have between 1 and 26 alphanumeric characters. A service connection is always a database connection to the standard database and inherits all settings from the standard connection automatically. When a service connection is requested in AB_SQL >, Native SQL>, or AMDP>, it is opened for the current work process if possible or an existing inactive service connection with the same name is reused.
Latest notes:
The freely definable name> is not associated with the entries in the database table DBCON> and is used only to identify a service connection. Hence, specifying a database connection from the database table DBCON> for name> does not mean that this database connection is used.
Service connections to the standard SAP database are useful for performing operations in a database LUW> that are independent of the LUW of the standard connection. It should be noted that the current isolation level> is responsible for determining whether a read from a database LUW can access data modified in a different database LUW, before this data is committed using a database commit.
Like secondary connections, service connections add to the number of open connections of the current work process. There can be a maximum of 16 open connections, including the standard connection itself. ABAP_HINT_END
Example ABAP Coding
Use of a service connection called R/3*service_conn> in AB_SQL . ABEXA 01184 ABAP_EXAMPLE_END