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

how to get data from MS-ACCESS table from other server to SAP

Hi,

How to get the data from non-sap server MS-ACCESS table data into SAP.

I am able to connect non-sap MDB server successfully but no able to extract the same.

IF con-header IS INITIAL OR con-handle = -1.

CREATE OBJECT con 'ADODB.Connection'.

IF NOT sy-subrc = 0.

EXIT.

ENDIF.

CREATE OBJECT REC 'ADODB.Recordset'.

IF NOT sy-subrc = 0.

EXIT.

ENDIF.

ENDIF.

  • MDB connetion infomations ....

CONCATENATE 'Provider=' '''Microsoft.Jet.OLEDB.4.0''' ';'

INTO SQL.

CONCATENATE SQL 'Data Source=' '''C:\Ford_Connect.mdb''' ';'

INTO SQL.

CONCATENATE SQL 'User ID=' '''administrator''' ';'

INTO SQL.

CONCATENATE SQL 'Password=' '''ROUTER''' ';'

INTO SQL.

CONCATENATE SQL 'Mode=' '''Share Deny None'''

INTO SQL.

  • MDB connection ...

CALL METHOD OF CON 'Open'

EXPORTING #1 = SQL.

*

till this point is ok.

when i tried to execute below statements then i am getting sy-subrc ne 0.

Please advise.

  • Query (insert) statement ...

SQL = 'insert into test values('.

CONCATENATE SQL '''A''' ',' '''1''' ')' INTO SQL.

  • Query run ...

CALL METHOD OF REC 'Open'

EXPORTING #1 = SQL

#2 = CON

#3 = '1'.

  • Query (select) statement ...

SQL = 'select * from erp_out'.

  • Query run ...

CALL METHOD OF REC 'Open'

EXPORTING #1 = SQL

#2 = CON

#3 = '1'.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 06, 2010 at 03:35 PM

    check it once........

    REPORT YGECICI MESSAGE-ID 00

    No Standard Page Heading

    Line-Size 200

    Line-Count 65.

    INCLUDE Ole2incl.

    DATA: Con TYPE Ole2_Object,

    Rec TYPE Ole2_Object.

    DATA SQL(1023).

    DATA: BEGIN OF SPL OCCURS 0,

    VAL(1023),

    END OF SPL.

    DATA: BEGIN OF I1 OCCURS 0,

    F1 TYPE I ,

    F2(10),

    F3(10),

    END OF I1.

    IF Con-Header IS INITIAL OR Con-Handle = -1.

    CREATE OBJECT Con u2018ADODB.Connectionu2019.

    IF NOT Sy-Subrc = 0.

    EXIT.

    ENDIF.

    CREATE OBJECT REC u2018ADODB.Recordsetu2019.

    IF NOT Sy-Subrc = 0.

    EXIT.

    ENDIF.

    ENDIF.

    • MDB Connetion Infomations u2026.

    CONCATENATE u2018Provider=u2019 u201Du2019Microsoft.Jet.OLEDB.4.0u201Du2019 u2018;u2019

    INTO SQL.

    CONCATENATE SQL u2018Password=u2019 u201Du201Du201D u2018;u2019

    INTO SQL.

    CONCATENATE SQL u2018User ID=u2019 u201Du2019Adminu201Du2019 u2018;u2019

    INTO SQL.

    CONCATENATE SQL u2018Data Source=u2019 u201Du2019C:\Mm.Mdbu201Du2019 u2018;u2019

    INTO SQL.

    CONCATENATE SQL u2018Mode=u2019 u201Du2019Share Deny Noneu201Du2019

    INTO SQL.

    • MDB Connection u2026

    CALL METHOD OF CON u2018Openu2019

    EXPORTING #1 = SQL.

    *

    • Query (Insert) Statement u2026

    SQL = u2018Insert Into [Test] Values(u2019.

    CONCATENATE SQL u201Du2019Au201Du2019 u2018,u2019 u201Du20191u201Du2019 u2018)u2019 INTO SQL.

    • Query Run u2026

    CALL METHOD OF REC u2018Openu2019

    EXPORTING #1 = SQL

    #2 = CON

    #3 = u20181u2032.

    • Query (Select) Statement u2026

    SQL = u2018Select * From[Test]u2019.

    • Query Run u2026

    CALL METHOD OF REC u2018Openu2019

    EXPORTING #1 = SQL

    #2 = CON

    #3 = u20181u2032.

    • Selecting MDB Record Into SAP Internal Table u2026

    DO.

    CALL METHOD OF REC u2018Getstringu2019 = SQL

    EXPORTING #1 = u20182u2032 u201CDo Not Modify!

    #2 = 1 u201CDo Not Modify!

    #3 = u2018|u2019 u201CDo Not Modify!

    #4 = u2018|u2019. u201CDo Not Modify!

    IF Sy-SUBRC EQ 0.

    REFRESH SPL. CLEAR SPL.

    SPLIT SQL AT u2018|u2019 INTO TABLE SPL.

    LOOP AT SPL.

    CASE SY-TABIX.

    WHEN 1.

    I1-F1 = SPL-VAL.

    When 2.

    I1-F2 = SPL-VAL.

    WHEN OTHERS.

    I1-F3 = SPL-VAL.

    ENDCASE.

    ENDLOOP.

    APPEND I1. CLEAR I1.

    ELSE.

    EXIT.

    ENDIF.

    ENDDO.

    • Result Writing u2026

    LOOP AT I1.

    WRITE: AT /1(10) I1-F1,

    AT (10) I1-F2, AT (20) I1-F3.

    ENDLOOP.

    • Connetion Close & Destroy

    FREE OBJECT Con.

    FREE OBJECT Rec.

    and also check the following function modules

    MSACCESS_STRUCT_EXPORT_RFC

    POPUP_FOR_DEST_AND_DBNAME

    PS_MATERIAL_RUE_VIA_ACCESS

    PS_MATMELDUNGEN_MSACCESS

    PS_ZEITRUECKMELDUNGEN_MSACCESS

    STRUCTURE_EXPORT_TO_MSACCESS

    TABLE_CONVERT_FOR_MSACCESS

    TABLE_EXPORT_TO_MSACCESS

    TABLE_EXPORT_TO_MSACCESS_RFC

    TABLE_EXPORT_TO_MSACCESS_RFCFE

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2010 at 12:01 PM

    closed

    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.