Google Search - Blog...........

At User-Command Command With Example - ABAP

AT USER-COMMAND

When the user selects the menu item or presses any function key, the event that is triggered is AT USER-COMMAND, and can be handled in the program by writing code for the same. The system variable SY-UCOMM stores the function code for the clicked menu item or for the function key and the same can be checked in the program. Sample code would look like

AT USER-COMMAND.

Case sy-ucomm.
When ‘DISP’.
Select * from sflight.
Write sflight-carrid, sflight-connid.
Endselect.

When ‘EXIT’.
LEAVE.

If GUI status, suppose you have set menu bar for two items and the function code is ‘DISP’ and ‘EXIT’ respectively. If the user clicks the menu item ‘DISPLAY’, then function code ‘DISP’ is stored in the sy-ucomm and whatever is written under the when ‘DISP’, gets executed. This is applicable for EXIT as well.

Sy-lsind for the screen increases when the user clicks the menu item.

Usually you have combination of all the three navigations in your user interface, i.e., you have to create menu bar, assign function code for the function keys and write code to handle all this in addition to handling double clicking.

Things to remember while using all the combinations:

• Sy-lsind increases even if you select menu-item.

• When the user double clicks on particular line, value of sy-ucomm is ‘PICK.

• If you set sy-lsind = 2 for your 4th secondary list, when control is transferred to the 2nd secondary list, all the other lists after 2nd are lost or memory allocated to them is lost.

• Sy-lisel also gives you the value of clicked line but in this case you cannot differentiate between field. To retrieve the exact field, you have to know the field length of each field.

• If you use statement SY-LSIND = 1.

The system reacts to a manipulation of SY-LSIND only at the end of an event, directly before displaying the secondary list. So, if within the processing block, you use statements whose INDEX options access the list with the index SY-LSIND, make sure that you manipulate the SY-LSIND field only after processing these statements. The best way is to have it always at the `as the last statement’ of the processing block.

No comments:

Post a Comment