Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Bapi Access from ASP Page

Former Member
0 Likes
790

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
724

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

3 REPLIES 3
Read only

Former Member
0 Likes
725

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

Read only

0 Likes
724

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

Read only

0 Likes
724

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