ABAP--SAP的SCreen录入的简单模板

本文档介绍了如何在SAP中使用ABAP编程语言创建一个简单的屏幕录入模板,用于管理部门年度预算考核额调整。程序包括主程序单元、屏幕输出模块、输入模块和函数说明单元,涉及数据表操作、输入帮助和数据验证等功能。
摘要由CSDN通过智能技术生成

1、主程序单元

************************************************************************
* Copyright 2003                                         *
* All Rights Reserved                                                  *
*----------------------------------------------------------------------*
* Program Name : ZFIE0005                                              *
* TYPE         : REPORT                                                *
* Project      :SAP Implementation Project                     *
* Program Title: 管理部门年度预算考核额调整
* Created by   : DEV01                                                 *
* Created on   :
* Version      : 1.0                                                   *
* Function Description:                                                *
* 管理部门年度预算考核额调整
*----------------------------------------------------------------------*
*操作数据表
*ZFI017
*----------------------------------------------------------------------*
*引用数据表
*
*----------------------------------------------------------------------*
* Modification Log:                                                    *
* Date        Programmer     Correction Number      DesingDoc Number   *
************************************************************************
include zfie0032top."全局变量说明但愿
include zfie0032o01."输出Module说明单元
include zfie0032i01."输入Module说明单元
include zfie0032f01."共用函数说明单元
include zfie0032fi1."输入函数说明单元
include zfie0032fi2."输入函数说明单元
include zfie0032h01."输入帮助说明单元 

2、 zfie0032top单元
************************************************************************
* Copyright 2003                                       *
* All Rights Reserved                                                  *
*----------------------------------------------------------------------*
* Program Name : ZFIE0005                                              *
* TYPE         : REPORT                                                *
* Project      :SAP Implementation Project                     *
* Program Title: 管理部门年度预算考核额调整
* Created by   : DEV01                                                 *
* Created on   :
* Version      : 1.0                                                   *
* Function Description:                                                *
* 管理部门年度预算考核额调整
*----------------------------------------------------------------------*
*操作数据表
*ZFI017
*----------------------------------------------------------------------*
*引用数据表
*
*----------------------------------------------------------------------*
* Modification Log:                                                    *
* Date        Programmer     Correction Number      DesingDoc Number   *
************************************************************************
report zfie0030 message-id zdev.
constants: con_show(6)   value 'SHOW',
           con_change(6) value 'CHANGE'.
class cl_gui_cfw definition load.
tables: zfi017v,*zfi017v,bseg,setheadert,zfi010,zfi017,csku,cskt. "
*公司,年份,次数的新旧值
data: v_bukrs like zfi017-bukrs,
      v_gjahr like zfi017-gjahr,
      v_zmon  like zfi017-zmon,
      v_oldbukrs like zfi017-bukrs,
      v_oldgjahr like zfi017-gjahr,
      v_oldzmon  like zfi017-zmon.
*grid的控件
controls: tctrl_order  type tableview using screen '0100'.
data: col type cxtab_column.
* Table for all entries loaded from database
data:   begin of order_extract occurs 0100.
        include structure zfi017v.
        include structure vimflagtab.
data: end of order_extract.
* Table for entries selected to show on screen
data: begin of order_total occurs 10.
        include structure zfi017v.
        include structure vimflagtab.
data: end of order_total.
*记录数据的状态信息的变量定义
data: begin of status_order. "state vector
        include structure vimstatus.
data: end of status_order.
data:  grid_item   type i.
data: answer(1)   type c,
      actionmode(6),
      datastate(1),
      mark_total   type i,
      init(1),
      first_flag(1).
data: wa_zfi017v type zfi017v.
data: ok_code like sy-ucomm,
      save_ok like sy-ucomm.           "OK-Code
data  g_return_code type i.
data: vim_marked(1) type c.                "mark-checkbox field
*存储屏幕选择的字段名
data  indexfldname(30).
data: gt_fieldcatalog  type lvc_t_fcat,
      text(70).
**********************************************************
*用于帮助的变量说明
*屏幕字段的帮助函数使用的变量
*用于成本要素组的属于帮助
data: begin of i_zfi010 occurs 0,
      name like zfi010-name,
end of i_zfi010.
*用于成本中心的输入帮助
data: begin of i_setheadert occurs 0,
        ktext like cskt-ktext,
      end of i_setheadert.
data: butxt like t001-bukrs.
data: ktext like cskt-kostl.
data: name like zfi010-name.
*用于输入帮助,存储帮助函数的通讯内表
data:    begin of fldtab occurs 2.
        include structure help_value.
data:    end of fldtab.
data:    f4dyn          like sy-dynnr.
data:    begin of f4hlp occurs 1.
        include structure dynpread.
data:    end of f4hlp.

