Question:
can someone explain by example how at-selection screen differs from at user-command.
Answer:
at-selection
there is no such event as "at-selection".
However, there is "at selection-screen" and "at line-selection".
I presume in this context you are looking "at line-selection".
AT User-Command.
Whenever user presses a function key this event is triggered. You can even code your custom buttons on the custom toolbar that will get executed whenever user clicks on it. Beyond that, it functions exactly the same as AT Line-selection.
AT Line-selection.
Is primarily used to further drill down within an interactive report.
SAP has ample examples in the help and most basic ABAP programming books provide it. Here are some demo examples.
1)DEMO_LIST_AT_LINE_SELECTION Line Selection with PICK
2)DEMO_LIST_AT_PF Allowing Function Key Selection
3)DEMO_LIST_AT_USER_COMMAND The AT USER-COMMAND Event
If you do a drop down on "DEMO*" within SE38 you should see a huge list of demo/sample programs.