关于SAP ABAP table control 显示数据、修改数据的问题
我用screenpainter画了个屏幕,然后在选项卡内建了个与内表相联系的tablecontrol,(1)显示数据:tablecontrol是能得到数据的,但刚进屏幕时...
我用screen painter画了个屏幕,然后在选项卡内建了个与内表相联系的table control,
(1)显示数据:table control是能得到数据的,但刚进屏幕时,table control并没有显示数据,需要回车或点击什么才能显示出来,这是什么原因啊,要怎么改代码啊?
(2)修改数据:现在要修改table control内的数据,但修改数据后回车,数据还是原来的数据,并没有修改成功,这是什么原因啊,要怎么改代码啊? 展开
(1)显示数据:table control是能得到数据的,但刚进屏幕时,table control并没有显示数据,需要回车或点击什么才能显示出来,这是什么原因啊,要怎么改代码啊?
(2)修改数据:现在要修改table control内的数据,但修改数据后回车,数据还是原来的数据,并没有修改成功,这是什么原因啊,要怎么改代码啊? 展开
3个回答
2012-05-10
展开全部
问题1:取内表数据你改到pbo事件中完成(显示table control前)。
目前可能你写到pai才会造成回车后才能显示数据。。。
问题2:追加modify命令
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TBL_9000'
LOOP AT ITAB_9100.
CHAIN.
FIELD H_9100-MATNR.
FIELD H_9100-ERSDA.
MODULE TBL_9000_MODIFY ON CHAIN-REQUEST.
endchain.
ENDLOOP.
module TBL_9000_MODIFY input.
MODIFY ITAB_9100
FROM H_9100
INDEX TBL_9000-CURRENT_LINE.
endmodule. " TBL_9000_MODIFY INPUT
目前可能你写到pai才会造成回车后才能显示数据。。。
问题2:追加modify命令
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TBL_9000'
LOOP AT ITAB_9100.
CHAIN.
FIELD H_9100-MATNR.
FIELD H_9100-ERSDA.
MODULE TBL_9000_MODIFY ON CHAIN-REQUEST.
endchain.
ENDLOOP.
module TBL_9000_MODIFY input.
MODIFY ITAB_9100
FROM H_9100
INDEX TBL_9000-CURRENT_LINE.
endmodule. " TBL_9000_MODIFY INPUT
追问
这些不是自动生成的代码吗?
我的还是修改不了啊。。
追答
MODULE TBL_9000_MODIFY ON CHAIN-REQUEST.
module TBL_9000_MODIFY input.
MODIFY ITAB_9100
FROM H_9100
INDEX TBL_9000-CURRENT_LINE.
endmodule. " TBL_9000_MODIFY INPUT
这两块代码需要你加进去,很容易的
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
展开全部
TABLE CONTROL里面最初显示界面是 PBO显示的,按钮是先触发了PAI ,然后走PBO的,所以在要写在PBO里面
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
主程序:
*声明table control里面表控件使用的结构
TABLES demo_conn.
*声明table control
CONTROLS sflight TYPE TABLEVIEW USING SCREEN 100.
*定义control cols表的行工作区
DATA col LIKE LINE OF sflight-cols.
*定义一个整型变量用来存储内表行数
DATA fill TYPE i.
*定义内表用来填充control的table
DATA itab TYPE STANDARD TABLE OF demo_conn.
*定义OK_CODE 存储ftcode
DATA ok_code TYPE sy-ucomm.
DATA ok_save TYPE sy-ucomm.
*---------------------------------------------------------*
*Event blocks *
*---------------------------------------------------------*
*start-of-selection event---------------------------------
START-OF-SELECTION.
*获取数据
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE itab.
*取得内表行数
DESCRIBE TABLE itab LINES fill.
*初始化table control的行数
sflight-lines = fill.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* 设置菜单 工具 栏
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_001'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module MODIFY_CT INPUT
*&---------------------------------------------------------------------*
* 更新内表
*----------------------------------------------------------------------*
MODULE modify_ct INPUT.
MODIFY itab FROM demo_conn INDEX sflight-current_line.
ENDMODULE. " MODIFY_CT INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* 处理那些按钮事件
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
ok_save = ok_code.
CLEAR ok_code.
CASE ok_save.
WHEN 'CHANGE'.
*当点击修改按钮,此时要需要修改control cols的input属性(cols包含所有列相关信息)
LOOP AT sflight-cols INTO col WHERE index GT 2.
IF col-screen-input EQ '1'.
col-screen-input = '0'.
modify sflight-cols from col index sy-tabix.
ELSEIF col-screen-input EQ '0'.
col-screen-input = '1'.
modify sflight-cols from col index sy-tabix.
ELSE.
ENDIF.
ENDLOOP.
*当点击sort_down按钮,此时需要对内表针对选中的地列进行排序
WHEN 'SORT_DOWN'.
READ TABLE sflight-cols INTO col WITH KEY selected = 'X'.
IF sy-subrc = 0.
SORT itab BY (col-screen-name+10) DESCENDING.
col-selected = ''.
MODIFY sflight-cols FROM col INDEX sy-tabix.
ENDIF.
*当点击sort_up按钮。。。。 。。。
WHEN 'SORT_UP'.
READ TABLE sflight-cols INTO col WITH KEY selected = 'X'.
IF sy-subrc = 0.
SORT itab BY (col-screen-name+10) ASCENDING.
col-selected = ''.
MODIFY sflight-cols FROM col INDEX sy-tabix.
ENDIF.
*当点击删除按钮,此时需要更新内表
WHEN 'DELETE'.
READ TABLE sflight-cols INTO col WITH KEY screen-input = '1'.
IF sy-subrc = 0.
LOOP AT itab INTO demo_conn WHERE mark = 'X'.
DELETE itab INDEX sy-tabix.
ENDLOOP.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
* 读取内表数据
*----------------------------------------------------------------------*
MODULE read_data OUTPUT.
READ TABLE itab INTO demo_conn INDEX sflight-current_line.
ENDMODULE. " READ_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Module CANCEL INPUT
*&---------------------------------------------------------------------*
* 强制退出
*----------------------------------------------------------------------*
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE. " CANCEL INPUT
屏幕逻辑流:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
LOOP WITH CONTROL sflight.
MODULE read_data.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP WITH CONTROL sflight.
MODULE modify_ct.
ENDLOOP.
MODULE user_command_0100.
*声明table control里面表控件使用的结构
TABLES demo_conn.
*声明table control
CONTROLS sflight TYPE TABLEVIEW USING SCREEN 100.
*定义control cols表的行工作区
DATA col LIKE LINE OF sflight-cols.
*定义一个整型变量用来存储内表行数
DATA fill TYPE i.
*定义内表用来填充control的table
DATA itab TYPE STANDARD TABLE OF demo_conn.
*定义OK_CODE 存储ftcode
DATA ok_code TYPE sy-ucomm.
DATA ok_save TYPE sy-ucomm.
*---------------------------------------------------------*
*Event blocks *
*---------------------------------------------------------*
*start-of-selection event---------------------------------
START-OF-SELECTION.
*获取数据
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE itab.
*取得内表行数
DESCRIBE TABLE itab LINES fill.
*初始化table control的行数
sflight-lines = fill.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* 设置菜单 工具 栏
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_001'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module MODIFY_CT INPUT
*&---------------------------------------------------------------------*
* 更新内表
*----------------------------------------------------------------------*
MODULE modify_ct INPUT.
MODIFY itab FROM demo_conn INDEX sflight-current_line.
ENDMODULE. " MODIFY_CT INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* 处理那些按钮事件
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
ok_save = ok_code.
CLEAR ok_code.
CASE ok_save.
WHEN 'CHANGE'.
*当点击修改按钮,此时要需要修改control cols的input属性(cols包含所有列相关信息)
LOOP AT sflight-cols INTO col WHERE index GT 2.
IF col-screen-input EQ '1'.
col-screen-input = '0'.
modify sflight-cols from col index sy-tabix.
ELSEIF col-screen-input EQ '0'.
col-screen-input = '1'.
modify sflight-cols from col index sy-tabix.
ELSE.
ENDIF.
ENDLOOP.
*当点击sort_down按钮,此时需要对内表针对选中的地列进行排序
WHEN 'SORT_DOWN'.
READ TABLE sflight-cols INTO col WITH KEY selected = 'X'.
IF sy-subrc = 0.
SORT itab BY (col-screen-name+10) DESCENDING.
col-selected = ''.
MODIFY sflight-cols FROM col INDEX sy-tabix.
ENDIF.
*当点击sort_up按钮。。。。 。。。
WHEN 'SORT_UP'.
READ TABLE sflight-cols INTO col WITH KEY selected = 'X'.
IF sy-subrc = 0.
SORT itab BY (col-screen-name+10) ASCENDING.
col-selected = ''.
MODIFY sflight-cols FROM col INDEX sy-tabix.
ENDIF.
*当点击删除按钮,此时需要更新内表
WHEN 'DELETE'.
READ TABLE sflight-cols INTO col WITH KEY screen-input = '1'.
IF sy-subrc = 0.
LOOP AT itab INTO demo_conn WHERE mark = 'X'.
DELETE itab INDEX sy-tabix.
ENDLOOP.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
* 读取内表数据
*----------------------------------------------------------------------*
MODULE read_data OUTPUT.
READ TABLE itab INTO demo_conn INDEX sflight-current_line.
ENDMODULE. " READ_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Module CANCEL INPUT
*&---------------------------------------------------------------------*
* 强制退出
*----------------------------------------------------------------------*
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE. " CANCEL INPUT
屏幕逻辑流:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
LOOP WITH CONTROL sflight.
MODULE read_data.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP WITH CONTROL sflight.
MODULE modify_ct.
ENDLOOP.
MODULE user_command_0100.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询