Application Development 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: 

pf status and user-command

Former Member
0 Kudos

hi

can any one explain me about pf-status and user-command? what is the difference between this two and how to display icons in it.

max reward points for good answer

thanks

alka

8 REPLIES 8

Former Member
0 Kudos

PF-STATUS is used to set the GUI Status of a screen, ie you can control the options on your menu bar, application toolbar, the function keys assigned to various options etc.

Implementing the status for a screen can be done in 2 ways:

1) Create the GUI status using the object list of the program or by using the transaction SE41. Then, assign it to the screen using SET PF-STATUS statement.

2) Create the GUI status by means of forward navigation, ie, use the SET PF-STATUS 'XXX' statement where 'XXX' is the name of the GUI status and double click on it to create it.

Status names can have a maximum of 20 characters.

After assigning a GUI status to a screen, this is inherited to all subsequent screens. In order to have a different status for each of the subsequent screens, you have to set a separate status for each screen.

In transaction SE41,

1) Give the program name and the status name and click on the Create button.

2) Go to 'Function keys' and expand.

3) On top of the save icon type SAVE, on top of the back icon type BACK, on top the the exit icon type EXIT etc ie on top of all the icons that you want to use, type the respective names that you want to give.

Whatever you have typed now becomes the function codes of these icons and can be used in your program.

For example you have a screen 100.

In the 'Element list' tab of the screen, give "ok_code" as the name where "OK" is the type of screen element. Activate screen.

The flow logic for the screen looks like this:

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

PROCESS AFTER INPUT.

MODULE USER_COMMAND_0100.

Create the modules STATUS_0100 and USER_COMMAND_0100 in the main program by simply double clicking on them.

The code for these modules can be something like this:

MODULE status_0100 OUTPUT.

SET PF-STATUS 'Example'. "Example is the name of the GUI status

ENDMODULE.

MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'SAVE'.

"call a subroutine to save the data or give statements to save data.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE.

Go thru this Link for More Info,

Please refer to the document:

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba34635c111d1829f0000e829fbfe/content.htm

Regards.

Former Member
0 Kudos

Hi,

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 Program:

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.

SET PF-STATUS stat OF PROGRAM prog

itab.

This statement defines the user interface for all subsequent screens of a screen sequence until another dialog status is set using a new SET PF-STATUSstatement. The dialog status stat must be a component of the current ABAP program, unless you use the OF PROGRAM addition to set a dialog status of another program prog.

The EXCLUDING addition allows you to change the appearance and function of a dialog status dynamically. This is useful if the individual user interfaces for a range of screens are very similar. You can define a single global status, and then just deactivate the functions you do not need using EXCLUDING. Specify f to deactivate the function code stored in field f. Specify itab to deactivate all function codes stored in the internal table itab. The field f and the rows of table itab should be of the type c with the length 20.

You should set the dialog status for a screen in the PBO event. If you do not specify a dialog status for a screen, it is displayed with the interface of the previous screen. If you do not specify a dialog status for the first screen of a program, it has no user interface, and the user may not be able to leave the screen.

Example Program:

PROGRAM demo_dynpro_gui_status.

DATA: ok_code TYPE sy-ucomm,

save_ok LIKE ok_code,

output LIKE ok_code.

CALL SCREEN 100.

MODULE init_screen_0100 OUTPUT.

SET PF-STATUS 'STATUS_100'.

SET TITLEBAR '100'.

ENDMODULE.

MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.

LEAVE PROGRAM.

WHEN OTHERS.

output = save_ok.

ENDCASE.

ENDMODULE.

Click on the STATUS_100, it will open a screen, you can fill the fields and go on with the navigation

Simply....

AT- PF: This event is for predefined function keys like Ctrls, CtrlF3..

where as

AT-User Command: This event is for user defined function keys

for User defined function keys you have to maintain the logic explicitly

Regards,

Omkar.

Former Member
0 Kudos

Hi,

PF-status is used to assign function code for the button in ur program, where as user-command is used to write code when u click the button.'

In short we can tell that pf-status is defination of that button where as user-command is implementation of that button.

for example.

  • Defination of fcodes.

set pf-status 'main'.

  • implementation of fcodes

case sy-ucomm.

when 'back'.

leave program.

when 'write'.

write: 'user-command write has been executed'.

endcase.

Plzz reward points if it helps.

Former Member
0 Kudos

Hi Ritu,

PF-Status is the status where we are declaring the status of the screen such as

icons, pushbuttons etc.

But User-command is the syntax used in interactive lists or reports, ie if user interacts with the gui status of the screen.

Former Member
0 Kudos

USER COMMAND:

WHEN THE USER SELECTS A USER DEFINED ACTION.

THE EVENT IS NOT TRIGGERED IF THE USER SELECTS SYSTEM-DEFINED ACTIONS. BASED ON THE ACTION SELECTED A UNIQUE CODE IS POPULATED BY THE SYSTEM IN THE VARIABLE SY-UCOMM.

PF-STATUS: SETS A GUI STATUS PFSTAT WHICH CAN BE UP TO 20 CHAR LONG.THERE ARE MANY OF THESE STATUSES IN THE GUI OF A PROGRAM.EACH ONE DESCRIBES WHICH FUNCTIONS ARE AVALIABLE AND HOW YOU CAN SELECT THESE VIA MENUS AND MENU BARS OR BY PRESSING FUNCTION KEYS OR PUSH BUTTONS.

REWARD IF ITS USEFUL

