ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Coding更改程序的变式(report variant change 转)

Coding更改程序的变式(report variant change 转)

原创 Linux操作系统 作者:翟毛 时间:2009-08-04 15:41:05 0 删除 编辑

*&---------------------------------------------------------------------*
*& Report  Z_BARRY_REPORT_VARIANT_CHANGE
*&
*&---------------------------------------------------------------------*
*& Codeing更改程序变式的值
*& 本例为点击"执行"后变式内的日期加一天
*& 而且包含如何把格式化的日期转换为内部日期的代码
*&---------------------------------------------------------------------*

REPORT  z_barry_report_variant_change .
TABLES usr01 .
DATA: l_report LIKE rsvar-report,
      l_varia LIKE rsvar-variant,
      i_rc LIKE sy-subrc.
DATA: itab_variant_values LIKE rsparams OCCURS 0 WITH HEADER LINE,
      wa_techn_data LIKE varid.
DATA: tmpdate LIKE sy-datum .
DATA: str(10).

PARAMETERS p_date LIKE sy-datum .

START-OF-SELECTION.
  l_varia = 'TEST'.
  l_report = sy-repid .
  CALL FUNCTION 'RS_VARIANT_EXISTS'
    EXPORTING
      report              = l_report
      variant             = l_varia
    IMPORTING
      r_c                 = i_rc
    EXCEPTIONS
      not_authorized      = 1
      no_report           = 2
      report_not_existent = 3
      report_not_supplied = 4
      OTHERS              = 5.
  CHECK i_rc = 0.
  CALL FUNCTION 'RS_VARIANT_VALUES_TECH_DATA'
    EXPORTING
      report               = l_report
      variant              = l_varia
    IMPORTING
      techn_data           = wa_techn_data
    TABLES
      variant_values       = itab_variant_values
    EXCEPTIONS
      variant_non_existent = 1
      variant_obsolete     = 2
      OTHERS               = 3.
  READ TABLE itab_variant_values WITH KEY selname = 'P_DATE'.
  IF sy-subrc = 0.
    SELECT SINGLE * FROM usr01 WHERE bname = sy-uname.
    CALL FUNCTION 'DATE_STRING_CONVERT' "格式化日期转为内部日期
      EXPORTING
        date_format = usr01-datfm
        date_string = itab_variant_values-low
      IMPORTING
        result_date = tmpdate.

    tmpdate = tmpdate + 1.
    itab_variant_values-low = tmpdate.
    MODIFY itab_variant_values  INDEX sy-tabix.
  ENDIF.
  CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
    EXPORTING
      curr_report               = l_report
      curr_variant              = l_varia
      vari_desc                 = wa_techn_data
    TABLES
      vari_contents             = itab_variant_values
    EXCEPTIONS
      illegal_report_or_variant = 1
      illegal_variantname       = 2
      not_authorized            = 3
      not_executed              = 4
      report_not_existent       = 5
      report_not_supplied       = 6
      variant_doesnt_exist      = 7
      variant_locked            = 8
      selections_no_match       = 9
      OTHERS                    = 10.

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

下一篇: 财务报表版本
请登录后发表评论 登录
全部评论

注册时间:2009-07-15

  • 博文量
    5
  • 访问量
    7810