Tips & Tricks

 

It is recommended to analyze the scripts in the example workbooks (these workbooks may not work in the client SAP system as each system can be differently customized).


Parallel work with MS Excel when EasyInput script is already running

Normally when an Excel macro or an EasyInput script is running one cannot work with other MS Excel windows. This is because separate excel windows share the same Excel engine called Excel instance. The user can however run a second Excel instance. To start it follow the steps:

1. Click with right mouse key the Excel icon on Windows taskbar. Excel context menu should appear.

2. Press Alt key and keep it. Click with left mouse the Excel icon on the context menu. Do not release the Alt key! Keep it pressed!

3. When popup window appears, confirm that you want to start new Excel instance. And that is it!

 

Chaining several transactions/ functions in one EasyInput script

One can connect two recordings/ scripts of the same type (TR/ GS/ FM) in one EasyInput script. The only prerequisite is that transaction IDs (TR)/ recording IDs (GS)/ function IDs (FM) of the two scripts to join must differ. The joining is done by assigning the same script ID on the EI_Script_XX worksheet (where XX stands for TR, GS or FM). If one needs to join several scripts of various types (TR/GS/FM), then using VBA macros is required (see example templates with macros).

 

Reading data from any SAP table with the use of function module RFC_READ_TABLE.

Easy input can read data from any SAP table/ database view. This can be achieved using function script based on RFC_READ_TABLE function module. When no DELIMITER is set, EasyInput will cut the retrieved data and put separate fields into separate columns of the data sheet. See the example EI_FM_Ex_READ_ANY_SAP_TABLE.

 

Using SPECIAL COMMANDS in SAP GUI scripting

In SAP GUI scripting/transaction scripts it is sometimes useful to use loops over script lines (as opposite to loops over data lines, that are served by level/ order pairs) or to paste the data from the copied to the buffer by the script. To do so, special commands are used.

 

Using EasyInput in your own Visual Basic for Applications programs (VBA macros)

For external use the following macros (API) are prepared. One can write VBA macros in the EasyInput sheets calling this predefined application Interface:

Macro

Description

Sub API_BCC_EI_SetScript(ByRef pWorkbook As Workbook, pScript As String)

Chooses the EasyInput script

pScript - Script ID or Script name to be set

Function API_BCC_EI_GetScriptName(ByRef pWorkbook As Workbook, Optional ByVal pError As Boolean = True) As String

Returns the selected script name

Function API_BCC_EI_GetScriptID(ByRef pWorkbook As Workbook, Optional ByVal pError As Boolean = True) As String

Returns the selected script ID

Sub API_BCC_EI_SetRunType(ByRef pWorkbook As Workbook, pRT As String)

Sets the run mode
pRT - Run mode- possible values:
TR

TE

TN

AR

AE

AN

Function API_BCC_EI_GetRunType(ByRef pWorkbook As Workbook) As String

Returns the selected run mode (TR,TE,TN,AR,AE,AN)

Sub API_BCC_EI_SetDataSheet(ByRef pWorkbook As Workbook, pDataSheet As String)

Sets the data sheet
pDataSheet - Name of the data sheet on the EI_Config worksheet

Function API_BCC_EI_GetDataSheet(ByRef pWorkbook As Workbook) As String

Returns the name of the data sheet

Function API_BCC_EI_RunScript(ByRef pWorkbook As Workbook) As Boolean

Runs the set EasyInput script

Sub API_BCC_EI_ClearLevelOrder(ByRef pWorkbook As Workbook)

Clears the data sheet level/order columns

Sub API_BCC_EI_ClearResultMessages(ByRef pWorkbook As Workbook)

Clears the data sheet result messages

Sub API_BCC_EI_ClearDataArea(ByRef pWorkbook As Workbook)

Clears the data sheet data area

Sub API_BCC_EI_SetConfig(ByRef pWorkbook As Workbook, ByVal pParam As String, ByVal pValue As String)

Sets the chosen configuration setting.

WARNING: This procedure does not check the passed value in any way! The programmer must ensure, that the passed value is correct.

pParam – depicts the configuration parameter to be set

pValue is the passed parameter value

Function API_BCC_EI_GetConfig(ByRef pWorkbook As Workbook, ByVal pParam As String) As String

Gets the chosen configuration setting.

pParam – depicts the configuration parameter to be set

Sub API_BCC_EI_SetALO(ByRef pWorkbook As Workbook)

