Skip to Content
avatar image
Former Member

Opening SAP system using excel macro

Hi,

Kindly guide me how to open and access a SAP sytem using SAP logon pad using a macro in the excel.

I have created a macro in excel for rest of the process by recording it.

First time we log on to the SAP System and after work is completed we log out, but then need to be re-log in to the system for another work sequence using the macro in excel.

Kindly provide me the code

Regards,

Anup

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    May 29, 2010 at 08:45 AM

    Hi Anup,

    I am using in this case, the following code:

    Dim sap As Object
    Dim conn As Object
     
    Set sap = CreateObject("SAP.Functions")
    Set conn = sap.Connection
    conn.System = "SYSTEM"
    conn.client = "123"
    conn.user = "USER"
    conn.Password = "PW"
    conn.Language = "DE"
     
    If conn.logon(0, False) <> True Then
        MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment"
    Else
         . . . 
    End if
    

    Please do not forget: A link in a VBA Project with e.g. SAP: Remote Function Call: COM support 1.0 Type Library

    Regards,

    ScriptMan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      i have to create a mcro to delete purchase ordders from SAP.we get a file of the list of PUrchase order and the corresponding line numbers.so using me22n we open the purchase order and then click on the line number press delete and save it..is there any way to make macros since it eats up my 8 hrs of working.

  • avatar image
    Former Member
    May 31, 2010 at 08:50 AM

    Hi Thanks,

    But the solution did not work.

    To Add further information....

    1. We provide access to users in the organisation.

    2. At times there are a lot of changes to be made for a bunch of users.

    3. For this we need to login to each of the users and change some settings and then log out.

    4. After we log out, we need to re-login using logon pad (non-single sign on)

    5. These have to be performed a number of times, hence cannot provide a user name and a password as provided in the coding provided.

    6. Kindly provide us a way in which we can open the log on pad and open a particular system.

    Thanks,

    Anup Nair

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Thomas Bräutigam

      Hi Script,

      am facing the below error while am running the macros

      i.e error -

      RFC_ERROR_PROGRAM

      Message

      Ent

      Please help us to solve this

      Regards

      Karthick.T

  • avatar image
    Former Member
    Jul 06, 2010 at 02:58 PM

    Thanks....

    My query is now solved....

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 20, 2010 at 05:23 PM

    Hi ScriptMan - just curious how to add such a link:

    "Please do not forget: A link in a VBA Project with e.g. SAP: Remote Function Call: COM support 1.0 Type Library"

    Thanks

    Umur

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 14, 2010 at 11:59 AM

    Hi guys.. Hope you can help me out.

    I am want the salesorder details to be displayed in the excel using the BAPI activex control in MS Access.

    I connected to SAP and got some code from internet to get the orderdetails. The problem is I need the

    item quantity and purchase order number also. Here's some code in vba which gives idea what I want to display.

    **************************************************************code*********************************************************************

    Set oSalesOrder = oBAPICtrl.GetSAPObject("SalesOrder", sapSoNumber)

    Indexv = 4

    For Each oItem In oSalesOrder.items

    wsTemplate.Range(cols(3) & Indexv).Value = oItem.material.material

    'wsTemplate.Range(cols(4) & Indexv).Value = oItem.orderedqty 'I need the item quantity here..?

    wsTemplate.Range(cols(1) & Indexv).Value = sapSoNumber

    'wsTemplate.Range(cols(2) & Indexv).Value = oSalesOrder.ponumber ' I need the purchase order number here??

    Indexv = (Indexv + 1)

    Next

    **********************************************************************************************************************************************

    if this method doe snot work then can you give me the code using any different methods like getdetail with full code in vba.?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 25, 2013 at 08:14 AM

    Hi,

    i have to create a macro that could delete the Purchase orders from SAp.we get the file in excel where we have the purchase order number and under that teh item number.so we got to SAP using me22n then put the purchase order and then select the item number press delete and then save it..could you pls help me in making macros..its really urgent

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 21, 2015 at 11:27 AM

    hi:

      Every body, i met an emergent proplem and want to get any help, did anyone can give me some suggestion how i can get all macros already existed in a certain excel tempplate when using sap doi technology, i have already tried class:

    Add comment
    10|10000 characters needed characters exceeded