2009 Oct 10 6:17 AM
Dear All
I am trying to access SAP BAPI through ASP pages. My Source code is as follows :
<%@ Language=VBScript %>
<html>
<head>
<%
DIM oLogonControl
DIM oBapiControl
DIM oConn
DIM oCompanyCode
Dim otabCompanyCodes
Dim oReturn
Dim oCol
Dim oRow
sub Main()
set oBapiControl=CreateObject("SAP.BAPI.1")
set oLogonControl=CreateObject("SAP.LogonControl.1")
set oConn=oLogonControl.NewConnection
oConn.ApplicationServer="aaa.bb.cc.dd"
oConn.System="00"
oConn.Client="190"
oConn.User="XXXX"
oConn.Password="YYYYYYYY"
oConn.Language="EN"
retcd=oConn.Logon(0,true)
Response.Write(retcd)
Response.Write("<BR>")
if(retcd<>true)then
Response.Write("no logon")
stop
else
Response.Write("logon OK")
oBapiControl.Connection=oConn
Set oCompanyCode=oBapiControl.GetSAPObject("CompanyCode")
end if
End Sub
%>
</head>
<body>
<% Call Main() %>
</body>
</html>
The problem is that it is able to logon into the SAP System successfully but as soon as it tries to access the BAPI object , it throws an error
***An internal RFC-Error occurred.***
**Error-key: RFC_ERROR_SYSTEM_FAILURE**
***Description: See RFC trace file or SAP system log for more details***
**cpic-status: ??? Internal State: ???**
can anyone please help me in this ? am i doing something wrong with the code or it is basis rights problem ? what rights and what configuration changes has to be done to access this BAPI ?
kindly share some source code also if i am doing something wrong with the source code.
Solutions would be appreciated.
Thanks and Regards
Prashant Jha
Edited by: Prashant Kr Jha on Oct 10, 2009 7:17 AM
2009 Oct 10 7:42 AM
Dear Prashant ,
please try in following way
functionCtrl.Connection = oConn
'**************************************
'Give the name of RFC Function
'**************************************
Set theFunc = functionCtrl.Add("BAPI_COMPANYCODE_GETLIST")
returnFunc = theFunc.Call
If returnFunc = True Then
'Give the Name of Table parameter in RFC Function
Set docs = theFunc.tables.Item("COMP_CODE")
end if
'**************************************
'Write The Out Put
'**************************************
for i = 1 to docs.rows.count
for each oCol in docs.columns
response.write oCol.value(i)
next
next
Regards,
Ashish Gautam
Dear All
I am trying to access SAP BAPI through ASP pages. My Source code is as follows :
<%@ Language=VBScript %>
<html>
<head>
<%
DIM oLogonControl
DIM oBapiControl
DIM oConn
DIM oCompanyCode
Dim otabCompanyCodes
Dim oReturn
Dim oCol
Dim oRow
sub Main()
set oBapiControl=CreateObject("SAP.BAPI.1")
set oLogonControl=CreateObject("SAP.LogonControl.1")
set oConn=oLogonControl.NewConnection
oConn.ApplicationServer="aaa.bb.cc.dd"
oConn.System="00"
oConn.Client="190"
oConn.User="XXXX"
oConn.Password="YYYYYYYY"
oConn.Language="EN"
retcd=oConn.Logon(0,true)
Response.Write(retcd)
Response.Write("<BR>")
if(retcd<>true)then
Response.Write("no logon")
stop
else
Response.Write("logon OK")
oBapiControl.Connection=oConn
Set oCompanyCode=oBapiControl.GetSAPObject("CompanyCode")
end if
End Sub
%>
</head>
<body>
<% Call Main() %>
</body>
</html>
The problem is that it is able to logon into the SAP System successfully but as soon as it tries to access the BAPI object , it throws an error
***An internal RFC-Error occurred.***
**Error-key: RFC_ERROR_SYSTEM_FAILURE**
***Description: See RFC trace file or SAP system log for more details***
**cpic-status: ??? Internal State: ???**
can anyone please help me in this ? am i doing something wrong with the code or it is basis rights problem ? what rights and what configuration changes has to be done to access this BAPI ?
kindly share some source code also if i am doing something wrong with the source code.
Solutions would be appreciated.
Thanks and Regards
Prashant Jha
Edited by: Prashant Kr Jha on Oct 10, 2009 7:17 AM
2009 Oct 10 7:42 AM
Dear Prashant ,
please try in following way
functionCtrl.Connection = oConn
'**************************************
'Give the name of RFC Function
'**************************************
Set theFunc = functionCtrl.Add("BAPI_COMPANYCODE_GETLIST")
returnFunc = theFunc.Call
If returnFunc = True Then
'Give the Name of Table parameter in RFC Function
Set docs = theFunc.tables.Item("COMP_CODE")
end if
'**************************************
'Write The Out Put
'**************************************
for i = 1 to docs.rows.count
for each oCol in docs.columns
response.write oCol.value(i)
next
next
Regards,
Ashish Gautam
2009 Oct 10 9:33 AM
Dear Ashish
Thanks a lot for sharing the code.
I tried to implement what you have sent.
My page gives me an error at this code
for i = 1 to docs.rows.count
for each oCol in docs.columns
response.write oCol.value(i)
next
next
it gives me an error "Object Required" . Am i doing something wrong ? Please help.
Regards / Prashant
2011 Jan 05 12:27 PM
Ashish
you need define the variable dim i in the "for i = 1 to docs.rows.count" and Dim docs, oCol, i
Hector Enriquez
Surpoint
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |