구슬이네 IT & Media / IT 와 미디어를 바라봅니다




참고문서

http://arraybox.com/entry/ASP%EC%97%90%EC%84%9C-SAP-Remote-Function-Call
 

<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim sapConnection, functionCtrl
Dim retcd
Dim theFunc
Dim returnFunc
Dim docs
Dim T_PERSON
Dim i
Dim pernr

'SAP 접속 함수
Sub ConnectSAP() 
 Set sapConnection = CreateObject("SAP.Logoncontrol.1") 
 Set sapConnection = sapConnection.NewConnection 
 
 sapConnection.System = "KKK" 
 sapConnection.ApplicationServer = "erperp"
 sapConnection.SystemNumber = 00
 sapConnection.user = "USERID" 
 sapConnection.Password = "USERPASS" 
 sapConnection.client = "300" 
 sapConnection.language = "3"
 sapConnection.Codepage = "8500"  
 
 retcd=sapConnection.Logon(0,true) 
 If RetCd = False Then 
  Response.write "SAP Logon Failed. retcd="  & retcd
  Response.End 
 end if 
 
 Set functionCtrl = CreateObject("SAP.Functions") 
 functionCtrl.Connection = sapConnection 
End Sub

'SAP 접속 종료 함수
Sub CloseSAP()
 functionCtrl.Connection.logoff
 Set sapConnection = Nothing
 Set functionCtrl = Nothing
End Sub

ConnectSAP()


functionCtrl.Connection = sapConnection
Set theFunc = functionCtrl.Add("FUNC_NAME") 
' 인자를 넣을 때는 아래와 같이
'theFunc.exports("PERNR") = "00014657 "
returnFunc = theFunc.Call

If returnFunc = True Then         

 Set T_PERSON = theFunc.Tables ( "T_SEND")
 For i = 1 To T_PERSON.ROWCOUNT
  
  Response.write T_PERSON(i,"PERNR") & " - "
  Response.write T_PERSON(i,"ENDDA") & " - "
  Response.write T_PERSON(i,1) & " - "
  Response.write T_PERSON(i,2) & " - "
  Response.write "<BR>"

 Next

End if


Set theFunc = Nothing

CloseSAP()
%>
<br><br>
RFC호출 페이지입니다.