Skip to content

SAP — ALV toolbar

Type: sap-grid-toolbar  ·  Package: SAP Activities v1.0.5  ·  Output: List<string>

Presses a button on an ALV grid’s toolbar: the small toolbar attached to the grid (filter, sort, totals, change layout…). Each program puts its own buttons there, so the activity also helps you discover them: if you leave button empty, instead of pressing it returns the list of buttons that ALV has.

It waits for SAP to finish processing and looks up the ALV by its selector, waiting for it to appear up to timeout. Then:

  • With button: it presses the button with that code and waits for SAP to respond. Then it reads the status bar: a message of type E or A makes the activity fail; the rest are written to the log.
  • Without button: it presses nothing. It returns a list with one text per button, formatted as code · text (for example &FIND · Find).
ParameterTypeDefaultDescription
selectorselector—The ALV grid. Ex: "wnd[0]/usr/cntlGRID1/shellcont/shell".
ParameterTypeDefaultDescription
sessionZoanSapSession—SAP session. Omit it inside the body of an SAP — Attach or SAP — Log on.
buttonstring—Button code (&SORT_ASC, &FIND…). Empty: returns the available buttons instead of pressing. Menu buttons (&MB_…) open a menu instead of running an action; to export use SAP — Export ALV grid.
timeoutnumber—Seconds to wait for the ALV grid to appear. Overrides the scope’s elementTimeout. Empty uses the scope value (30 by default); 0 fails on the first try. Decimals allowed.

Without button, returns a List<string> with the ALV’s buttons, one per item and in toolbar order, formatted as code · text (for example &FIND · Find; the text may be empty for icon-only buttons). If the ALV has no buttons, the list is empty.

When pressing a button it does not return a value.

MessageCause and fix
SAP GUI error when pressing the buttonThe ALV has no button with that code. List the ones it does have by leaving button empty.
Component '…' does not exist in the SAP session. Waited … s for it to appear. The current screen is … dynpro … (transaction …). …The element did not appear in time. The message says which screen the session is on: it is almost always a different one than expected (a dialog in front, a step that didn’t happen). If the screen is slow, raise timeout.
SAP replied [E …]: …After the action, SAP showed an error (E) or an abort (A) in the status bar. The text is SAP’s.

Plus the errors common to all activities.

First, discover which buttons the ALV has (once, while building the flow):

SAP ALV Toolbar selector = "wnd[0]/usr/cntlGRID1/shellcont/shell" → output: buttons
Log message = string.Join(" | ", buttons)

Then press the one you need:

SAP ALV Toolbar selector = "wnd[0]/usr/cntlGRID1/shellcont/shell" button = "&SORT_ASC"