ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 关于search help Exit和样例收藏(from Jack Wu)

关于search help Exit和样例收藏(from Jack Wu)

原创 Linux操作系统 作者:SAP骑士 时间:2011-03-30 11:31:07 0 删除 编辑

关于search help Exit和样例收藏(from Jack Wu)

1、 search help Exit是用于对标准帮助进行扩充,以提供更好的灵活性。

2、search help Exit何时被调用

Before Displaying the Dialog Box for Selecting the Required Search Path.

It is only called for collective search helps. Using the search help exit, the set of elementary search helps available can for example be restricted depending on the context.

Before Starting the F4 Process for the Elementary Search Help

The call is triggered independent of whether the dialog window for entering the search conditions appears or whether the selection is executed immediately (for example, because in the Hot key of the elementary search help Immediate value display is set).

Before Displaying the Dialog Box for Entering Search Conditions.

You can either influence the dialog for entering search conditions or skip it altogether here. You can also influence how the selection screen looks. The call is triggered only if there is no direct selection (that is, if in the Hot key of the elementary search help Immediate value display is not set).

Before Selecting Data.

The data selection can be partly or completely copied from the search help exit. This can become necessary if the data selection cannot be implemented with a SELECT statement for a table or a view.

Before Displaying the Hit List.

You can influence the display of the hit list in this step with the search help exit. You can reduce the number of values displayed here. For example, you can display only values for which the person calling the input help has authorization. You can also copy the complete hit list from the search help exit.

Before Returning the Values Selected by the User to the Input Template.

It could be advisable to intervene at this time if control of the further transaction flow should depend on the value selected. A typical example is setting set/get parameters.

3、search help Exit的函数模板(F4IF_SHLP_EXIT_EXAMPLE )程序员就可以拷贝该函数进行改编,已达到适合自己企业的应用。

type-pools shlp.
type-pools f4typ. "Brücke zu alten F4-Bausteinen
tables: ddshdefsh. "Tabelle der Default-Suchhilfen

function f4if_shlp_exit_example.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     VALUE(SHLP) TYPE  SHLP_DESCR
*"     VALUE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
*"----------------------------------------------------------------------

* EXIT immediately, if you do not want to handle this step
  if callcontrol-step <> 'SELONE' and
     callcontrol-step <> 'SELECT' and
     " AND SO ON
     callcontrol-step <> 'DISP'.
     exit.
  endif.

*"----------------------------------------------------------------------
* STEP SELONE  (Select one of the elementary searchhelps)
*"----------------------------------------------------------------------
* This step is only called for collective searchhelps. It may be used
* to reduce the amount of elementary searchhelps given in SHLP_TAB.
* The compound searchhelp is given in SHLP.
* If you do not change CALLCONTROL-STEP, the next step is the
* dialog, to select one of the elementary searchhelps.
* If you want to skip this dialog, you have to return the selected
* elementary searchhelp in SHLP and to change CALLCONTROL-STEP to
* either to 'PRESEL' or to 'SELECT'.
  if callcontrol-step = 'SELONE'.
*   PERFORM. SELONE .........
    exit.
  endif.

*"----------------------------------------------------------------------
* STEP PRESEL  (Enter selection conditions)
*"----------------------------------------------------------------------
* This step allows you, to influence the selection conditions either
* before they are displayed or in order to skip the dialog completely.
* If you want to skip the dialog, you should change CALLCONTROL-STEP
* to 'SELECT'.
* Normaly only SHLP-SELOPT should be changed in this step.
  if callcontrol-step = 'PRESEL'.
*   PERFORM. PRESEL ..........
    exit.
  endif.
*"----------------------------------------------------------------------
* STEP SELECT    (Select values)
*"----------------------------------------------------------------------
* This step may be used to overtake the data selection completely.
* To skip the standard seletion, you should return 'DISP' as following
* step in CALLCONTROL-STEP.
* Normally RECORD_TAB should be filled after this step.
* Standard function module F4UT_RESULTS_MAP may be very helpfull in this
* step.
  if callcontrol-step = 'SELECT'.
*   PERFORM. STEP_SELECT TABLES RECORD_TAB SHLP_TAB
*                       CHANGING SHLP CALLCONTROL RC.
*   IF RC = 0.
*     CALLCONTROL-STEP = 'DISP'.
*   ELSE.
*     CALLCONTROL-STEP = 'EXIT'.
*   ENDIF.
    exit. "Don't process STEP DISP additionally in this call.
  endif.
*"----------------------------------------------------------------------
* STEP DISP     (Display values)
*"----------------------------------------------------------------------
* This step is called, before the selected data is displayed.
* You can e.g. modify or reduce the data in RECORD_TAB
* according to the users authority.
* If you want to get the standard display dialog afterwards, you
* should not change CALLCONTROL-STEP.
* If you want to overtake the dialog on you own, you must return
* the following values in CALLCONTROL-STEP:
* - "RETURN" if one line was selected. The selected line must be
*   the only record left in RECORD_TAB. The corresponding fields of
*   this line are entered into the screen.
* - "EXIT" if the values request should be aborted
* - "PRESEL" if you want to return to the selection dialog
* Standard function modules F4UT_PARAMETER_VALUE_GET and
* F4UT_PARAMETER_RESULTS_PUT may be very helpfull in this step.
  if callcontrol-step = 'DISP'.
