02-14-2008 5:44 AM
hi,
I am currently in a project implementing SAP for a cement manufacturing company. Here we have a VB .exe file which takes parameters and return values. now we need to connect this to application to SAP R/3 to pass data to that application and access the data from that .exe file.
Note: we don't have any source code for that vb .exe file its a third party software.
Its an very urgent one....
please guide me how to do it with all steps.
Any material please pass to mskn09@gmail.com
Thanks in advance.
02-14-2008 3:01 PM
Dear Sriharitha
Pl go through the below link this may help you
http://help.sap.com/saphelp_47x200/helpdata/en/72/90fd343603c95ee10000009b38f844/frameset.htm
Regards
Kesava
02-19-2008 5:09 AM
02-19-2008 11:17 AM
Dear
This is the code when we call BAPIs from Visual Basic .
This example illustrates a BAPI call in Visual Basic using the BAPI ActiveX Control. This report uses the service BAPI BapiService.MessageGetDetail(), to display the short text and the long text of error messages.
'
' Visual BASIC 5.0
' Copyright SAP AG Walldorf Juli 1998
'
' read a message short and longtext using the BAPI
' BAPI_MESSAGE_GETDETAIL of the object BapiService
' constant for user identification
Const cstrMUsrClient As String = "000"
Const cstrMUsrUser As String = "MYUSER"
Const cstrMUsrPassword As String = "MYPASS"
Const cstrMUsrLanguage As String = "EN"
' constant for system identification
Const cstrMSysSystem As String = "P45"
Const cstrMSysMessageServer As String = "p45main.wdf.sap-ag.de"
Const cstrMSysGroupName As String = "PUBLIC"
'
' constant values for reading message texts
Const cstrMMsgId As String = "SX"
Const cstrMMsgNumber As String = "101"
Const cstrMMsgVariable1 As String = "var1"
Const cstrMMsgVariable2 As String = "var2"
Const cstrMMsgVariable3 As String = "var3"
Const cstrMMsgVariable4 As String = "var4"
Const cstrMMsgLanguage As String = "DE"
' other constant
Const cstrMPathfile As String = "D:\A\saptext.rtf"
' password for login in R/3
Dim strMUsrPassword As String
' react on button START
Private Sub cmdMsgStart_Click()
' define object for BAPI ActiveX control
Dim oBAPICtrl As Object
' define object for R/3 logon control
Dim oLogonCtrl As Object
' business object BapiService
Dim boBapiSercice As Object
' for BAPI: BapiService.MessageGetDetail
Dim oMsgReturn As Object
Dim oMsgText As Object
Dim intCounter As Integer
' to open the file you need a file channel
Dim intChannel As Integer
' create BAPI ActiveX control object
Set oBAPICtrl = CreateObject("SAP.BAPI.1")
' create R/3 logon control object
Set oLogonCtrl = CreateObject("SAP.Logoncontrol.1")
' connection object is part of the BAPI ActiveX Control object
Set oBAPICtrl.Connection = oLogonCtrl.NewConnection
' fill logon parameters for system to use
oBAPICtrl.Connection.System = txtSysSystem
oBAPICtrl.Connection.MessageServer = txtSysMessageServer
oBAPICtrl.Connection.GroupName = txtSysGroupName
' fill logon parameter for user
oBAPICtrl.Connection.Client = txtUsrClient
oBAPICtrl.Connection.User = txtUsrUser
oBAPICtrl.Connection.Password = strMUsrPassword
oBAPICtrl.Connection.Language = txtUsrLanguage
' user logon to R/3
If oBAPICtrl.Connection.Logon(frmStart.hWnd, False) = False Then
MsgBox "R/3 connection failed"
End
End If
' create BAPI service object
Set boBapiService = oBAPICtrl.GetSAPObject("BapiService")
' call method of BapiService
boBapiService.MessageGetDetail id:=txtMsgId, _
Number:=txtMsgNumber, _
Language:=txtMsgLanguage, _
Textformat:=cboMsgTextformat.Text, _
message:=strMsgShorttext, _
Return:=oMsgReturn, _
Text:=oMsgText
' fill field in form
' If txtMsgShorttext = "" Then
' MsgBox "No message read"
' End If
' user logoff from R/3
oBAPICtrl.Connection.Logoff
' error handling check if RETURN parameter is not empty and react
If oMsgReturn.Value("TYPE") <> "" Then
lblReturn.Caption = oMsgReturn.Value("TYPE") + _
". " + _
oMsgReturn.Value("ID") + _
". " + _
oMsgReturn.Value("NUMBER") + _
". " + _
oMsgReturn.Value("MESSAGE") + _
". " + _
oMsgReturn.Value("MESSAGE_V1") + _
". " + _
oMsgReturn.Value("MESSAGE_V2") + _
". " + _
oMsgReturn.Value("MESSAGE_V3") + _
". " + _
oMsgReturn.Value("MESSAGE_V4") + _
". " + _
oMsgReturn.Value("LOG_NO") + _
". " + _
oMsgReturn.Value("LOG_MSG_NO")
Else
' fill form fields
txtMsgShorttext = strMsgShorttext
arrayText = oMsgText.Data
' handling of non RTF texts
If cboMsgTextformat.Text <> "RTF" Then
For intCounter = 1 To oMsgText.RowCount
If intCounter = 1 Then
rtfMsgLongtext.Text = arrayText(intCounter, 1)
Else
rtfMsgLongtext.Text = rtfMsgLongtext.Text + _
Chr(13) + Chr(10) + _
arrayText(intCounter, 1)
End If
Next intCounter
End If
' handling of RTF texts
If cboMsgTextformat.Text = "RTF" Then
' save text as rtf file
intChannel = FreeFile
Open cstrMPathfile For Output As #intChannel
For intCounter = 1 To oMsgText.RowCount
Print #intChannel, arrayText(intCounter, 1)
Next intCounter
Close #intChannel
rtfMsgLongtext.LoadFile cstrMPathfile, rtfRTF
End If
End If
End Sub
I hope this will be helpful to you
Best Regards
Pramendra
02-20-2008 10:39 AM
Hi,
It is difficult to run the VB file from SAP. If you some ho run the VB program also then how do you capture the output of the program back to SAP. I think The vB program needs to be altered to meet the requirement for this.
02-21-2008 4:42 AM
Hi,
I have done a similar thing, which connects sp to vb exe, yours might be a weighbridge or weigh feeder thing, right?,
use the function module ws_execute to run the vb exe..
It might be storing the values in some text file or so...read from that text file the return value using fm ws_read or so..
i have done a similar thing for a cement industry in a weighbridge case.
for any help pls reply...
regards
Ranjith, SAP Group, KELTRON
02-21-2008 1:01 PM
Hi,
Thanks for posting . I have the same problem what u have specified in the posting. that is i have take the readings from the weigh bridge through a VB.exe file (Cement manufacturing company). if u have the code for that weight bridge please mail be to mskn09@gmail.com.
really i will be thank ful if you send me the code for weigh bridge to execute.
please help me in this regard
-haritha
02-25-2008 6:41 AM
form grosswt .
refresh itab3.
clear itab3.
Executing VB EXE file to get the weight from weigh bridge
call function 'WS_EXECUTE'
exporting
DOCUMENT = ' '
CD = ' '
COMMANDLINE = ' '
inform = 'X'
cd = 'C:\SAPWEI'
program = 'C:\sapwei\MyVB.exe'
STAT = ' '
WINID = ' '
OSMAC_SCRIPT = ' '
OSMAC_CREATOR = ' '
WIN16_EXT = ' '
EXEC_RC = ' '
IMPORTING
RBUFF =
EXCEPTIONS
FRONTEND_ERROR = 1
NO_BATCH = 2
PROG_NOT_FOUND = 3
ILLEGAL_OPTION = 4
GUI_REFUSE_EXECUTE = 5
OTHERS = 6
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Fetching Value from VB text file
call function 'WS_UPLOAD'
exporting
CODEPAGE = ' '
filename = 'C:\sapwei\w1.txt'
FILETYPE = 'ASC'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
tables
data_tab = itab3
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
loop at itab3.
v1 = itab3-num.
pgrwt = v1.
endloop.
message 'Save Gross Weight' type 'S'.
endform. " grosswt