财务集(set)的使用(gs01,gs02,gs03)

这是一个关于如何在SAP环境中使用集(set)处理财务数据的程序示例,包括从G/L账户主记录中读取月度借方和贷方数据,计算余额,并进行报表打印。程序涉及了输入参数检查、数据检索、平衡计算、行填充、计算和报表填充等步骤。
摘要由CSDN通过智能技术生成

 

REPORT  zfi_set.
        LINE-COUNT 90
        LINE-SIZE  240
        MESSAGE-ID zfi
        NO STANDARD PAGE HEADING .

*----------------------------------------------------------------------*
* TYPES OR TYPE-POOLS
*----------------------------------------------------------------------*

TABLES:
  glt0,   " G/L account master record monthly debit and credit
  t001,
  bkpf.   " 会计核算凭证标题
*----------------------------------------------------------------------*
* CONSTANTS
*----------------------------------------------------------------------*
CONSTANTS:
  c_rldnr    LIKE  glt0-rldnr  VALUE  'ZC',     "分类帐
  c_rrcty    LIKE  glt0-rrcty  VALUE  '0',      "记录类型
  c_rvers    LIKE  glt0-rvers  VALUE  '001',    "版本号
  c_rpmax    LIKE  glt0-rpmax  VALUE  '016',    "会计期间
  c_shkzgd   LIKE  bseg-shkzg  VALUE  'S',      "借方/贷方标识
  c_shkzgc   LIKE  bseg-shkzg  VALUE  'H'.

*----------------------------------------------------------------------*
* PARAMETERS AND SELECT-OPTIONS
*----------------------------------------------------------------------*

PARAMETERS:
  p_bukrs LIKE t001-bukrs OBLIGATORY,     "公司代码
  p_gjahr LIKE bsis-gjahr OBLIGATORY,     "会计年度
  p_monat LIKE bsis-monat OBLIGATORY.     "会计期间
SELECT-OPTIONS:
  s_monat FOR  bkpf-monat.                "因调整不包含的期间

*----------------------------------------------------------------------*
* INTERNAL TABLES AND WORK AREAS
*
*----------------------------------------------------------------------*

DATA:BEGIN OF t_t001 OCCURS 0,
     butxt LIKE t001-butxt,
     END OF t_t001.

DATA:
  BEGIN OF t_glt0 OCCURS 0,
    racct LIKE glt0-racct,  "总帐科目
    hslvt LIKE glt0-hslvt,  "年初余额
    hsl01 LIKE glt0-hsl01,  "第一个会计期间的余额
    hsl02 LIKE glt0-hsl02,
    hsl03 LIKE glt0-hsl03,
    hsl04 LIKE glt0-hsl04,
    hsl05 LIKE glt0-hsl05,
    hsl06 LIKE glt0-hsl06,
    hsl07 LIKE glt0-hsl07,
    hsl08 LIKE glt0-hsl08,
    hsl09 LIKE glt0-hsl09,
    hsl10 LIKE glt0-hsl10,
    hsl11 LIKE glt0-hsl11,
    hsl12 LIKE glt0-hsl12,
    hsl13 LIKE glt0-hsl13,
    hsl14 LIKE glt0-hsl14,
    hsl15 LIKE glt0-hsl15,
    hsl16 LIKE glt0-hsl16,
  END OF t_glt0.
DATA:t_delt LIKE TABLE OF t_glt0 WITH HEADER LINE.
*Store Accounting document header &item data
DATA:
  BEGIN OF t_line OCCURS 0,
    linno(3) TYPE c,
    setid    LIKE rgsbm-shortname,    " 集标识
    hslvt    LIKE glt0-hslvt,
    hslve    LIKE glt0-hslvt,
    drcrk    LIKE glt0-drcrk,         " 借方/贷方标识
  END OF t_line.
DATA:w_line LIKE LINE OF  t_line .
DATA:
  BEGIN OF t_out OCCURS 0,
    desc1(70) TYPE c,                  "科目描述
    linno1(3) TYPE c,                  "行号
    hslvt1(20) TYPE c,
    hslve1(20) TYPE c,
    desc2(70) TYPE c,
    linno2(3) TYPE c,
    hslvt2(20) TYPE c,
    hslve2(20) TYPE c,
  END OF t_out.
