Special script commands

 

In EI  scripts one can use special commands (they can be put in script object/program column) to influence SAP GUI script execution.

Command

Value column meaning (field value column, or data transferred via WriteData from the data worksheet)

Description

LOOP_BEGIN

Number of loop iterations (1 to N)

Starts script block that will be processed several times (the number of iterations depends on the value column/ WriteData value).

Loops can be nested to the second level (see below):
LOOP_BEGIN

   … some script lines

  LOOP_BEGIN

    … some script lines

  LOOP_END

    … some script lines

LOOP_END

 

Important: When within the internal loop to the standard loop index value, the index of internal loops is added e.g.:
1-2 (one internal loop level) or 2-3-5 (nested loops).

This facilitates making lines within the internal loop dependent on iteration number.

LOOP_END

When empty, the loop is processed normally. Not empty value (e.g. X) breaks the loop processing.

Ends script block that that will be processed several times

Important: using the field value one can force to break the loop processing (e.g. after an error in one of the loop lines).  

PASTE

Specifies cell address starting from which the paste operation will be executed:

Worksheet!Address (e.g. EI_Data!AB20) or
Address (e.g. AB20)

Allows pasting data to excel copied previously to the buffer by the script. Important: Can be used only in SAP GUI scripts.

 

Possible use of special commands is reading data from ALV grids. See an example script reading data from SE16 transaction with ALV grid below:

Script object

Script function

Field name

Field value

Field desc

Transfer type

Read/write column

Ignore errors

GUIScriptName

SE16.VBS







("wnd[0]/tbar[0]/okcd")

text = &&


/nse16





("wnd[0]")

sendVKey 0







("wnd[0]/usr/ctxtDATABROWSE-TABLENAME")

text = &&

DATABROWSE-TABLENAME

BKPF


WriteData

AA


("wnd[0]/usr/ctxtDATABROWSE-TABLENAME")

caretPosition = 4







("wnd[0]")

sendVKey 0







("wnd[0]/usr/txtMAX_SEL")

text = &&

MAX_SEL

100000





("wnd[0]/usr/txtMAX_SEL")

setFocus

MAX_SEL






("wnd[0]/usr/txtMAX_SEL")

caretPosition = 11







("wnd[0]")

sendVKey 0







("wnd[0]/tbar[1]/btn[8]")

press






X

("wnd[0]/mbar/menu[3]/menu[3]")

select







("wnd[1]/usr/tabsG_TABSTRIP/tabp0400/ssubTOOLAREA:SAPLWB_CUSTOMIZING:0400/radRSEUMOD-TBALV_GRID")

setFocus







("wnd[1]/tbar[0]/btn[0]")

press







("wnd[0]/usr/cntlGRID1/shellcont/shell")

RowCount




ReadData

AB


("wnd[0]/usr/cntlGRID1/shellcont/shell")

ColumnCount




ReadData

AC


LOOP_BEGIN



=ROUND(Y21/32;0)+1





("wnd[0]/usr/cntlGRID1/shellcont/shell")

firstVisibleRow = &&


=IFERROR((RIGHT(Z25;LEN(Z25)-FIND("|";REPLACE(Z25;"-";"|";1))) - 1)*32;)





LOOP_END








("wnd[0]/usr/cntlGRID1/shellcont/shell")

SelectAll







("wnd[0]/usr/cntlGRID1/shellcont/shell")

contextMenu







("wnd[0]/usr/cntlGRID1/shellcont/shell")

SelectContextMenuItemByPosition "0"






("wnd[1]/tbar[0]/btn[0]")

press






X

PASTE



AA11:GZ:10000





("wnd[0]/tbar[0]/btn[12]")

press







("wnd[0]/tbar[0]/btn[12]")

press







("wnd[0]/tbar[0]/btn[12]")

press