关闭

GUI STATUS 的使用

标签: functionlistscrollprocessingmenusap
1173人阅读 评论(0) 收藏 举报
分类:

1、用se80进入Object Navigator,然后选择需要增加GUISTATUES的Program,如下图;

 

2、选择好Promgram之后,在 Object Name 中的程序名称节点上单击鼠标右键,选择 Create —》 GUI Status菜单项,出现“Create GUI Status”窗口,输入GUI Status名称和简要描述,Status Type选择“normal screen”,单击 ,出现GUI Status的工作区,如下图所示:

 

3、在SAP标准中,Application Toolbar中包含的功能项在Menu Bar都应该有与其对应的选项。在Menu Bar一栏,点击 ,出现下面界面:

 

单击“Display Standards” 可以出现系统默认的一级菜单项,最多允许6个一级菜单。

 

4、在上面的输入框中输入你需要的菜单名称,如:Lists,然后双击该输入框,出现如下图界面:

每个菜单包含两项内容:Text 和 Function Code, Text 用于显示,Function Code用于在程序中辨别用户选择了哪个菜单,每个菜单项,它包含的Function Code不能相同。为了将具有相同功能或相同特性的菜单项显示在一起,且同其他菜单项分隔,SAP允许你插入分割线,选择 “Edit” —》 “Insert” —》“Separator Line”可以插入菜单分割线。如果有二级菜单,那么只输入Text项中值,将Code项中的值留空,然后双击该项,将会出现二级菜单的维护界面,如下图:

,二级菜单同样包括Code 和 Text两项值,SAP最多允许3级菜单。

 

5、其中Code项中的值非常重要,在程序中当用户单击某个菜单项的时候,系统会将该项对应的Code值赋给系统变量sy-ucomm,然后在根据sy-ucomm来处理不同的业务逻辑。Code 值可以是系统中已有的,也可以是自定义的,系统中已包含下列Function Code:

Code

Menu

Standard toolbar

Function key

Description

%PC

List

   

Save list to file

%SL

List

   

Save list in SAPoffice

%ST

List

   

Save list in report tree

PRI

List

This graphic is explained in the accompanying text

CTRL-P

Print displayed list

%EX

List

This graphic is explained in the accompanying text

Shift-F3

Exit processing

PICK

Edit

This graphic is explained in the accompanying text

F2

Event AT LINE-SELECTION

RW

Edit

This graphic is explained in the accompanying text

F12 , ESC

Cancel processing

%SC

Edit

This graphic is explained in the accompanying text

CTRL-F

Find

%SC+

Edit

This graphic is explained in the accompanying text

CTRL-G

Find next

BACK

Goto

This graphic is explained in the accompanying text

F3

Back one level

P--

 

This graphic is explained in the accompanying text

CTRL-PgUp

Scroll to first window page

P-

 

This graphic is explained in the accompanying text

PgUp

Scroll to previous window page

P+

 

This graphic is explained in the accompanying text

PgDn

Scroll to next window page

P++

 

This graphic is explained in the accompanying text

Ctrl-PgDn

Scroll to last window page

%CTX

   

Shift-F10

Context menu on list

 

 

此外,还有一些预定义的Function Codes,它们没有设置成的状态功能,可以自由的分配它们到未使用的状态元素,预定义的Function Code如下:

Code

Description

PF<nn>

Event AT PF<nn>

PP<n>

Scroll to top of list page <n>

PP-[<n>]

Scroll back one list page or <n> pages

PP+[<n>]

Scroll forward one list page or <n> pages

PS<n>

Scroll to column <n>

PS--

Scroll to first column of the list

PS-[<n>]

Scroll left by one or <n> columns

PS+[<n>]

Scroll right by one or <n> columns

PS++

Scroll to last column of the list

PZ<n>

Scroll to line <n>

PL-[<n>]

Scroll back to first line of the page or by <n> lines

PL+[<n>]

Scroll to last line of the page or by <n> lines

/....

For other system commands

 