DATA:
  BEGIN OF t_monat OCCURS 0,
    monat LIKE bkpf-monat,
  END OF t_monat.
DATA: t_set_values TYPE STANDARD TABLE OF rgsb4 WITH
HEADER LINE.
*Store beginning balance
DATA:
  BEGIN OF t_bal OCCURS 0,
    racct    LIKE   glt0-racct,
    hslvt    LIKE   glt0-hslvt,
    hslve    LIKE   glt0-hslvt,
  END OF t_bal.
DATA:w_lastday LIKE sy-datum,
     gjahr LIKE bkpf-gjahr,
     hslve LIKE glt0-hslvt.
******************************************************
*  A T  S E L E C T I O N  S C R E E N
*
******************************************************
AT SELECTION-SCREEN.
  PERFORM f100_input_check.
  PERFORM f200_authority_check.
************************************************************************
*   B E G I N  S E L E C T I O N
*
************************************************************************
START-OF-SELECTION.
  SET PF-STATUS 'STATUS_1000' .
  PERFORM f200_glt0_read.
  PERFORM f300_bala_calc.
  PERFORM f400_line_fill.
  PERFORM f500_line_calc.
  PERFORM f600_form_fill.
  PERFORM f700_data_calc.

AT USER-COMMAND .
  CASE sy-ucomm .
    WHEN 'FPRINT' .
*form print .
      PERFORM f_print .
    when 'EXIT' OR 'BACK' .
      leave to screen 0 .
  ENDCASE .
  CLEAR sy-ucomm .

 

************************************************************************
*   E N D  O F   S E L E C T I O N
*
************************************************************************
END-OF-SELECTION.
  PERFORM f800_form_prnt.
************************************************************************
*   B E G I N   F O R M S
*
************************************************************************
*&---------------------------------------------------------------------*
*&      Form  F100_input_check
*&---------------------------------------------------------------------*
*  Check input parameters
*
*----------------------------------------------------------------------*
FORM f100_input_check.
  SELECT SINGLE
    periv                  " 会计年度变式
    waers                  " 货币代码
    INTO (t001-periv ,
          t001-waers)
    FROM t001
   WHERE bukrs = p_bukrs.

  CASE sy-subrc.
    WHEN 0.
    WHEN 4.
      MESSAGE e021 WITH p_bukrs.
    WHEN OTHERS.
      MESSAGE e999 WITH 'Read Table'
                        'T001'
                        'Error'
                        space.
  ENDCASE.
  IF p_monat > 16.
    MESSAGE e022.
  ENDIF.
ENDFORM.                    "f100_input_check
*----------------------------------------------------------------------*
*      Form  F200_glt0_read
*
*----------------------------------------------------------------------*
*      Retrieve data from tables
*
*----------------------------------------------------------------------*
FORM f200_glt0_read.
  "Retrieve G/L account master record monthly debit and credit
  SELECT racct
         SUM( hslvt )
         SUM( hsl01 )
         SUM( hsl02 )
         SUM( hsl03 )
         SUM( hsl04 )
         SUM( hsl05 )
         SUM( hsl06 )
         SUM( hsl07 )
         SUM( hsl08 )
         SUM( hsl09 )
         SUM( hsl10 )
         SUM( hsl11 )
         SUM( hsl12 )
         SUM( hsl13 )
         SUM( hsl14 )
         SUM( hsl15 )
         SUM( hsl16 )
    FROM glt0
    INTO TABLE t_glt0
   WHERE bukrs = p_bukrs
     AND ryear = p_gjahr
     AND rrcty = c_rrcty
     AND rvers = c_rvers
     AND rpmax = c_rpmax
    GROUP BY
         racct.

  CASE sy-subrc.
    WHEN 0.
    WHEN 4.
    WHEN OTHERS.
      MESSAGE e999 WITH 'Read Table'
                        'glt0'
                        'Error'
                        space.
  ENDCASE.
  IF s_monat[] IS NOT INITIAL.
    LOOP AT s_monat.
      IF s_monat-high <> ''.
        WHILE t_monat-monat <> s_monat-high.
          IF t_monat-monat = ''.
            t_monat-monat = s_monat-low.
            APPEND t_monat.
          ELSE.
            t_monat-monat = t_monat-monat + 1.
            APPEND t_monat.
          ENDIF.
       

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值