动态显示报表

 

*----------------------------------------------------------------------*
* Program ID/Name : YCX0002
* Author's name   : 
* Program title   : HCP系统工资数据底表数据查询
* Project Name    : S4/HANA
* Version         :
* Date written    : 
* Last update     :
* Function Spec ID: LSTZ_FI_DEV_006
*----------------------------------------------------------------------*
REPORT YCX0002 MESSAGE-ID ztz_001.

TABLES: zfit_tz01, "表1工资接口数据表(计提与实际)
        zfit_tz02, "表2社保接口数据表
        zfit_tz03. "表3年终奖接口数据表


*TYPES: BEGIN OF ty_fi01.
*    INCLUDE STRUCTURE zfit_tz01.
*TYPES: sel TYPE c,
*       END OF ty_fi01.
*DATA:gt_fi01 TYPE TABLE OF ty_fi01.
*
*TYPES: BEGIN OF ty_fi02.
*    INCLUDE STRUCTURE zfit_tz02.
*TYPES: sel TYPE c,
*       END OF ty_fi02.
*DATA:gt_fi02 TYPE TABLE OF ty_fi02.
*
*TYPES: BEGIN OF ty_fi03.
*    INCLUDE STRUCTURE zfit_tz03.
*TYPES: sel TYPE c,
*       END OF ty_fi03.
*DATA:gt_fi03 TYPE TABLE OF ty_fi03.

TYPES: ty_field TYPE TABLE OF string.
DATA: gt_flds  TYPE ty_field,
      gt_from  TYPE ty_field,
      gt_where TYPE ty_field.
FIELD-SYMBOLS <fs_fld> TYPE string.

*dynamic table
DATA: gt_dyn_table TYPE REF TO data,
      gs_dyn_line  TYPE REF TO data.
FIELD-SYMBOLS:<fs_dyn_table> TYPE STANDARD TABLE,
              <fs_dyn_wa>,
              <fs_dyn_field>.
FIELD-SYMBOLS:<fs_fieldcate> TYPE lvc_s_fcat.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: gv_tabname   LIKE    dd02l-tabname.

*----------------------------------------------------------------------*
* Micro
*----------------------------------------------------------------------*
"查询字段
DEFINE field.
  APPEND INITIAL LINE TO gt_flds ASSIGNING <fs_fld>.
  <fs_fld> = &1.
END-OF-DEFINITION.
DEFINE from.
  APPEND INITIAL LINE TO gt_from ASSIGNING <fs_fld>.
  <fs_fld> = &1.
END-OF-DEFINITION.
DEFINE whe.
  APPEND INITIAL LINE TO gt_where ASSIGNING <fs_fld>.
  <fs_fld> = &1.
END-OF-DEFINITION.

DATA: gs_kaps LIKE zcov_kaps,
      ok_code TYPE sy-ucomm.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t01.

SELECT-OPTIONS: s_bno    FOR zfit_tz01-batchno ,
                s_psnno  FOR zfit_tz01-psn_dept_no ,
                s_job    FOR zfit_tz01-jobcategory,
                s_rvers1 FOR zfit_tz01-reverse1.

PARAMETERS: rb_01 RADIOBUTTON GROUP g1 USER-COMMAND rb DEFAULT 'X',
            rb_02 RADIOBUTTON GROUP g1,
            rb_03 RADIOBUTTON GROUP g1.

SELECTION-SCREEN END OF BLOCK b1.


START-OF-SELECTION.
  PERFORM frm_get_data.

END-OF-SELECTION.
  PERFORM frm_display.