3、ZFIE0032O01单元
************************************************************************
* Copyright 2003 C-Bons Wuhan                                          *
* All Rights Reserved                                                  *
*----------------------------------------------------------------------*
* Program Name : ZFIE0005                                              *
* TYPE         : REPORT                                                *
* Project      :  SAP Implementation Project                     *
* Program Title: 管理部门年度预算考核额调整
* Created by   : DEV01                                                 *
* Created on   :
* Version      : 1.0                                                   *
* Function Description:                                                *
* 管理部门年度预算考核额调整
*----------------------------------------------------------------------*
*操作数据表
*ZFI017
*----------------------------------------------------------------------*
*引用数据表
*
*----------------------------------------------------------------------*
* Modification Log:                                                    *
* Date        Programmer     Correction Number      DesingDoc Number   *

************************************************************************
************************************************************************
*&Form Name    : init_data
* Created by   : DEV01                                                 *
* Created on   :
*----------------------------------------------------------------------*
* Function Description:                                                *
*根据用户输入条件的变化,进行数据读取
*----------------------------------------------------------------------*
*参数说明 
*
*----------------------------------------------------------------------*
* Date        Programmer   Description          *

************************************************************************
module init_data output.
  if first_flag eq space.
    first_flag = 'X'.
    v_gjahr = sy-datum+0(4).
    bseg-pswsl = 2.
  endif.
  if ( v_oldgjahr ne v_gjahr or v_oldbukrs ne v_bukrs and
    v_oldzmon ne v_zmon ) and
    v_gjahr ne space and  v_bukrs ne space and v_zmon ne space.
    perform fill_data.
  else.
*    SET CURSOR FIELD f LINE lin OFFSET o.
  endif.
endmodule.                 " init_data  OUTPUT
************************************************************************
*&Form Name    : init_pbo
* Created by   : DEV01                                                 *
* Created on   :
*----------------------------------------------------------------------*
* Function Description:                                                *
*设置标题栏和工具条按钮
*----------------------------------------------------------------------*
*参数说明 
*
*----------------------------------------------------------------------*
* Date        Programmer   Description          *

************************************************************************
module init_pbo output.
  set pf-status 'MAIN100'.
  set titlebar 'MAINTITLE'.
endmodule.                             " PBO  OUTPUT
************************************************************************
*&Form Name    :liste_show_liste
* Created by   : DEV01                                                 *
* Created on   :
*----------------------------------------------------------------------*
* Function Description:                                                *
*将显示数据写到显示字段中,并设置主键字段是否可输入
*----------------------------------------------------------------------*
*参数说明 
*
*----------------------------------------------------------------------*
* Date        Programmer   Description          *

************************************************************************
module liste_show_liste output.
  if tctrl_order-current_line gt tctrl_order-lines.
    exit from step-loop.
  endif.
  grid_item = sy-loopc.
  zfi017v-kostl = order_extract-kostl.
  zfi017v-ktext = order_extract-ktext.
  zfi017v-kstar = order_extract-kstar.
  zfi017v-descript = order_extract-descript.
  zfi017v-adamt = order_extract-adamt.
  zfi017v-reasn = order_extract-reasn.
  zfi017v-zyearmonth = order_extract-zyearmonth.
  vim_marked = order_extract-mark.
  loop at screen.
    if ( order_extract-action = 'L'
     and screen-name = 'VIM_MARKED' ).
      screen-input = 0.
      modify screen.
    endif.
    if ( zfi017v-kostl ne space
     and screen-name = 'ZFI017V-KOSTL' ) or
     ( zfi017v-kstar ne space
     and screen-name = 'ZFI017V-KSTAR' ) .
      screen-input = 0.
      modify screen.
    endif.
  endloop.
  if vim_marked = 'M'.
    vim_marked = 'X'.
  endif.
endmodule.                 " LISTE_SHOW_LISTE  OUTPUT
************************************************************************
*&Form Name    : fill_data
* Created by   : DEV01                                                 *
* Created on   :
*----------------------------------------------------------------------*
* Function Description:                                                *
*根据用户输入读取数据并初试化状态变量
*----------------------------------------------------------------------*
*参数说明 
*
*----------------------------------------------------------------------*
* Date        Programmer   Description          *

************************************************************************
form fill_data .
  select *
    into corresponding fields of order_extract
  from zfi017
  where zfi017~bukrs = v_bukrs
    and zfi017~gjahr = v_gjahr
    and zfi017~zmon = v_zmon.
    select single cskt~ktext as descript
      into (order_extract-descript)
      from cskt
      where spras = '1'
        and kokrs = '1000'
        and kostl = order_extract-kostl.
    select single ktext
    into (order_extract-ktext)
    from csku
    where spras = '1' and ktopl ='CB00'
          and kstar = order_extract-kstar.
    append order_extract.
  endselect.
  sort order_extract by bukrs gjahr kostl kstar.
*  order_extract[] = order_total[].
  if actionmode = con_change.
    perform insert_newworkarea using grid_item.
  endif.
  describe table order_extract lines tctrl_order-lines.
  tctrl_order-top_line = 1.
  clear ok_code.
  mark_total = 1.
  clear:datastate,status_order.

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值