FICO-凭证清单查询程序

一、主程序

*&---------------------------------------------------------------------*
*& Report ZFIR0033
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zfir0033.
*DATA
TABLES:bkpf,bseg.
TYPES:BEGIN OF ty_tab,
        bukrs     TYPE bkpf-bukrs,
        belnr     TYPE bkpf-belnr,
        gjahr     TYPE bkpf-gjahr,
        monat     TYPE bkpf-monat,
        budat     TYPE bkpf-budat,
        bldat     TYPE bkpf-bldat,
        blart     TYPE bkpf-blart,
        bktxt     TYPE bkpf-bktxt,
        usnam     TYPE bkpf-usnam,
*        tcode     TYPE bkpf-tcode,
        xblnr_alt TYPE bkpf-xblnr_alt,
        buzei     TYPE bseg-buzei,
        bschl     TYPE bseg-bschl,
        shkzg     TYPE bseg-shkzg,
        hkont     TYPE bseg-hkont,
        txt20     TYPE skat-txt20,
        sgtxt     TYPE bseg-sgtxt,
        dmbtr     TYPE bseg-dmbtr,
        wrbtr     TYPE bseg-wrbtr,
        pswsl     TYPE bseg-pswsl,
      END OF ty_tab.
DATA:gt_tab TYPE TABLE OF ty_tab,
     gs_tab TYPE ty_tab.
DATA:gt_skat TYPE TABLE OF skat,
     gs_skat TYPE skat.
DATA:gt_t001 TYPE TABLE OF t001,
     gs_t001 TYPE t001.

CLASS lcl DEFINITION DEFERRED.
DATA: gr_lcl TYPE REF TO lcl.

*SELECT-OPTION
SELECT-OPTIONS:s_bukrs FOR bkpf-bukrs.
SELECT-OPTIONS:s_belnr FOR bkpf-belnr.
SELECT-OPTIONS:s_gjahr FOR bkpf-gjahr.
SELECT-OPTIONS:s_monat FOR bkpf-monat.

INCLUDE zfir0033_lcl.

START-OF-SELECTION.
*SQL
  SELECT * INTO TABLE gt_t001 FROM t001
    WHERE land1 = 'CN'
      AND bukrs IN s_bukrs.

  LOOP AT gt_t001 INTO gs_t001.
    AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
                        ID 'BUKRS'   FIELD gs_t001-bukrs.
    IF sy-subrc NE 0.
      DELETE gt_t001 WHERE bukrs = gs_t001-bukrs.
    ENDIF.
  ENDLOOP.

  SELECT a~bukrs a~belnr a~gjahr a~monat a~budat a~bldat a~blart a~bktxt
         a~usnam a~xblnr_alt
         b~buzei b~bschl b~shkzg b~dmbtr b~wrbtr b~pswsl b~hkont b~sgtxt
    INTO CORRESPONDING FIELDS OF TABLE gt_tab
    FROM bkpf AS a
    INNER JOIN bseg AS b ON
    a~bukrs = b~bukrs AND
    a~belnr = b~belnr AND
    a~gjahr = b~gjahr
    FOR ALL ENTRIES IN gt_t001
    WHERE a~bukrs IN s_bukrs
      AND a~bukrs = gt_t001-bukrs
      AND a~belnr IN s_belnr
      AND a~gjahr IN s_gjahr
      AND a~monat IN s_monat.

  SELECT * INTO TABLE gt_skat FROM skat WHERE spras = '1' AND ktopl = 'DTIS'.

  SORT gt_tab BY bukrs gjahr monat belnr buzei.
  SORT gt_skat BY saknr.

  LOOP AT gt_tab ASSIGNING FIELD-SYMBOL(<fs_tab>).
    READ TABLE gt_skat ASSIGNING FIELD-SYMBOL(<fs_skat>)
    WITH KEY saknr = <fs_tab>-hkont BINARY SEARCH.
    IF sy-subrc = 0.
      <fs_tab>-txt20 = <fs_skat>-txt20.
    ENDIF.
  ENDLOOP.

END-OF-SELECTION.
  CREATE OBJECT gr_lcl.
  gr_lcl->show_alv( ).

包含程序

*&---------------------------------------------------------------------*
*& 包含               ZFIR0033_LCL
*&---------------------------------------------------------------------*
*LCL
CLASS lcl DEFINITION.
  PUBLIC SECTION.
    METHODS:show_alv.

  PRIVATE SECTION.
    METHODS:handle_hotspot FOR EVENT link_click OF cl_salv_events_table
      IMPORTING row column.
    METHODS handle_double FOR EVENT double_click OF cl_salv_events_table
      IMPORTING row column.

ENDCLASS.
CLASS lcl IMPLEMENTATION.

  METHOD show_alv.
*DISPLAY ALV
    cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_salv)
                            CHANGING t_table = gt_tab[] ).

    DATA(lo_funcs) = lo_salv->get_functions( ).
    lo_funcs->set_all( 'X' ).
    DATA(lo_layout) = lo_salv->get_layout( ).
    DATA:ls_program   TYPE salv_s_layout_key. "该结构包含了布局变式所属程序名
    ls_program-report = sy-repid.
    lo_layout->set_key( ls_program )."设置布局保存为变式时,这些变式应属性此Key(本程序名)
    lo_layout->set_save_restriction( cl_salv_layout=>restrict_none )."允许保存布局为变式
*   handle hotspot
    DATA(lo_evt) = lo_salv->get_event( ).
    SET HANDLER handle_hotspot FOR lo_evt.
    SET HANDLER handle_double FOR lo_evt.

    lo_salv->display( ).
  ENDMETHOD.

  METHOD handle_hotspot.
    MESSAGE '123' TYPE 'I'.
  ENDMETHOD.
  METHOD handle_double.
    READ TABLE gt_tab INTO gs_tab INDEX row.
    IF sy-subrc = 0.
      SET PARAMETER ID: 'BUK' FIELD gs_tab-bukrs,
                       'GJR' FIELD gs_tab-gjahr,
                       'BLN' FIELD gs_tab-belnr.
      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDMETHOD.
ENDCLASS.
RIPRO主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
SapiBook » FICO-凭证清单查询程序

发表评论