Former Member
0 Kudos

Hi alka ritu ,

Check the following websites for good documentation o n pf status and user-command

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba34635c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba99935c111d1829f0000e829fbfe/content.htm

1. How to set pf-status

set pf-status ‘ZZBILSTA’.

2. How to set pf-status excluding/including single menu items

You can exclude menus by using exclude :

set pf-status ‘ZZBILSTA’ excluding ‘PST’.

Note: Can also be used with include instead of exclude

3. How to set pf-status excluding/including several menu items

You have to use an internal table to store the status you wan’t to ex- or include:

DATA:BEGIN OF I_PF_STATUS_TAB OCCURS 10,

FCODE,

END OF I_PF_STATUS_TAB.

FORM SET_PF_STATUS_POSTER.

REFRESH I_PF_STATUS_TAB. MOVE ‘PST’ TO I_PF_STATUS_TAB. APPEND I_PF_STATUS_TAB. MOVE ‘ART’ TO I_PF_STATUS_TAB. APPEND I_PF_STATUS_TAB. SET PF-STATUS ‘ZZBILSTA’ EXCLUDING I_PF_STATUS_TAB.

ENDFORM.

4. Setting PF status to the (SAP) system default

set pf-status ‘BASIC’.

5. How to check for pf-status

AT USER-COMMAND.

CASE SY-UCOMM. WHEN ‘ART’. PERFORM STYR_ARTSKONTI. WHEN ‘PST’. PERFORM STYR_POSTER. WHEN ‘BIL’. PERFORM VIS_BILAG. ENDCASE.

6. Use of SY-PFKEY

You can use the system variable sy-pfkey to retrieve the name of the current pf status

USER-COMMAND:

If the user chooses a function code during list processing that is neither processed by the system, or PICK or PFnn, the system triggers the event AT USER-COMMAND. For this event, you must define your own GUI status for a list. To react to your own function codes in a program, you must define the following event block:

AT USER-COMMAND.

statements.

In this event block, you can use an IF or CASE structure to differentiate between the function codes. They are available in the system field sy-ucomm. There are further system fields that are filled in list events, such as sy-lsind and sy-pfkey, that allow you to make further case distinctions.

Triggering a List Event from the Program

You can trigger a list event from the program as follows:

SET USER-COMMAND fc.

This statement takes effect after the current list is completed. Before the list is displayed, the event assigned to function code fc is triggered, regardless of the dialog status you are using.

The effect is the same as when the user chooses the function. In other words, predefined list function codes are trapped and processed by the runtime environment, the function codes PICK and PFnn trigger the AT LINE-SELECTION and AT PFnnevents, and user-defined function codes trigger the AT USER-COMMAND event block.

Function code PICK triggers an event only if the cursor is located on a list line.

Using this statement in conjunction with the function codes reserved for system functions, you can call the system functions from the program. For example, you can use SET USER-COMMAND '%SC' to call the Find dialog box directly, or to position the list correctly before it is displayed.

If you use several SET USER-COMMAND statements while creating a list, the system executes only the last one.

Example of AT USER-COMMAND.

REPORT demo_list_at_user_command NO STANDARD PAGE HEADING.

START-OF-SELECTION.

WRITE: 'Basic List',

/ 'sy-lsind:', sy-lsind.

TOP-OF-PAGE.

WRITE 'Top-of-Page'.

ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.

CASE sy-pfkey.

WHEN 'TEST'.

WRITE 'Self-defined GUI for Function Codes'.

ULINE.

ENDCASE.

AT LINE-SELECTION.

SET PF-STATUS 'TEST' EXCLUDING 'PICK'.

PERFORM out.

sy-lsind = sy-lsind - 1.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'FC1'.

PERFORM out.

WRITE / 'Button FUN 1 was pressed'.

WHEN 'FC2'.

PERFORM out.

WRITE / 'Button FUN 2 was pressed'.

WHEN 'FC3'.

PERFORM out.

WRITE / 'Button FUN 3 was pressed'.

WHEN 'FC4'.

PERFORM out.

WRITE / 'Button FUN 4 was pressed'.

WHEN 'FC5'.

PERFORM out.

WRITE / 'Button FUN 5 was pressed'.

ENDCASE.

sy-lsind = sy-lsind - 1.

FORM out.

WRITE: 'Secondary List',

/ 'sy-lsind:', sy-lsind,

/ 'sy-pfkey:', sy-pfkey.

ENDFORM.

Example of AT USER-COMMAND.

REPORT demo_list_set_user_command NO STANDARD PAGE HEADING.

START-OF-SELECTION.

SET USER-COMMAND 'MYCO'.

WRITE 'Basic List'.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'MYCO'.

WRITE 'Secondary List from USER-COMMAND,'.

WRITE: 'sy-lsind', sy-lsind.

SET USER-COMMAND 'PF05'.

ENDCASE.

AT pf05.

WRITE 'Secondary List from PF05,'.

WRITE: 'sy-lsind', sy-lsind.

SET CURSOR LINE 1.

SET USER-COMMAND 'PICK'.

AT LINE-SELECTION.

WRITE 'Secondary List from LINE-SELECTION,'.

WRITE: 'sy-lsind', sy-lsind.

SET USER-COMMAND '%SC'.

http://maxdb.sap.com/currentdoc/94/90ee41c334c717e10000000a155106/content.htm

cheers!

gyanaraj

****Pls reward points if u find this helpful

Former Member
0 Kudos

thanks to all