cancel
Showing results for 
Search instead for 
Did you mean: 

Log onto SAP CRM system via VBA

Former Member
0 Kudos

Hi all and apologies if I'm in the wrong forum. I've been using the function RFC_READ_TABLE to read data from R3 via an Access database for a while now. I now have to branch out and read data from CRM but I am not having much luck. The problem seems to be that I can't login to the CRM system the same way that I am currently logging into R3. Here is a snippet of what I am currently doing.

Function LogOnR3() As Boolean
 
Set R3 = CreateObject("SAP.Functions")
 
R3.Connection.ApplicationServer = UsrInfo.lServer
R3.Connection.System = UsrInfo.lSystem
R3.Connection.Client = UsrInfo.lClient
R3.Connection.User = UsrInfo.lUser
R3.Connection.Password = UsrInfo.lPassWord
R3.Connection.Language = UsrInfo.lLang
R3.LogLevel = 9
 
SysStr = SysCmd(acSysCmdSetStatus, "Logging on to SAP R/3...Functions")
If R3.Connection.Logon(0, UsrInfo.lSilent)  True Then
    MsgBox ("Could not log on")
    UsrInfo.lStatus = "Logged Off"
    SysStr = SysCmd(acSysCmdClearStatus)
    Exit Function
End If
 
 
LogOnR3 = True
UsrInfo.lStatus = "Logged On"
End Function

All of the UsrInfo variables are populated prior to this log on function. If I enter all the details for the R3 system then it works perfectly. If I enter all the details for the CRM system, it will not login unless I provide my R3 password. So it is logging on the the R3 system, even though I am providing the CRM system, server, client, etc and then I can't read any of the CRM tables. How do I login to CRM.

Essentially I am trying to read information from the tables CRMD_ORDERADM_H, CRMD_ORDERADM_I, IBIB, IBIN, etc but it seems that because I'm logged into the R3 system instead I can't read these tables. Does the function RFC_READ_TABLE even exist in CRM, I don't have the access to look it up?

Alternatively, is there tables in R3 that show all the details of a business transaction, ibase, etc, that I could use instead so I don't have to login to CRM. For example, I can read data from the view IAOM_CRM_AUFK but this does not provide me with all the information that I'm looking for. I have a very limited knowledge of CRM and SAP.

Any help would be greatly appreciated.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi, normal , login a SAP server need application server, system number, system ID, SAP user, password, language.

And you can also check if all the connection info you use is available by a SAP GUI. According your system info, you can create a login point in SAP GUI, and to check if you can login the CRM by SAP GUI. Maybe there is some network or user license problem.

stephenjohannes
Active Contributor
0 Kudos

RFC_READ_TABLE is a very bad idea and a security risk.

In CRM we generally approach reading data at a logical level on the busines object unless we are searching for data. For business transactions review this wiki for some ideas:

http://wiki.sdn.sap.com/wiki/display/CRM/funktions+crmd_activity_h

I'm used to working with folks wanting to get CRM data from their external systems, so I would not let those guys who I work with use RFC read table, but instead use a standard BAPI or use Z-BAPI(standard bapi wrapped in a Z-function module called to make life simpler for them). If you have a CRM ABAP developer at your place, ask them to help you. If not, if you explain your business scenario(what are you trying to get out of CRM). I can give you a few ideas.

The other problem with RFC_READ_TABLE is that if you are ever audited for security, you are going to fail that audit big time, by using that function module.

Take care,

Stephen

Former Member
0 Kudos

Thank you both for you help.

zhenglin gu

Here is my situation at the moment. I won't provide the actual values but you should be able see what is going on.

R3.Connection.ApplicationServer = R3 Server
R3.Connection.System = R3 System
R3.Connection.Client = R3 Client
R3.Connection.User = My User Name
R3.Connection.Password = My R3 Password
R3.Connection.Language = "EN"
R3.LogLevel = 9

This logs in fine.

R3.Connection.ApplicationServer = CRM Server
R3.Connection.System = CRM System
R3.Connection.Client = CRM Client
R3.Connection.User = My User Name
R3.Connection.Password = My "CRM" Password
R3.Connection.Language = "EN"
R3.LogLevel = 9

This fails saying my username or password is invalid.

R3.Connection.ApplicationServer = CRM Server
R3.Connection.System = CRM System
R3.Connection.Client = CRM Client
R3.Connection.User = My User Name
R3.Connection.Password = My "R3" Password
R3.Connection.Language = "EN"
R3.LogLevel = 9

This logs in but from what I can tell it's logging into the R3 system as none of the CRM tables are available.

Are there any other connection parameters that need to be set also?

zhenglin gu & Stephen Johannes

I agree that RFC_READ_TABLE is not that great and have come up with many issues using it, including tables that have too many fields and it overflows the return structure. I've got around this issue by limiting the fields that I actually want returned. I also agree with the security issue as well. I just find that it is more flexible for me to returning all the data that I may need to retrieve.

I'm happy to use a BAPI instead if I can get all the info but it will have to be a standard BAPI, I would never get any help from any of our ABAP programmers as they are all consultants and want the earth for any changes. When looking for the CRM tables that I would need on the net, I came across the BAPI's CRM_ORDER_READ, CRM_ORDER_CREATE, etc. These may be useful as apposed to using the rfc.

At one stage, a few years back when the company was a bit more lenient, I had access to the transactions se37 and bapi in the test system. I don't have access to them now. Is there an online alternative to these transactions that shows the standard FM and BAPI's.

Either way though, my issue is I can't access the CRM system at all. If I can get it to log on correctly then I can go from there.

Former Member
0 Kudos

hi, as I known, CRM also have RFC_READ_TABLE

For your problem, please aware that not only the user info is different when you login CRM, the sys info is also different when you login CRM, compare to login ERP.

CRM is a respecitive server to ERP, so the IP, system code, system number can be different.

In additional, the RFC_READ_TABLE is not a very strong FM to fetch data, because it has a lengh limit on the reture structure, too large structure can't be fetch. And the table which is too large record is a poor performance to return.