*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_get_data .

  CLEAR: gv_tabname.
  CASE abap_true.
    WHEN rb_01.
      gv_tabname = 'ZFIT_TZ01'.
      from: 'ZFIT_TZ01'.
      whe: 'batchno         IN @s_bno',
           'AND psn_dept_no IN @s_psnno',
           'AND jobcategory IN @s_job',
           'AND reverse1    IN @s_rvers1'.

    WHEN rb_02.
      gv_tabname = 'ZFIT_TZ02'.
      from: 'ZFIT_TZ02'.
      whe: 'batchno         IN @s_bno',
           'AND psn_dept_no IN @s_psnno',
           'AND jobcategory IN @s_job'.
    WHEN rb_03.
      gv_tabname = 'ZFIT_TZ03'.
      from: 'ZFIT_TZ03'.
      whe: 'batchno         IN @s_bno',
           'AND psn_dept_no IN @s_psnno',
           'AND jobcategory IN @s_job'.
    WHEN OTHERS.
  ENDCASE.

  PERFORM frm_create_table.
  PERFORM frm_get_fi01.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_display .

  PERFORM frm_get_alv_fieldcat CHANGING gt_fieldcat.
*  ls_gridset-edt_cll_cb = 'X'."编辑回调

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_callback_program = sy-repid
*     i_callback_pf_status_set = 'FRM_ALV_PF_STATUS_SET'
*     i_callback_user_command  = 'FRM_ALV_USER_COMMAND'
*     i_grid_settings    = ls_gridset
      is_layout_lvc      = VALUE lvc_s_layo( zebra = abap_true cwidth_opt = abap_true ) "box_fname = 'SEL'
      it_fieldcat_lvc    = gt_fieldcat
      i_default          = 'X'
      i_save             = 'A'
      is_variant         = VALUE disvariant( report = sy-repid )
*     it_events          = gt_event
    TABLES
      t_outtab           = <fs_dyn_table>
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_FI01
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_get_fi01 .

  SELECT *
    FROM (gv_tabname)
   WHERE (gt_where)
    INTO CORRESPONDING FIELDS OF TABLE @<fs_dyn_table>.
  IF sy-subrc NE 0.
    MESSAGE s000 DISPLAY LIKE 'E'.
    LEAVE LIST-PROCESSING.
  ELSE.
    DATA(lv_line) = lines( <fs_dyn_table> ).
    MESSAGE s003 WITH lv_line.
  ENDIF.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_ALV_FIELDCAT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*&      <-- LT_FIELDCAT
*&---------------------------------------------------------------------*
FORM frm_get_alv_fieldcat  CHANGING ct_fieldcat TYPE lvc_t_fcat.

  LOOP AT ct_fieldcat INTO DATA(ls_fieldcat).
    CASE ls_fieldcat-fieldname.
      WHEN 'PSP001'
        OR 'PSP002'
        OR 'PSP003'
        OR 'PSP004'
        OR 'PSP005'
        OR 'PSP006'
        OR 'PSP007'
        OR 'PSP008'
        OR 'PSP009'
        OR 'PSP010'
        OR 'PSP011'
        OR 'PSP012'
        OR 'PSP013'
        OR 'PSP014'
        OR 'PSP015'
        OR 'PSP016'.
        ls_fieldcat-edit = 'X'.
        ls_fieldcat-checkbox = 'X'.
      WHEN OTHERS.
    ENDCASE.
    MODIFY ct_fieldcat FROM ls_fieldcat.
  ENDLOOP.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_CREATE_TABLE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_create_table .
  DATA: lv_copos TYPE i.
  DATA: lv_from TYPE numc2.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = gv_tabname
      i_client_never_display = 'X'
    CHANGING
      ct_fieldcat            = gt_fieldcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc <> 0.
*    RAISE fcat_error.
  ENDIF.
  SORT gt_fieldcat BY col_pos.

  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = gt_fieldcat
    IMPORTING
      ep_table        = gt_dyn_table.

  ASSIGN  gt_dyn_table->* TO <fs_dyn_table>.
  IF sy-subrc EQ 0.
  ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_01_FIELDCAT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM frm_get_01_fieldcat .

ENDFORM.

 

上一篇:web前端黑客技术揭秘 6.2.3URL编码差异 笔记


下一篇:创建采购申请(BAPI_REQUISITION_CREATE / BAPI_PR_CREATE)