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 / USER COMMAND

Former Member
0 Kudos

1. what is pf status , user command on which situation you have to used this......(didn't understand the clarity provided by the existing forum answers)

2. give me how to create a button (step by step)

3. how to create a menu painter (step by step)

thx

Sree.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Declare as shown below in your program.

set pf-status 'XYZ'.

now double click on 'XYZ'. it will take you to some other screen to maintain your buttons or other details.

Example: you can maintain MENU bar, Application tool bar an dfunction keys.

After that again go back to your program and write the below code.

case sy-ucomm.

when 'BACK'.

Do what ever you like

when 'EXIT'.

Do what ever you like

when others.

endcase.

Edited by: Velangini Showry Maria Kumar Bandanadham on May 15, 2008 2:14 PM

9 REPLIES 9

Former Member
0 Kudos

Hi,

Declare as shown below in your program.

set pf-status 'XYZ'.

now double click on 'XYZ'. it will take you to some other screen to maintain your buttons or other details.

Example: you can maintain MENU bar, Application tool bar an dfunction keys.

After that again go back to your program and write the below code.

case sy-ucomm.

when 'BACK'.

Do what ever you like

when 'EXIT'.

Do what ever you like

when others.

endcase.

Edited by: Velangini Showry Maria Kumar Bandanadham on May 15, 2008 2:14 PM

0 Kudos

THX FOR YOUR SPONTONEOUS ABSWER

0 Kudos

As you mentioned , i have created some application tool bars. and assinged name as "zsave", "zlocate".

whene i try to use the follwoing code.

case sy-ucomm.

when 'ZSAVE'.

write : ' save button presed'.

when 'locate'.

write : 'locatet button pressed'.

when others.

write : 'other buttons pressed'.

endcase.

control always to go to others. since no selection value has been assingned.

regards

sree

Former Member
0 Kudos

Hi,

Dialog Status for Lists

To allow the user to communicate with the system when a list is displayed, the lists must be able to direct user actions to the ABAP program. As described in User Actions on Screens, function codes are used to do this. Function codes are maintained in the GUI status of the list screen. You define a GUI status using the Menu Painter tool in the ABAP Workbench. The system assigns function codes to list-specific user actions.

The most important of these functions is for selecting list lines by double-clicking. As described in Using a GUI Status, the double-click function is always linked to the F2 key. If a function code is assigned to the F2 key in the GUI status, it will be triggered when you double-click.

The Standard List Status

As with normal screens, you can define your own GUI status for lists and attach it to a list level using the SET PF-STATUS statement. If you do not set a particular GUI status, the system sets a default list status for the list screen in an executable program. In other programs, for example, when you call a list from screen processing, you must set this status explicitly using the statement

SET PF-STATUS space.

This default interface always contains at least the functions described in the Standard List section.

Unlike normal dialog statuses, the default list status is affected by the ABAP program.

If you define event blocks in your program using the event keywords AT LINE-SELECTION or AT PF<nn>, the system automatically assigns extra functions to other function keys that provide additional functions.

AT PF<nn> (obsolete)

All function keys of the keyboard F<nn> that are not used for predefined system functions, are set to the function codes PF<nn>, where <nn> is a number between 01 and 24. During list processing, the function codes PF<nn> are linked to the events AT PF<nn>. Choosing PF<nn> always triggers AT PF<nn>. You should no longer use event blocks for PF<nn>.

AT LINE-SELECTION

For this event, the F2 key (double-click) is assigned the function code PICK and function code Choose. The function also always appears in the application toolbar. During list processing, the PICK function code is assigned to the event AT LINE-SELECTION. PICK always triggers AT LINE-SELECTION.

All other function codes are either intercepted by the runtime environment or trigger the event AT USER-COMMAND. Function codes that trigger AT USER-COMMAND must be defined in your own GUI status. The easiest way to do this is to use the standard list status and add extra functions of your own to it.

Former Member
0 Kudos

Hi,

PF STATUS / USER COMMAND

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

Reward points for useful answers

cheers!

Raj.

0 Kudos

hello..!

under what event we can write  the pf status  ......

plz kindly help me.

0 Kudos

hi!

IT  IS VERY USEFULL,BUT UNDER WHAT EVENT WE CAN WRITE PF STATUS?

PL KINDLY HELP ME.

THANK YOU.

0 Kudos

Hi,

END-OF-SELECTION but before the first write Statement. I think even START-OF-SELECTION would work.

Regards

Oliver

0 Kudos

HI Oliver.

THANKS FOR OUR SUGGESTION .