ABAP 自建透明表维护
*&---------------------------------------------------------------------*
*& Report ZMMR011
*&
*&---------------------------------------------------------------------*
*&程序名称:供应商、工厂对应公里数维护
*&事物代码:ZMM031
*&导入模板:无
*&作者:
*&时间:2016/3/2
*&更新时间:2016/3/3
*&---------------------------------------------------------------------*
REPORT zmmr011.
TABLES: tvbvk ,cskt ,ztmm002.
TYPES:ty_xs LIKE v_tvbur.
DATA:gt_xs LIKE TABLE OF v_tvbur.
DATA:wa_xs TYPE v_tvbur.
DATA:edit(1) VALUE ''."ALV是否处于可编辑状态
DATA:lt_lfa1 TYPE lfa1 OCCURS 0 WITH HEADER LINE. "供应商内表
DATA:lt_t001w TYPE t001w OCCURS 0 WITH HEADER LINE."工厂内表
FIELD-SYMBOLS: <f1>, <f2>, <f3>.
TYPES:BEGIN OF ty_tab.
INCLUDE TYPE ztmm002.
TYPES: lifnr_name LIKE lfa1-name1,
werks_name LIKE t001w-name1.
TYPES:END OF ty_tab.
DATA :gt_zz TYPE STANDARD TABLE OF ty_tab .
DATA:wa_zz TYPE ty_tab.
FORM get_data.
* CALL FUNCTION 'VIEW_GET_DATA'
* EXPORTING
* view_name = 'V_TVBUR'
* TABLES
* data = gt_xs.
SELECT *
FROM lfa1
INTO CORRESPONDING FIELDS OF TABLE lt_lfa1.
SELECT *
FROM t001w
INTO CORRESPONDING FIELDS OF TABLE lt_t001w.
SELECT *
FROM ztmm002
INTO CORRESPONDING FIELDS OF TABLE gt_zz.
LOOP AT gt_zz INTO wa_zz.
READ TABLE lt_lfa1 WITH KEY lifnr = wa_zz-lifnr.
wa_zz-lifnr_name = lt_lfa1-name1.
READ TABLE lt_t001w WITH KEY werks = wa_zz-werks.
wa_zz-werks_name = lt_t001w-name1.
MODIFY gt_zz FROM wa_zz.
ENDLOOP.
ENDFORM.
DATA: gs_fcat TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo,
gs_grid TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event WITH HEADER LINE,
gt_event_exit TYPE slis_t_event_exit WITH HEADER LINE.
DATA: ref_grid TYPE REF TO cl_gui_alv_grid .
"parameters: p_ds type c as checkbox.
START-OF-SELECTION.
PERFORM get_data.
PERFORM show_data_to_alv.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_modify
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified et_good_cells.
METHODS data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_modify.
* PERFORM refresh.
DATA stbl TYPE lvc_s_stbl.
stbl-row = 'X'." 基于行的稳定刷新
stbl-col = 'X'." 基于列稳定刷新
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable = stbl.
ENDMETHOD.
METHOD data_changed.
DATA: ls_mod_cells TYPE lvc_s_modi,
tvalue TYPE string.
DATA: ls_stable TYPE lvc_s_stbl.
DATA: l_message TYPE string.
*
DATA:wa_lfa1 TYPE lfa1.
DATA:wa_t001w TYPE t001w.
DATA:row_no TYPE i.
CHECK er_data_changed->mt_inserted_rows[] IS INITIAL.
LOOP AT er_data_changed->mt_good_cells INTO ls_mod_cells.
CLEAR tvalue.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
IMPORTING
e_value = tvalue.
IF ls_mod_cells-fieldname EQ 'LIFNR'.
LOOP AT lt_lfa1 INTO wa_lfa1 .
IF wa_lfa1-lifnr EQ tvalue.
CALL METHOD er_data_changed->modify_cell
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'LIFNR_NAME'
i_value = wa_lfa1-name1.
EXIT.
ENDIF.
CLEAR lt_lfa1.
ENDLOOP.
ENDIF.
IF ls_mod_cells-fieldname EQ 'WERKS'.
LOOP AT lt_t001w INTO wa_t001w.
IF wa_t001w-werks EQ tvalue.
CALL METHOD er_data_changed->modify_cell
EXPORTING
i_row_id = ls_mod_cells-row_id
i_fieldname = 'WERKS_NAME'
i_value = wa_t001w-name1.
EXIT.
ENDIF.
CLEAR wa_t001w.
ENDLOOP.
ENDIF.
* DATA:blank_zz TYPE ztmm002.
*
*
*
* LOOP AT tab_tvgrt INTO wa_tvgrt .
* IF wa_tvgrt-vkgrp EQ tvalue.
* CLEAR wa_zz.
* LOOP AT gt_zz INTO wa_zz.
* IF wa_zz-vkgrp EQ tvalue AND tvalue NE ''.
* MESSAGE i001(00) WITH '已有相同的销售组!'.
*
* "MODIFY gt_zz INDEX ls_mod_cells-row_id FROM blank_zz .
* CLEAR wa_tvgrt.
* "如果有重复的销售组,那么将输入的销售组清空
* CALL METHOD er_data_changed->modify_cell
* EXPORTING
* i_row_id = ls_mod_cells-row_id
* i_fieldname = 'VKGRP'
* i_value = ''.
* ENDIF.
*
* CONTINUE.
* ENDLOOP.
*
* CALL METHOD er_data_changed->modify_cell
* EXPORTING
* i_row_id = ls_mod_cells-row_id
* i_fieldname = 'VKGRPTEXT'
* i_value = wa_tvgrt-bezei.
* ENDIF.
* CLEAR wa_tvgrt.
* ENDLOOP.
*
* IF strlen( tvalue ) GT 4.
*
*
* LOOP AT tab_cskt INTO wa_cskt .
* IF wa_cskt-kostl EQ tvalue.
* CALL METHOD er_data_changed->modify_cell
* EXPORTING
* i_row_id = ls_mod_cells-row_id
* i_fieldname = 'LTEXT'
* i_value = wa_cskt-ltext.
* EXIT.
* ENDIF.
* CLEAR wa_cskt.
* ENDLOOP.
* ENDIF.
ENDLOOP.
ENDMETHOD. "HANDLE_MODIFY
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
DATA gt_event_receiver TYPE REF TO lcl_event_receiver .
FORM show_data_to_alv.
CLEAR gt_fcat[].
PERFORM set_fcat USING edit.
PERFORM set_layout.
PERFORM show_alv TABLES gt_fcat gt_zz[]
USING gs_layo.
ENDFORM.
FORM frm_edit_alv." TABLES GT.
*DATA: ls_row TYPE lvc_s_cell,
* lt_rows TYPE lvc_t_cell.
* "CLEAR GT_HEADER.
* "CLEAR GT_ITEMS.
* CALL METHOD ref_grid->GET_SELECTED_CELLS
* IMPORTING
* et_index_cells = lt_rows
ENDFORM.
FORM show_changed_alv.
CLEAR gt_fcat[].
* IF edit EQ '' .
* edit = 'X'.
* ELSE.
* edit = ''.
* ENDIF.
PERFORM set_fcat USING edit.
PERFORM set_layout.
PERFORM show_alv TABLES gt_fcat gt_zz[]
USING gs_layo.
PERFORM frm_edit_alv.
ENDFORM.
FORM set_fcat USING edit.
PERFORM csalv_set_fcat USING :
" 'Field' 'Text' 'Edit' 'Zero' 'Type' 'Qfieldname' 'Key' 'Hostspot' 'Emphasize' 'Checkbox'
'LIFNR' '供应商或债权人账号' edit '' '' '' '' '' '' '' '' '' '' 'X' 'ZTMM002' 'LIFNR',
'LIFNR_NAME' '供应商名称' '' '' '' '' '' '' '' '' '' '' '' '' '' '',
'WERKS' '工厂' edit '' '' '' '' '' '' '' '' '' '' 'X' 'ZTMM002' 'WERKS',
'WERKS_NAME' '工厂名称' '' '' '' '' '' '' '' '' '' '' '' '' '' '',
'MENGE' '数量' edit '' '' '' '' '' '' '' '' '' '' 'X' '' '',
'MEINS' '单位' edit '' '' '' '' '' '' '' '' '' '' 'X' '' ''.
"'KOSTL' '成本中心' edit '' '' '' '' '' '' '' '' '' '' 'X' 'CSKS' 'KOSTL' ,
"'LTEXT' '成本中心描述' '' '' '' '' '' '' '' '' '' '' '' '' '' '' .
* 'ADD01' '车主' '' '' '' '' '' '' '' '' '' '' '',
* 'EXTI1' '卸货点' '' '' '' '' '' '' '' '' '' '' '',
* 'ADD02' '司机' '' '' '' '' '' '' '' '' '' '' '',
* 'BFART' '车厢类型' '' '' '' '' '' '' '' '' '' '0' '',
*
* 'BEIZHU' '备注' 'X' '' '' '' '' '' '' '' '' '' 'X'.
" 'zsel' '是否打印 ' 'X' '' '' '' '' '' '' 'X' ''.
ENDFORM. " SET_FCAT
FORM set_layout .
gs_layo
-zebra = 'X'.
* gs_layout-stylefname = 'FIELD_STYLE'.
gs_layo
-cwidth_opt = 'X'.
ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
FORM csalv_set_fcat USING
p_name
p_text
p_edit
p_zero
p_type
p_qfieldname
p_key
p_hotspot
p_emphasize
p_checkbox
p_do_sum
p_decimals_out
p_no_out
p_f4availabl
p_ref_table
p_ref_field
.
gs_fcat
-fieldname = p_name.
* gs_fcat-reptext_l =
* gs_fcat-selddictxt =
gs_fcat
-reptext = p_text.
gs_fcat
-edit = p_edit.
gs_fcat
-no_zero = p_zero.
gs_fcat
-datatype = p_type.
gs_fcat
-qfieldname = p_qfieldname.
gs_fcat
-key = p_key.
gs_fcat
-hotspot = p_hotspot.
gs_fcat
-emphasize = p_emphasize.
gs_fcat
-checkbox = p_checkbox.
gs_fcat
-do_sum = p_do_sum.
gs_fcat
-decimals_o = p_decimals_out.
gs_fcat
-no_out = p_no_out.
gs_fcat
-f4availabl = p_f4availabl.
gs_fcat
-ref_table = p_ref_table.
gs_fcat
-ref_field = p_ref_field.
APPEND gs_fcat TO gt_fcat.
ENDFORM. "csalv_set_fcat
FORM show_alv TABLES pt_fcat
pt_tab
USING ps_layout.
gs_grid
-edt_cll_cb = 'X'."当屏幕失去焦点时,自动刷新
gt_event
-name = 'CALLER_EXIT'. "slis_ev_caller_exit_at_start事件
gt_event
-form = 'FM_BUTTON'.
APPEND gt_event .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program
= sy-repid
i_callback_user_command
= 'USER_COMMAND'
i_grid_settings
= gs_grid
i_callback_pf_status_set
= 'SET_PF_STATUS'
is_layout_lvc
= ps_layout
it_fieldcat_lvc
= pt_fcat[]
it_events
= gt_event[]
* it_event_exit = gt_event_exit[]
TABLES
t_outtab
= pt_tab
EXCEPTIONS
program_error
= 1
OTHERS = 2.
ENDFORM. "csalv_set_fcat
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield
TYPE slis_selfield.
CASE r_ucomm.
WHEN '&CHANGE'.
IF edit EQ '' .
edit = 'X'.
ELSE.
edit = ''.
ENDIF.
PERFORM show_changed_alv.
WHEN '&BACK'.
LEAVE PROGRAM.
WHEN '&ADD_ROW'.
* CLEAR wa_zz.
* DATA:end TYPE i.
* DESCRIBE TABLE gt_zz LINES end.
*
* READ TABLE gt_zz INDEX end INTO wa_zz.
* IF wa_zz-vkbur IS INITIAL AND gt_zz is NOT INITIAL .
* MESSAGE i001(00) WITH '不能继续添加行!'.
* exit.
* ENDIF.
"edit = ''.
CLEAR wa_zz.
IF edit EQ 'X'.
APPEND wa_zz TO gt_zz.
"PERFORM show_changed_alv.
PERFORM show_data_to_alv.
ENDIF.
WHEN '&SAVE_DATA'.
DATA:lt_ztmm002 TYPE TABLE OF ztmm002.
DATA:wa_ztmm002 TYPE ztmm002.
CLEAR wa_ztmm002.
DELETE FROM ztmm002 .
MOVE-CORRESPONDING gt_zz TO lt_ztmm002.
IF lt_ztmm002 IS NOT INITIAL.
LOOP AT lt_ztmm002 INTO wa_ztmm002 .
IF wa_ztmm002-lifnr IS NOT INITIAL AND wa_ztmm002-werks IS NOT INITIAL.
INSERT INTO ztmm002 VALUES wa_ztmm002 .
ENDIF.
ENDLOOP.
ENDIF.
IF sy-subrc EQ 0.
MESSAGE i001(00) WITH '保存成功!'.
ELSE.
MESSAGE i001(00) WITH '保存失败!'.
ENDIF.
WHEN '&DELE_ROW'.
DATA:ls_row TYPE lvc_s_row,
lt_rows
TYPE lvc_t_row.
DATA:del_rows TYPE STANDARD TABLE OF ty_tab.
CALL METHOD ref_grid->get_selected_rows
IMPORTING
et_index_rows
= lt_rows
* et_row_no =
.
CLEAR wa_zz.
LOOP AT lt_rows INTO ls_row.
READ TABLE gt_zz INTO wa_zz INDEX ls_row-index.
"delete gt_zz INDEX ls_row-index.
"DELETE ztmm002 FROM wa_zz.
APPEND wa_zz TO del_rows.
ENDLOOP.
LOOP AT del_rows INTO wa_zz.
DELETE TABLE gt_zz FROM wa_zz.
ENDLOOP.
CLEAR del_rows.
CLEAR ls_row.
CLEAR lt_rows.
PERFORM show_changed_alv.
ENDCASE.
ENDFORM.
FORM set_pf_status USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'STANDARD'.
ENDFORM. "SET_PF_STATUS
FORM fm_button USING e_grid TYPE slis_data_caller_exit.
DATA: lt_f4 TYPE lvc_t_f4,
ls_f4
TYPE lvc_s_f4.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* EXPORTING
* IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
* ET_EXCLUDING =
* E_REPID =
* E_CALLBACK_PROGRAM =
* E_CALLBACK_ROUTINE =
e_grid
= ref_grid
* ET_FIELDCAT_LVC =
* ER_TRACE =
* E_FLG_NO_HTML =
* ES_LAYOUT_KKBLO =
* ES_SEL_HIDE =
* ET_EVENT_EXIT =
* ER_FORM_TOL =
* ER_FORM_EOL =
.
* CALL METHOD ref_grid->check_changed_data.
* 设置enter事件
CALL METHOD ref_grid->register_edit_event
EXPORTING
i_event_id
= cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error
= 1
OTHERS = 2.
CREATE OBJECT gt_event_receiver.
SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
SET HANDLER gt_event_receiver->data_changed FOR ref_grid.
ENDFORM.
ABAP 自建透明表维护的更多相关文章
- 通过ABAP程序创建透明表
最近在解决用户账号问题的时候,需要通过ABAP程序创建透明表,查询了相关资料,总结如下. 通过ABAP程序创建透明表,主要利用了4个函数: DDIF_TABL_ACTIVATE: 激活透明表 GOX_ ...
- abap 开发之创建表维护生成器
在sap开发中有时需要对一些自建表维护数据,但又不想写程序,怎么办呢??这个时候我们可以直接生成个表维护生成器,为其定义一个事物码就ok了.以下是表格维护生成器的生成步骤. 首先我们需要先定义表.输入 ...
- sap透明表、结构、簇介绍以及查找表方法
sap透明表.结构.簇介绍以及查找表方法 一些人在写开发功能说明书的时候不知道如何去找屏幕字段对应的透明表,下面我来介绍一个比较有效的方法:首先简单介绍一下概念:在SAP中的表的种类有以下三种:Tra ...
- ABAP简单表维护的制作
为了知识的积累,特作了个简单的表维护. 因为自己之前做dynpro程序的时候建了一个Tree node的表,所以就不在此重复.(在表的交付和维护页签中标的属性要是‘允许标准表维护的’) 直接Alt+U ...
- 【ABAP系列】SAP ABAP 为表维护生成器创建事务代码
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 为表维护生成器 ...
- SAP 透明表之间的关联字段
VTTK-TPLST=TTDST-TPLST(装运点的关联表及描述表字段TTDST-BEZEI) VTTK-ROUTE=TVROT-ROUTE(装运线路关联表及描述表字段TVROT-BEZEI) VT ...
- sm30表维护做排序
好吧,之前有人问过,因为代码太少就一直没发...今天给出来吧 众所周知,表维护其实就是个TC,只是表维护是统一的,没有使用通用名内表名什么的,这个就不多说了,来重点: TC的一般排序可以放在:1,PB ...
- SAP 通过屏幕字段查看透明表
我要查看创建采购订单屏幕上抬头部分付款条件的这个透明表中的字段. 图1. 1.首先准备好MM模块中的常用透明表. 图2. 2.把光标放在字段上,按F1,再点击图中技术信息按钮. 图3. 3.在弹出的技 ...
- sap表维护工具来维护自定义表&视图簇的使用
一.通过表维护工具维护自定义表 1.SE11创建表 2.se11界面的菜单:实用程序->Table Maintenance Generator其实这里就是调用SE54 3.sm30 调用维护好的 ...
随机推荐
- 深入浅出JMS(一)--JMS基本概念
from:http://blog.csdn.net/jiuqiyuliang/article/details/46701559 深入浅出JMS(一)--JMS基本概念 标签: jmsmessagin ...
- Ubuntu之Mysql安装及基本设置
No1. Mysql 安装 sudo apt-get install mysql-server mysql-client 记得root密码别忘了. No2. 验证Mysql安装 sudo servic ...
- python4delphi 使用
Python 开发桌面程序, 之前写过一个使用IronPython的博客. 下面这个方案使用 delphi 作为主开发语言,通过 python4delphi 控件包将 python 作为 script ...
- (1)apply族函数总论
来自为知笔记(Wiz) 附件列表
- 使用原生JS封装Ajax
使用原生 的JS封装 Ajax,实现 仿JQuery的Ajax,post,get三种异步请求方式: var MAjax = { //根据浏览器创建异步对象 createXhr: function () ...
- 【PHP面向对象(OOP)编程入门教程】3.什么是面向对象编程呢?
就不说他的概念,如果你想建立一个电脑教室,首先要有一个房间, 房间里面要有N台电脑,有N个桌子, N个椅子, 白板, 投影机等等,这些是什么,刚才咱们说了, 这就是对象,能看到的一个个的实体,可以说这 ...
- jersey
http://www.cnblogs.com/bluesfeng/archive/2010/10/28/1863816.html
- leofs存储总结
1.leofs角色 Account(账户).Bucket(对象桶).Object(对象), gateway.manager0.manager1.storage Account 一个account可以创 ...
- 【转】MySQL数据类型和常用字段属性总结
来源:http://www.jb51.net/article/55853.htm 这里先总结数据类型.MySQL中的数据类型大的方面来分,可以分为:日期和时间.数值,以及字符串.下面就分开来进行总结. ...
- 剑指Offer 从上往下打印二叉树(dfs)
题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 思路: 用一个队列来辅助,先压入根节点,设置一个指针记录队列头位置,判断队头指针有没有孩子,有压入左右孩子,,,操作完一次,队头出 ...