Using R/3 Transactions Interactively
R/3 transactions are composed of a sequence of screens, into which a user can enter data. An end user enters data into fields on these screens, then the user chooses a button or menu option that possibly leads to another screen. After entering data at the last screen in the sequence, the transaction ends.
Using R/3 Transactions with the Transaction Control
When using the Transaction control, you are using R/3 transactions in Batch Input mode. Note that Batch Input mode is different from the online mode. Not all transactions that are available in online mode are available in Batch Input mode.
When working with the Transaction control you need to specify the transaction you are using, its screens, and the fields you are sending values for. You need to specify similar parameters to those you specify when transferring data into R/3 with Batch Input methods. For example, to enter a value into a field, you need to provide field name and field value. To execute a function, you need to use the constant BDC_OKCODE, representing the command field on the screen.
An easy way to obtain the code of a transaction, its screens and all the necessary fields is by recording a Batch Input transaction (Transaction SHDB). Using transaction SHDB you record the desired transaction while going through its screens and entering data as an end user. At the end of the transaction (which ends the recording) the transaction, the screens and the fields you have used appear in a tree hierarchy.
Procedure
Note that the Transaction control always calls the transaction in batch input mode. This means that the external program can send input field values to an R/3 screen, but output field values are not returned. For complete transaction execution, with data transfer in both directions, use the
SAP Automation GUI Library.Also note that no GUI is displayed when you use the Transaction control.
Example
' Create a Transactions collection:
Set transOCX = CreateObject("SAP.Transactions.1")
' Add a Transaction object for the transaction:
Set trans = transOCX.Add("SE11", "DOMAIN")
' Add screens and fields:
Set Screen = trans.Screens.Add
Screen.Program = "SAPMSRD0"
Screen.Number = "0100"
Create the Fields collection.
Set Fields = Screen.Fields
Fields.Add "RSRD1-OBJNAME", "ZTST"
Fields.Add "RSRD1-DOMA", "X"
Fields.Add "BDC_OKCODE", "=ADD"
Set Screen = trans.Screens.Add
Screen.Program = "SAPMSD01"
Screen.Number = "0100"
Set Fields = Screen.Fields
Text = "Testing at " + Str$(Hour(Now)) + ":" + Str$(Minute(Now))
Fields.Add "DD01V-DDTEXT", Text
Fields.Add "DD01V-DATATYPE", "CHAR"
Fields.Add "DD01V-LENG", "10"
Fields.Add "BDC_OKCODE", "/11"
Set Screen = trans.Screens.Add
Screen.Program = "SAPLSTRW"
Screen.Number = "0100"
Screen.Fields.Add "BDC_OKCODE", "/9"
' Use the Logon Control to create a Connection object.
' Assign the Connection object to the Connection property
' of the Transaction collection:
Dim conn as object
Dim locx as object
set locx = CreateObject ("SAP.LogonControl.1")
set conn = locx.NewConnection
set transOCX.Connection = conn
' Call the transaction:
if trans.Call <> true then
MsgBox
" Call failed… "End If
See Also
For more details on using Batch Input programming, see the topic
Data Transfer in the
BC - Basis Programming Interfaces section of the R/3 Library documentation.