Fills level/order columns on the data worksheet.

Function API_BCC_EI_getLastDataSheetRow(ByRef pWorkbook As Workbook) As Long

Returns last row on the data sheet

Sub API_BCC_EI_SetSAPUser(ByRef pWorkbook As Workbook, ByVal pUser As String)

Sets SAP user ID for script calling (if not set, then on execution a popup window will appear to ask for user ID)

Sub API_BCC_EI_SetSAPPass(ByRef pWorkbook As Workbook, ByVal pPass As String)

Sets SAP password for script calling (if not set, then on execution a popup window will appear to ask for password). Password will be stored only for the amount of time set in general settings. Password can be deleted by calling this function again with an empty string as password. 

GetConfig/SetConfig pParam most important values (for full list see EI_Config worksheet, column A):

          DS_START       - data sheet start row (number >=10)

          DS_END         - data sheet end row (optional, number >=11)

          PREV_DOUBLE    - prevent double posting (X)

          BACKUP_BEFORE  - save backup data sheet before script start (X)

          BACKUP_AFTER   - save backup data sheet after script end (X)

          DEBUG_DET_MESG - debug mode detailed messages (X)

          SKIP_IND       - character used as skip indicator (skipped if put on data sheet, can be left empty)

          SKIP_DELTA     - setting telling that the skip indicator will be used, or all values will be transfered (X)

          WAIT_TIME      - wait time between consecutive transaction call (used sometimes to slow down the EI) (number in ms)

          SUBLEVEL_REQUIRED - setting telling whether the sublevel (level more than 0) is required e.g. for FI documents (X)

          SAP_GUI_USE    - setting telling whether SAP_GUI should be used for the script (needed for some transactions) (X)

          LOOP_BACK      - setting telling that loops over sublevels should be done backwards (useful for some transaction scripts) (X)

          AUTO_LEVEL_ORDER - auto recognition of data lines (about setting of level/order) (X)

          MESSAGE_TYPES_PRESENTED   - message types that should be presented on data sheet (*=ALL, string e.g. AESIW)

          MESSAGE_VALUE_READ_STRING - string to get value from the message back (ID-Nr-Param-Column)

          RESULT_CHECK_STRING       - setting telling how result checking is verified (E|S-Type[-Id][-Nr])

          CONFIG_PASS    - string for config pass (can be left emty)

 

Important! If the data sheet is visible (Visible = True), then when running macro run script the sheet will be activated (shown). If it is hidden (Visible = False), this activation will not be performed.

Important! To call any of the EI API macros the automation object should be constructed and its method should be used (see the example below).

 

An example of own VBA macro using EasyInput API:
Public MyEIMacro

  Dim addIn As COMAddIn

  Dim automationObject As Object

  Dim pWorkbook As Workbook

  Set addIn = Application.COMAddIns("EasyInput")

  addIn.Connect = True ' force add-in start

  Set automationObject = addIn.Object

  Set pWorkbook = ActiveWorkbook

 

 ' prepare and run the first script

  Sheets("EI_Data").Range("Y12:AS5000").ClearContents

  automationObject.API_BCC_EI_SetConfig pWorkbook, "DS_START", "10"

  automationObject.API_BCC_EI_ClearResultMessages pWorkbook

  automationObject.API_BCC_EI_ClearLevelOrder pWorkbook

  automationObject.API_BCC_EI_SetScript pWorkbook, "CI"

 

  If automationObject.API_BCC_EI_RunScript(pWorkbook) = True Then

    ' only run second macro if connection successfull

    automationObject.API_BCC_EI_ClearLevelOrder pWorkbook

    automationObject.API_BCC_EI_SetConfig pWorkbook, "DS_START", "12"

    automationObject.API_BCC_EI_SetScript pWorkbook, "CB"

    automationObject.API_BCC_EI_RunScript pWorkbook

  End If

  ' read data from EI_Data worksheet and write result to EI_Example worksheet

  CalculateReport

End Sub

 

Important! On the EI_ScriptName worksheet one can define user’s macros, that will be called before and/or after the EI Script run. This allows connecting own development and extending EasyInput functionalities.

 

Force EasyInput Add-in Start

EasyInput is normally loaded only when needed (when the user presses the Start button). One can however force EasyInput add-in loading via VBA command:

Application.COMAddIns("EasyInput").Connect = True

 

See EasyInput forum to get more information on EasyInput.