F4搜索帮助~出口函数

FUNCTION ZF4IF_SHLP_EXIT_BANZU_TEST.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  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
  DATA: BEGIN OF GT_TAB OCCURS 0,
           KUNNR TYPE ZSD15-KUNNR,
           MATNR TYPE ZSD15-MATNR,
           SPRAS TYPE ZSD15-SPRAS,
           MAKTX TYPE MAKT-MAKTX,

        END OF GT_TAB.
  DATA R_KUNNR     TYPE RANGE OF ZSD15-KUNNR WITH HEADER LINE.
  DATA R_MATNR     TYPE RANGE OF ZSD15-MATNR WITH HEADER LINE.
  DATA R_SPRAS     TYPE RANGE OF ZSD15-SPRAS WITH HEADER LINE.
  DATA R_MAKTX     TYPE RANGE OF MAKT-MAKTX WITH HEADER LINE.

  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.

    LOOP AT SHLP-SELOPT INTO DATA(WA_SELOPT) . .
       CASE WA_SELOPT-shlpfield.
           WHEN 'KUNNR'.
          MOVE-CORRESPONDING wa_selopt TO R_KUNNR.
          APPEND R_KUNNR .
           WHEN  'MATNR'.
          MOVE-CORRESPONDING wa_selopt TO R_MATNR.
          APPEND R_MATNR.
         WHEN 'SPRAS' .
          MOVE-CORRESPONDING wa_selopt TO R_SPRAS.
          APPEND R_SPRAS .
         WHEN 'MAKTX' .
          MOVE-CORRESPONDING wa_selopt TO R_MAKTX.
          APPEND R_SPRAS.
           WHEN OTHERS.
       ENDCASE.

    ENDLOOP.
    SELECT KUNNR
           ZSD15~MATNR
           zsd15~SPRAS
           MAKTX

          FROM ZSD15
          INNER JOIN MAKT ON ZSD15~MATNR = MAKT~MATNR UP TO 100 ROWS
       INTO CORRESPONDING FIELDS OF TABLE  GT_TAB
      WHERE KUNNR IN R_KUNNR AND
            zsd15~MATNR IN R_MATNR AND
            zsd15~SPRAS IN R_spras AND
            MAKTX IN R_MAKTX.

*
*    CALL FUNCTION 'F4UT_PARAMETER_ALLOCATE'
*      EXPORTING
*        PARAMETER   = 'ZHS'
**        DEALLOCATE  = '1'
*      TABLES
*        SHLP_TAB    = SHLP_TAB
*        RECORD_TAB  = RECORD_TAB
*         source_tab  = GT_TAB
*      CHANGING
*        SHLP        = SHLP
*        CALLCONTROL = CALLCONTROL.
  callcontrol-step   =   'DISP'.
    CALL FUNCTION 'F4UT_RESULTS_MAP'
      TABLES
        shlp_tab    = shlp_tab
        record_tab  = record_tab
        source_tab  = GT_TAB
      CHANGING
        shlp        = shlp
        callcontrol = callcontrol .



    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.
*      callcontrol-step   =   'DISP'.
       SORT RECORD_TAB .
       DELETE ADJACENT DUPLICATES FROM RECORD_TAB COMPARING ALL FIELDS . "zsecond.


    EXIT.
  ENDIF.
ENDFUNCTION.

 





 

posted @ 2018-08-04 16:17  追寻无限  阅读(670)  评论(0编辑  收藏  举报