*   PERFORM. AUTHORITY_CHECK TABLES RECORD_TAB SHLP_TAB
*                           CHANGING SHLP CALLCONTROL.
    exit.
  endif.
endfunction.

4、样例代码(参考sap的实例SFLIGHT)
SFLIGHT(SE11)中设置了search help exit SAPBC_GLOBAL_F4_SFLIGHT 。代码如下:

function sapbc_global_f4_sflight.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     VALUE(SHLP) TYPE  SHLP_DESCR
*"     VALUE(CALLCONTROL) LIKE  DDSHF4CTRL STRUCTURE  DDSHF4CTRL
*"----------------------------------------------------------------------
* The scope of this search help exit is decribed in the documentation.
* Note that SAPBC_GLOBAL_F4_SFLIGHT_MIN_FR provides a more complex
* example of a serch help exit.

data: begin of seatinfo occurs 0,                " parallel table to
            seatsmax type sflight-seatsmax,      " record_tab containing
            seatsocc type sflight-seatsocc,      " the information about
            seatsfre type s_seatsfre,            " the seats
      end of seatinfo.

if callcontrol-step = 'SELECT'.
* The search help parameters SEATSMAX and SEATSOCC are not displayed on
* the list of possible entries. Hence, provided they are not connected
* to dynpro fields, the F4 processor might consider it not to be
* necessary to select the contents of these fields.
* But this exit needs these contents in order to compute the number of
* free seats. Thus, the space for this contents is allocated by the
* following two calls. This automatically forces the F4 processor to
* fill this space with the contents of these fields.
   call function 'F4UT_PARAMETER_ALLOCATE'
        exporting
             parameter         = 'SEATSMAX'
        tables
             shlp_tab          = shlp_tab
             record_tab        = record_tab
        changing
             shlp              = shlp
             callcontrol       = callcontrol.
   call function 'F4UT_PARAMETER_ALLOCATE'
        exporting
             parameter         = 'SEATSOCC'
        tables
             shlp_tab          = shlp_tab
             record_tab        = record_tab
        changing
             shlp              = shlp
             callcontrol       = callcontrol.
endif.

check callcontrol-step = 'DISP'.

* This Exit only has to do something before the list of possible values
* is displayed. At that moment it has to compute the number of free
* seats for each row and attach it to the result of the selection
* process

* First fill the seatsmax-Info from the selected data. Note that there
* are two ways of using F4UT_PARAMETER_VALUE_GET described in the
* documetation of that function module. Here the second one is used.
call function 'F4UT_PARAMETER_VALUE_GET'
     exporting
          parameter         = 'SEATSMAX'
                                    " Reference to search help parameter
          fieldname         = 'SEATSMAX'
                                    " Reference to field of Seatinfo
     tables
          shlp_tab          = shlp_tab
          record_tab        = record_tab
          results_tab       = seatinfo
     changing
          shlp              = shlp
          callcontrol       = callcontrol.

* Now do the same with the seatsocc-Info:
call function 'F4UT_PARAMETER_VALUE_GET'
     exporting
          parameter         = 'SEATSOCC'
                                    " Reference to search help parameter
          fieldname         = 'SEATSOCC'
                                    " Reference to field of Seatinfo
     tables
          shlp_tab          = shlp_tab
          record_tab        = record_tab
          results_tab       = seatinfo
     changing
          shlp              = shlp
          callcontrol       = callcontrol.

* Now compute the number of free seats:
loop at seatinfo.
     if seatinfo-seatsocc < seatinfo-seatsmax.
        seatinfo-seatsfre = seatinfo-seatsmax - seatinfo-seatsocc.
     else.
          clear seatinfo-seatsfre.
     endif.
     modify seatinfo transporting seatsfre.
endloop.

* Finally transport the computed numbers into the search help data.
call function 'F4UT_PARAMETER_RESULTS_PUT'
     exporting
          parameter         = 'SEATSFRE'
                                    " Reference to search help parameter
          fieldname         = 'SEATSFRE'
                                    " Reference to field of Seatinfo
     tables
          shlp_tab          = shlp_tab
          record_tab        = record_tab
          source_tab        = seatinfo
     changing
          shlp              = shlp
          callcontrol       = callcontrol.
endfunction.
具体处理流程如图:

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17204926/viewspace-691291/,如需转载,请注明出处,否则将追究法律责任。

上一篇: ABAP Interview Faq's
请登录后发表评论 登录
全部评论

注册时间:2009-01-01

  • 博文量
    59
  • 访问量
    314209