cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a transaction STMS by an excel macro?

Former Member
0 Kudos

Hello,

I don't know much about excel macro and I have to make a transaction STMS by using it. I try to call RFC but it does not work. Someone can help me ?


	Dim oCtrl As Object
	Dim oLogonCtrl As Object
	Dim cn As Object
	Set oCtrl = CreateObject("SAP.Functions")
	Set oLogonCtrl = CreateObject("SAP.Logoncontrol.1")
	Set cn = oLogonCtrl.NewConnection
    
	cn.user = "foo"
	cn.password = "pass"
	cn.client = "700"
	cn.HostName = "hostname"
	cn.SystemNumber = 44
	If cn.Logon(0, True) = True Then
		Set tp = oCtrl.Add("SXPG_COMMAND_EXECUTE")
		tp.Exports("COMMANDNAME") = "stms"
		tp.Exports("TARGETSYSTEM") = "G50"
		tp.Exports("STDOUT") = "X"
		tp.Exports("STDERR") = "X"
		tp.Exports("ADDITIONAL_PARAMETERS") = "G50K900004 G50 100"
		result = tp.Call
	 Else
		MsgBox "Connection failed!"
		Exit
	End if

Message was edited by:

Dennis Lan

Message was edited by:

Dennis Lan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I found the solution :

[code]

Sub Transport()

'Log in

Dim ObjSapFunc As Object

Dim ObjLogCtrl As Object

Dim ObjConnection As Object

Set ObjSapFunc = CreateObject("SAP.Functions")

Set ObjLogCtrl = CreateObject("SAP.Logoncontrol.1")

Set ObjConnection = ObjLogCtrl.NewConnection

ObjConnection.user = "toto"

ObjConnection.password = "pass"

ObjConnection.client = "100"

ObjConnection.HostName = "tutu"

ObjConnection.SystemNumber = 45

If ObjConnection.Logon(0, True) = False Then

MsgBox (sapConnection.IsConnected)

End

End If

Set ObjSapFunc.Connection = ObjConnection

'Transport

Dim codeReturn As String

Dim output As String

Dim msgReturn As Object

Set tp = ObjSapFunc.Add("SXPG_COMMAND_EXECUTE")

tp.Exports("COMMANDNAME") = "MY_TRANSPORT"

'MY_TRANSPORT is external command that I created

'it contains the beginning of the command tp (tp import) and

'it will be concatenated with ADDITIONAL_PARAMETERS

'To create it, use the transaction SM69

tp.Exports("ADDITIONAL_PARAMETERS") = "G50K900004 G50 client100 pf=
tutu\sapmnt\trans\bin\your_profile_file.PFL"

'You can find the parameter transdir in the profile file

'(your_profile_file.PFL) of

'SAP systeme in transport environment (transdir =
$(SAPTRANSHOST)\sapmnt\trans\)

result = tp.Call

codeReturn = tp.Imports("EXITCODE")

'Log off

ObjConnection.Logoff

Set ObjConnection = Nothing

Set oLogonCtrl = Nothing

Set ObjSapFunc = Nothing

End Sub

[/code]

Message was edited by:

Dennis Lan

Message was edited by:

Dennis Lan