2016년 3월 8일 화요일

[ABAP] 유지보수 테이블에 검색 조건 달기

[출처 : http://scn.sap.com/ ]
 *&---------------------------------------------------------------------*
*& Report  ZPP001
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZPP001.
TABLES: ZPPT001.

DATA MYTABLE    TYPE ZPP001.
DATA SELECTIONS TYPE TABLE OF VIMSELLIST.
DATA SELECTION  TYPE VIMSELLIST.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_AUFNR FOR ZPPT001-AUFNR OBLIGATORY,
                S_VORNR FOR ZPPT001-VORNR,
                S_PERNR FOR ZPPT001-PERNR,
                S_FDATE FOR ZPPT001-FDATE.

 PARAMETERS   : P_STAT TYPE ZPPT001-STAT.
 SELECTION-SCREEN END OF BLOCK B1.

START-OF-SELECTION.
  DEFINE ADDSEL.

    call function 'VIEW_RANGETAB_TO_SELLIST'
      exporting
        fieldname          &1
        append_conjunction 'AND'
      tables
        sellist            selections
        rangetab           &2[].

  END-OF-DEFINITION.


  DEFINE ADDPAR.
    IF &2 IS NOT INITIAL.
      CLEAR selection.
      selection-viewfield &1.
      selection-value &2.
      selection-and_or 'AND'.
      selection-operator 'EQ'.
      APPEND selection TO selections.
    ENDIF.
  END-OF-DEFINITION.


  ADDSEL 'AUFNR' S_AUFNR.
  ADDSEL 'VORNR' S_VORNR.
  ADDSEL 'PERNR' S_PERNR.
  ADDSEL 'FDATE' S_FDATE.

  ADDPAR 'STAT'  P_STAT.


  CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
    EXPORTING
      action                'U' "for Update
      view_name             'ZPPT001'
      complex_selconds_used 'X'
    TABLES
      dba_sellist           selections
    EXCEPTIONS
      OTHERS                1.

  IF sy-subrc 1.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

댓글 없음:

댓글 쓰기