Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

reports

Former Member
0 Likes
683

what is the main difference between AT PF & AT USER-COMMAND ?

please give reply.

5 REPLIES 5
Read only

Former Member
0 Likes
656

AT USER-COMMAND event is for handling user defined function.Say for eg when the user clicks the Pushbutton in the list you can do further processing for this action in AT USER-COMMAND event.

AT PF-STATUS is outdated/obsolete so dont think/worry about it.But it is used for handling function keys in the list.

Read only

Former Member
0 Likes
656

hi

AT PFnn

statements.

These event blocks are executed when the user chooses the corresponding function key. The position of the cursor in the list is irrelevant.

If you use these event blocks at all, it should only be for temporary test versions.

In production programs, you should only use AT USER-COMMAND with a dialog status of your own to assign function codes to function keys. When you use your own interfaces, the system displays a function text explaining what the function does. This does not happen when you use AT PFnn event blocks.

regards,

madhu

Read only

Former Member
0 Likes
656

you might want to use F1 help in SAP. they explain it in very short terms, probably better than i can but still i try.

at PF is an event which is beeing thrown just on LISTS while the ok_code is like PF## where ## stands for a number between 01 and 24.

at user command is a more generic event which is beeing thrown on every dynpro (be aware that selection screens and lists are technically dynpros as well).

SAP help says that even on lists you better use at user-command.

Probably thats why i didnt hear from at PF till today, i just dont need it.

Read only

Former Member
0 Likes
656

AT USER-COMMAND - 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 .

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.

AT PFn - 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.

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.