sap abap屏幕编程中使用的table 和call子程序的

简介: 今天下午顾问在和用户谈需求呢,趁这个时间写了个屏幕中使用table 和如何call 子程序的例子,放在这里,有人看也好,没有人看也罢,权当自己练连手.*&------------------------------------------------------...
今天下午顾问在和用户谈需求呢,趁这个时间写了个屏幕中使用table 和如何call 子程序的例子,放在这里,有人看也好,没有人看也罢,权当自己练连手.

*&---------------------------------------------------------------------*
*& Module pool ZCHOUER1 *
*& this program is test for chouer
*&---------------------------------------------------------------------*
PROGRAM ZCHOUER1.

**---tables
TABLES ZEKKP.

**---workaera
DATA BEGIN OF WA_ZEKKP.
INCLUDE STRUCTURE ZEKKP.
DATA END OF WA_ZEKKP.
DATA WA_ZEKK LIKE WA_ZEKKP.

**---Initial table
DATA IT_ZEKKP LIKE TABLE OF WA_ZEKKP.

**---data define
DATA OK_CODE LIKE SY-UCOMM.

**---tables controls
CONTROLS MY_TABLE_CONTROL TYPE TABLEVIEW USING SCREEN '0201'.
DATA WA_COLS LIKE LINE OF MY_TABLE_CONTROL-COLS.

**---start-of-selection
START-OF-SELECTION.
CALL SCREEN 100.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
SET TITLEBAR 'TITLE_0100'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BOOK'.
PERFORM GET_DATA.
SORT IT_ZEKKP BY EBELN.
DESCRIBE TABLE IT_ZEKKP LINES MY_TABLE_CONTROL-LINES.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module CLEAR_OK_CODE OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CLEAR_OK_CODE OUTPUT.
CLEAR OK_CODE.
ENDMODULE. " CLEAR_OK_CODE OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'STATUS_0200'.
SET TITLEBAR 'TITLE_0200'.

ENDMODULE. " STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.
CASE OK_CODE.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
SET SCREEN 100.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'SRTD'.
READ TABLE MY_TABLE_CONTROL-COLS WITH KEY SELECTED = 'X' INTO
WA_COLS.
IF SY-SUBRC = 0.
SORT IT_ZEKKP BY (WA_COLS-SCREEN-NAME+6) DESCENDING.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT

*&---------------------------------------------------------------------*
*& Form get_Data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
FORM GET_DATA .
SELECT * FROM EKKO
INTO CORRESPONDING FIELDS OF TABLE IT_ZEKKP
WHERE BUKRS = WA_ZEKKP-BUKRS.
ENDFORM. " get_Data
*&---------------------------------------------------------------------*
*& Module trans_to_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_0200 OUTPUT.
MOVE-CORRESPONDING WA_ZEKKP TO ZEKKP.
ENDMODULE. " trans_to_0200 OUTPUT
*&---------------------------------------------------------------------*
*& Module trans_from_tc_fields INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_FROM_TC_FIELDS INPUT.
MOVE ZEKKP-MARK TO WA_ZEKKP-MARK.
MODIFY IT_ZEKKP INDEX MY_TABLE_CONTROL-CURRENT_LINE FROM WA_ZEKKP.
ENDMODULE. " trans_from_tc_fields INPUT
*&---------------------------------------------------------------------*
*& Module trans_to_tc_fields OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE TRANS_TO_TC_FIELDS OUTPUT.
MOVE-CORRESPONDING WA_ZEKKP TO ZEKKP.
ENDMODULE. " trans_to_tc_fields OUTPUT
*&---------------------------------------------------------------------*
*& Module check_zekkp INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE CHECK_ZEKKP INPUT.
SELECT SINGLE * FROM EKKO
INTO CORRESPONDING FIELDS OF WA_ZEKKP
WHERE EBELN = ZEKKP-EBELN
AND BUKRS = ZEKKP-BUKRS.
ENDMODULE. " check_zekkp INPUT

目录
相关文章
SAP ABAP 程序调用设置成后台作业模式
ABAP 程序调用设置成后台作业模式
533 0
SAP ABAP 内表排序 动态字段排序
对于动态内表排序引用ABAP_SORTORDER_TAB
306 0
|
SQL 设计模式 前端开发
【置顶】SAP ABAP开发实战——从入门到精通系列目录
本文章为SAP ABAP开发实战——从入门到精通系列的目录以及关于该教程的后续写作计划表
1676 0
【置顶】SAP ABAP开发实战——从入门到精通系列目录
|
SQL
SAP ABAP-OPENSQL-数值函数简介
S4中针对OPENSQL新提供一些函数
145 0
|
SQL
SAP ABAP-OPENSQL-字符串函数介绍
S4中SQL新语法字符串函数
226 0
|
SQL
SAP ABAP-OPENSQL-日期/时间戳函数
S4提供针对OPENSQL一些新的SQL函数调用,本文展示相关函数的使用
702 0
|
BI
SAP ALV报表选择屏幕筛选字段动态文本
SAP ALV报表选择屏幕筛选字段动态文本
250 0
SAP ABAP-删除工序示例代码
ABAP-删除工序示例代码
178 0
SAP ABAP 检查事务码权限
检查用户是否有自开发事务码的权限
164 0
|
BI
SAP ABAP在线预览文档对象的开发实现
应用场景:有些定制化开发(报表/功能增强等)完成之后,客户需要将其操作手册或者相关文档放在某个报表的初始画面,供实际操作者在线查阅,当然这个功能也同样类似于模板的下载,这里就以在线预览(直接打开)为例进行说明。
231 0