Variant 2
AT USER-COMMAND.
Effect
Event in interactive reporting
This event is executed whenever the user presses a function key in the list or makes an entry in the command field .
Some functions are executed directly by the system and thus cannot be processed by programs. These include:
PICK See variant AT LINE-SELECTION PFn See variant AT PFn /... System command %... System command PRI Print BACK Back RW Cancel P... Scroll function (e.g.: P+ , P- , PP+3 , PS-- etc.)
Instead of this functions, you can use the scroll statement in programs.
Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes.
Otherwise, the effect is as for AT LINE-SELECTION ; also, the current function code is stored in the system field SY-UCOMM .
This event is executed whenever the user presses a function key in the list or makes an entry in the command field .
Some functions are executed directly by the system and thus cannot be processed by programs. These include:
PICK See variant AT LINE-SELECTION PFn See variant AT PFn /... System command %... System command PRI Print BACK Back RW Cancel P... Scroll function (e.g.: P+ , P- , PP+3 , PS-- etc.)
Instead of this functions, you can use the scroll statement in programs.
Since many of these system functions begin with "P", you should avoid using this letter to start your own function codes.
Otherwise, the effect is as for AT LINE-SELECTION ; also, the current function code is stored in the system field SY-UCOMM .
Example
DATA: NUMBER1 TYPE I VALUE 20,
NUMBER2 TYPE I VALUE 5,
RESULT TYPE I.
START-OF-SELECTION.
WRITE: / NUMBER1, '?', NUMBER2.
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'ADD'.
RESULT = NUMBER1 + NUMBER2.
WHEN 'SUBT'.
RESULT = NUMBER1 - NUMBER2.
WHEN 'MULT'.
RESULT = NUMBER1 * NUMBER2.
WHEN 'DIVI'.
RESULT = NUMBER1 / NUMBER2.
WHEN OTHERS.
WRITE 'Unknown function code'.
EXIT.
ENDCASE.
WRITE: / 'Result:', RESULT.
After entry of a function code, the appropriate processing is performed under the event AT USER-COMMAND and the result is displayed in the details list.
Variant 3
AT PFn.
Effect
Event in interactive reporting
Here, n stands for a numeric value between 0 and 99.
This event is executed whenever the user presses a function key that contains the function code PFn in the interface definition. The default status for lists contains some of these functions.
Otherwise, the effect is as for the variant AT LINE-SELECTION . The cursor can be on any line.
Otherwise, the effect is as for the variant AT LINE-SELECTION . The cursor can be on any line.
To ensure that the chosen function is executed only for valid lines, you can check the current HIDE information. This variant should be used only for test or prototyping purposes, since the default status is not normally used. Instead, you should set a program-specific status with SET PF-STATUS . This should not contain any function codes beginning with " PF ".
Example
DATA NUMBER LIKE SY-INDEX.
START-OF-SELECTION.
DO 9 TIMES.
WRITE: / 'Row', (2) SY-INDEX.
NUMBER = SY-INDEX.
HIDE NUMBER.
ENDDO.
AT PF8.
CHECK NOT NUMBER IS INITIAL.
WRITE: / 'Cursor was in row', (2) NUMBER.
CLEAR NUMBER.
RELATED POST
AT EVENTS IN LISTS PART ONE
What is SAP and Why do we are in need of It
No comments :
Post a Comment