第一张表格中的Function Code对应的功能由SAP自己完成,PF<nn>始终触发 AT PF<nn>事件( AT PF<nn>事件也过时 )。


6、运行时环境直接处理上表中的所有Function Code,处理PICK 和 PF<nn>, PICK始终触发 AT LINE-SELECTION, PF<nn>始终触发 AT PF<nn>事件。如果你定义的Function Code不包含在上面的表中,那么触发 AT USER-COMMAND事件,但是除了F2和Shift +  F10。F2和双击的功能相同, Shift +  F10和单击鼠标右键的功能相同。




7、 Appication Toolbar  的设置 和Menu Bar类似,先在文本框中输入Function Code(function Code可以是系统默认的,也可以是上面menu bar中定义的),然后双击该文本框,出现Assign Function to Function Key 对话框,作用是让你指定一个和此功能相关联的快捷键, 根据需要选择一行,单击 或按下回车键,出现Function Attributes窗口,可以设置按钮在Appication Toolbar上显示的内容和图片.


8、Function Keys主要是为Function Code设置键盘快捷键。


9、都设置好后Ctrl + s 保存,Ctrl + F3 激活


10、在程序中用以下代码使用上面定义的GUI STATUS:

START-OF-SELECTION.
  SET PF-STATUS 'TEST'.
  write: 'sy-pfkey', sy-pfkey.
  WRITE: / 'Basic list, SY-LSIND =', sy-lsind.

AT LINE-SELECTION.
  WRITE:  'LINE-SELECTION, SY-LSIND =', sy-lsind.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'TEST'.
      WRITE:  'TEST, SY-LSIND =', sy-lsind.
  ENDCASE.


 

11、 SET PF-STATUS的完整语法是:

SET PF-STATUS <stat> [EXCLUDING <f>|<itab>]
                     [OF PROGRAM <prog>]
                     [IMMEDIATELY].

sap 官方网站上的说明是:

     This statement sets the status <stat> for the current output list. The dialog status <stat> must be defined for the current program, unless you have used the OF PROGRAM addition to set a status from another program <prog>. The status is active for all subsequent list levels until you set another status. The SY-PFKEY system field always contains the status of the current list.

      Using SET PF-STATUS, you can display different user interfaces for different list levels to provide the user with different functions according to the individual requirements. Use SET PF-STATUS SPACE to set the standard list status. This depends on the event blocks in the program, as described above.

      The EXCLUDING option allows you to change the appearance and available functions of a status from within the program. This is useful if the individual user interfaces for a range of list levels 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>. Field <f> and the lines of table <itab> should be defined with reference to the system field SY-UCOMM.

       The IMMEDIATELY addition is intended specially for list processing. You use it while creating a detail list within an event block to change the status of the list currently displayed (index SY-LISTI). Without this option, the system changes the status of the current secondary list (SY-LSIND) that is displayed only at the end of the processing block.


注意 SY-LISTI 和 SY-LSIND的区别

SY-LISTI       Index of the list level from which the event was triggered(触发事件的列表所在列表级别中的索引)

SY-LSIND     Index of the list created during the current event (basic list = 0)(当前事件执行过程中创建的列表在列表级别中的索引)


将第10条中的代码改成如下:

START-OF-SELECTION.
  write: 'sy-pfkey', sy-pfkey.
  WRITE: / 'Basic list, SY-LSIND =', sy-lsind.

AT LINE-SELECTION.
  WRITE:  'LINE-SELECTION, SY-LSIND =', sy-lsind.
  SET PF-STATUS 'TEST' immediately.

AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'TEST'.
      WRITE:  'TEST, SY-LSIND =', sy-lsind.
  ENDCASE.


加上 immediately,你会发现执行完一次 AT LINE-SELECTION 事件后再返回,基本列表的Status也变成了 TEST,如果不加 immediately,那么基本 列表的Status任然是系统默认的。


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:13080次
    • 积分:275
    • 等级:
    • 排名:千里之外
    • 原创:14篇
    • 转载:3篇
    • 译文:0篇
    • 评论:2条
    文章分类
    文章存档
    最新评论
    SAP BLOGER