Skip to Content
author's profile photo Former Member
Former Member

Connecting to database

Hi,

Is it possible to connect to another database from SAP.

Thanks.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Oct 03, 2005 at 06:35 PM

    Yes, it can be done by setting the enteries in DBCON table

    and following is the example

    FORM connect_hris_database.

    IF p_werks = 'ZDCF'.

    SELECT SINGLE * FROM dbcon WHERE con_name = 'SQL_CFMAX2_HRIS_CF'.

    IF sy-subrc NE 0.

    WRITE:/ 'Create Database connect String in DBCON'.

    WRITE: 'SQL_CFMAX2_HRIS_CR'.

    EXIT.

    ENDIF.

    EXEC SQL.

    CONNECT TO 'SQL_CFMAX2_HRIS_CF'

    ENDEXEC.

    ELSEIF p_werks = 'ZDCR'.

    SELECT SINGLE * FROM dbcon WHERE con_name = 'SQL_CFMAX2_HRIS_CR'.

    IF sy-subrc NE 0.

    WRITE:/ 'Create Database connect String in DBCON'.

    WRITE: 'SQL_CFMAX2_HRIS_CR'.

    EXIT.

    ENDIF.

    EXEC SQL.

    CONNECT TO 'SQL_CFMAX2_HRIS_CR'

    ENDEXEC.

    ELSEIF p_werks = 'ZDCC'.

    SELECT SINGLE * FROM dbcon WHERE con_name = 'SQL_CFMAX2_HRIS_CC'.

    IF sy-subrc NE 0.

    WRITE:/ 'Create Database connect String in DBCON'.

    WRITE: 'SQL_CFMAX2_HRIS_CC'.

    EXIT.

    ENDIF.

    EXEC SQL.

    CONNECT TO 'SQL_CFMAX2_HRIS_CC'

    ENDEXEC.

    ENDIF.

    IF sy-subrc <> 0.

    WRITE:/ 'CAN NOT OPEN DATABASE'.

    EXIT.

    ENDIF.

    ENDFORM. " connect_hris_database

    I hope this helps

    Jagraj

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.