SAP ABAP顾问能力模型梳理_企业数字化建设者的博客-CSDN博客SAP Abap顾问能力模型,ALV/REPORT|SMARTFROM|SCREEN|OLE|BAPI|BDC|PI|IDOC|RFC|API|WEBSERVICE|Enhancement|UserExits|Badi|Debughttps://blog.csdn.net/java_zhong1990/article/details/132469977
一 背景说明
实现效果:
二 实现步骤
2.1 创建屏幕
屏幕显示的字段准备 --> 屏幕绘制(字段元素类型的使用)--> 逻辑流程(PBO PAI)PBO:状态栏;PAI :字段栏位的控制,ON REQUEST / ON INPUT ,值改变的时候触发/不为空,触发,MODULE函数。屏幕按钮事件,user_command,处理点击屏幕按钮之后所触发的逻辑
2.2 调用屏幕
CALL SCREEN 9100 STARTING AT 10 5 ENDING AT 200 30.
2.3 代码分布
2.3.1,主程序,2.3.2,逻辑流程,MODULE函数,user_command,status ;基本上有5处代码
2.4 创建屏幕步骤细节
2.4.1 创建屏幕
2.4.2 输出屏幕编号
2.4.3 屏幕:属性、元素单元、逻辑流
屏幕的三大部分细节
2.4.4 逻辑流
逻辑流程中有两个部分的信息,PBO、PAI
PROCESS BEFORE OUTPUT.
* MODULE STATUS_9100.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_9100.
2.4.5 屏幕绘制,进入屏幕布局
2.4.6 从元素库中拖动元素到面板上
2.4.7 从元素库中拖动表格向导到面板上 (表格向导有6个步骤)
2.4.8 创建状态栏、创建按钮事件
创建成功之后分别对应到PBO PAI的模块中
2.4.9 状态栏中的按钮在屏幕中的位置
2.4.10 按钮事件编码区域
在这个区域,可以对屏幕的表,输入框里的值进行操作等等
2.4.11 PAI中添加MODEULE
屏幕逻辑流的关于 MODULE,
FIELD ls_head-vkorg MODULE check_vkorg ON REQUEST." 值改变,触发
FIELD ls_head-vkorg MODULE check_vkorg ON INPUT. " 不为空,触发
这个区域可以写搜索帮助等
2.4.12 屏幕属性设置成对话框方式
屏幕需要选择对话框的方式
2.4.13 元素类型说明
字段的输入、输出、必填控制,如果是按钮元素,请输入功能码
2.5 代码分布细节
直接copy可用
2.5.1 主程序
2.5.5逻辑流程
*&---------------------------------------------------------------------*
*& Report ZSMF
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zscreen.
DATA: gv_ok_code LIKE sy-ucomm.
"定义好销售订单的表头 ,表行数据
DATA: ls_head TYPE zssd_vbak,
ls_item TYPE zssd_vbap,
lt_item TYPE STANDARD TABLE OF zssd_vbap.
SELECTION-SCREEN:BEGIN OF BLOCK b0 WITH FRAME TITLE TEXT-001.
PARAMETERS: pa_file TYPE rlgrap-filename ."文件夹上传
SELECTION-SCREEN:END OF BLOCK b0.
INITIALIZATION.
* PERform INI_SELECTION_SCREEN. " 初始化选择屏上的变量
AT SELECTION-SCREEN.
* PERform INI_DATA. " 选择屏幕输入值的验证
START-OF-SELECTION.
* PERform PRECESS_DATA. " 主要数据处理逻辑
"定义好销售订单的表头 ,表行数据
DATA:lv_i TYPE i.
lv_i = 1.
CLEAR:ls_head.
ls_head-vkorg = '1010'.
ls_head-kunnr = 'kunnr'.
ls_head-name1 = 'kunnr_desc'.
ls_head-vbeln = 'A000' && lv_i.
REFRESH:lt_item.
DO 50 TIMES.
CLEAR:ls_item.
ls_item-checked = 'X'.
ls_item-posnr = 1.
ls_item-vrkme = '个'.
ls_item-zdw = '个'.
ls_item-matnr = 'M001' && lv_i.
ls_item-name1 = 'NAME1'.
ls_item-zbak = '销售订单打印测试demo'&& lv_i.
ls_item-kwmeng = 12.
APPEND ls_item TO lt_item.
CLEAR:ls_item.
ls_item-checked = 'X'.
ls_item-posnr = 2.
ls_item-vrkme = 'PC'.
ls_item-zdw = '个'.
ls_item-matnr = 'M002' && lv_i.
ls_item-name1 = 'NAME2'.
ls_item-zbak = '销售订单打印测试demo'&& lv_i.
ls_item-kwmeng = 13.
APPEND ls_item TO lt_item.
lv_i = lv_i + 1.
ENDDO.
"左边距离 + 上边距 + 长 + 高
CALL SCREEN 9100 STARTING AT 10 5 ENDING AT 200 30.
AT LINE-SELECTION.
* PERform PRECESS_LINE_SELECTED. " 行选择时的处理
AT USER-COMMAND.
* PERform PRECESS_USER_COMMAND. * 用自定义命令按钮时的处理
TOP-OF-PAGE.
* PERform PAGE_HEADER. " 页眉
END-OF-PAGE.
* PERform PAGE_FOOT. " 页脚
INCLUDE zscreen_status_9100o01.
INCLUDE zscreen_user_command_9100i01.
"--- 表控件向导,生成的--
*&SPWIZARD: DECLARATION OF TABLECONTROL 'LT_1' ITSELF
CONTROLS: lt_1 TYPE TABLEVIEW USING SCREEN 9100.
*&SPWIZARD: OUTPUT MODULE FOR TC 'LT_1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE lt_1_change_tc_attr OUTPUT.
DESCRIBE TABLE lt_item LINES lt_1-lines.
ENDMODULE.
"--- 表控件向导,生成的 end
INCLUDE zscreen_check_vkorgi01.
PROCESS BEFORE OUTPUT.
*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'LT_1'
MODULE lt_1_change_tc_attr.
*&SPWIZARD: MODULE LT_1_CHANGE_COL_ATTR.
LOOP AT lt_item
INTO ls_item
WITH CONTROL lt_1
CURSOR lt_1-current_line.
*&SPWIZARD: MODULE LT_1_CHANGE_FIELD_ATTR
ENDLOOP.
MODULE status_9100.
*
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'LT_1'
LOOP AT lt_item.
CHAIN.
FIELD ls_item-checked.
FIELD ls_item-posnr.
FIELD ls_item-matnr.
FIELD ls_item-name1.
FIELD ls_item-kwmeng.
FIELD ls_item-vrkme.
FIELD ls_item-zbak.
FIELD ls_item-zdw.
ENDCHAIN.
ENDLOOP.
*&SPWIZARD: MODULE LT_1_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE LT_1_CHANGE_COL_ATTR.
MODULE user_command_9100.
"FIELD ls_head-vkorg MODULE check_vkorg ON REQUEST." 值改变的时候触发
FIELD ls_head-vkorg MODULE check_vkorg ON INPUT. " 不为空,触发
2.5.2 status
MODULE status_9100 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLEBAR'.
ENDMODULE.
2.5.3 user_command
*----------------------------------------------------------------------*
***INCLUDE ZSCREEN_USER_COMMAND_9100I01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9100 INPUT.
gv_ok_code = sy-ucomm.
CASE gv_ok_code.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN '&F12'.
LEAVE TO SCREEN 0.
WHEN 'TEST'.
LEAVE TO SCREEN 0.
WHEN 'ZSAVE'.
IF ls_head-vkorg = '2000'.
ls_head-vkorg = '1010'.
ENDIF.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
2.5.4 MODULE函数
*----------------------------------------------------------------------*
***INCLUDE ZSCREEN_CHECK_VKORGI01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module CHECK_VKORG INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE check_vkorg INPUT.
IF 1 = 1.
ENDIF.
ENDMODULE.