660 likes | 1.08k Views
ABAP/4 程序员之路 —— 第 3 天. 上海华和得易信息技术有限公司 王勇. 本日学习内容. BATCH INPUT 程序概念和作成 DIALOG 程序初步. Batch Input 程序. Batch Input 是一种数据批量输入 SAP 系统的辅助程序, SAP 系统的资料、格式可以通过 Batch Input 录入 SAP 系统 Batch Input 的机制是模拟事务处理将数据录入 R/3 系统 Batch Input 类似 SAP 的 CATT ,控制性更好,处理能力更强. Batch Input 处理流程. 分析需要什么样的数据结构
E N D
ABAP/4程序员之路——第3天 上海华和得易信息技术有限公司 王勇
本日学习内容 • BATCH INPUT程序概念和作成 • DIALOG程序初步
Batch Input程序 • Batch Input是一种数据批量输入SAP系统的辅助程序, SAP系统的资料、格式可以通过Batch Input录入SAP系统 • Batch Input的机制是模拟事务处理将数据录入R/3系统 • Batch Input类似SAP的CATT,控制性更好,处理能力更强
Batch Input处理流程 • 分析需要什么样的数据结构 • 建立Batch Input程序 • 处理Batch Input数据 • 分析结果 • 分析错误的Session
分析数据结构 • 可以通过在屏幕字段上按‘F1’,然后查看其技术信息获得字段信息 • 一般我们通过工具来进行辅助分析: SHDB - Batch Input Transaction Recorder SM35 - Batch Input Monitoring SCAT - Computer Aided Test Tool
建立Batch Input程序 …… “创建Batch Input的数据 APPEND BDCDATA. …… “调用事务 CALL TRANSACTION <transaction code> USING <BDCDATA table> MODE <display mode> UPDATE <update mode> MESSAGE INTO <message table> .
建立Batch Input程序 • BDCDATA的结构
建立Batch Input程序 • 声明内部BDCDATA的内部表 * 存放Batch Input操作序列的内部表 -------------------------------------* DATA:BEGIN OF BDCDATA OCCURS 0. INCLUDE STRUCTURE BDCDATA. DATA:END OF BDCDATA. • 清空内部表 *&---------------------------------------------------------------------* *& Action : 清空BatchInput操作序列的内部表BDCDATA * *& Input : 无 * *& Output : 无 * *&---------------------------------------------------------------------* FORM BDC_REFRESH. REFRESH BDCDATA. ENDFORM.
建立Batch Input程序 • 设置屏幕 *&---------------------------------------------------------------------* *& Action : 添加Program/DynPro操作到BatchInput序列的内部表BDCDATA * *& Input : PROGRAM - 程序名(长度为8的字符串) * *& DYNPRO - 画面号 * *& Output : 无 * *&---------------------------------------------------------------------* FORM BDC_DYNPRO USING PROGRAM DYNPRO. CLEAR BDCDATA. BDCDATA-PROGRAM = PROGRAM. BDCDATA-DYNPRO = DYNPRO. BDCDATA-DYNBEGIN = 'X'. APPEND BDCDATA. ENDFORM.
建立Batch Input程序 • 设置屏幕字段 *&---------------------------------------------------------------------* *& Action : 添加屏幕数据操作到BatchInput序列的内部表BDCDATA * *& Input : FNAM - 屏幕项目名 * *& FVAL - 填写项目值 * *& Output : 无 * *&---------------------------------------------------------------------* FORM BDC_FIELD USING FNAM FVAL. CLEAR BDCDATA. BDCDATA-FNAM = FNAM. BDCDATA-FVAL = FVAL. APPEND BDCDATA. ENDFORM.
建立Batch Input程序 “调用事务 CALL TRANSACTION <transaction code> USING <BDCDATA table> MODE <display mode> UPDATE <update mode> MESSAGE INTO <message table> . • Display mode A - Display all (Default) E - Display only error N - No Display • Update Mode S - Continue processing when update is completed ( synchronous ) A - Continue processing immediately
Screen and Screen Object • Screen • Title bar • Text field • Input/output field • Status icon • Box • Radio button and checkbox • Pushbutton • GUI statuses • List • Selection screen • Subscreen • Tabstrip control • Table control
Screen Title bar Pushbutton Text field Input/Output field Status icon Group box Radio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
Screen Object: Screen A container for further screen object
Flow Logic PBO. . . . PAI. ... ... ... ... ... ... . . . Defining and Managing Screens Screen Objects Screen _ _ _ _ Text field Screen Attributes . . . Title Box
Dynamic Next Screen: Overview SET SCREEN CALL SCREEN
Setting the Next Screen Dynamically Screen Attributes Screen Attributes Screen number 100 Screen number 300 Next screen 200 Next screen 400 PAI PBO PBO PAI 400 MODULE ... SET SCREEN 300. LEAVE SCREEN. ENDMODULE.
MODULE ... SET SCREEN 0. LEAVE SCREEN. ENDMODULE. Inserting a Sequence of Screens Dynamically Screen Attributes Screen Attributes Screen number 100 Screen number 300 Next screen 200 Next screen 301 PBO PBO PAI PAI MODULE ... Call SCREEN 300. …. ENDMODULE.
101 101 100 100 Calling a Dialog Box Dynamically Screen 101 MODULE ok_code INPUT. ….. CALL SCREEN 101 STARING AT x1 y1. …… ENDMODULE. . Screen Attributes MODULE ok_code INPUT. ….. CALL SCREEN 101 STARING AT x1 y1 ENDING AT x2 y2. …… ENDMODULE. Modal dialog box . Next screen 101 101 100
Setting the Cursor Position Dynamically SET CURSOR FIELD f OFFECT o. Screen Painter PROCESS BEFORE OUTPUT. MODULE set_cursor. Airline LH ABAP Flight number ? MODULE set_cursor OUTPUT. Flight date ? sflight-carrid = 'LH'. SET CURSOR FIELD sdyn conn-connid. ... ENDMODULE.
Screen Title bar Pushbutton Text field Input/Output field Status icon Group box Radio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
Flight Connections Airline LH Flight No From To 0400 Frankfurt New 0402 Frankfurt New 2407 Berlin San Screen Object: Title Bar Window titles
ABAP Creating and Using Title Bars SET TITLEBAR ‘TITLE_SCREEN_100’. Create Object Title TITLE_SCREEN_100 does not exits. Do you want to create the object ? Yes No Cancel Double-click Create Title XXXX Program TITLE_SCREEN_100 Title code Title Flight Connections Save Cancel
Screen Title bar Pushbutton Text field Input/Output field Status icon Group box Radio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
Airline Flight number Booking date Booking number Screen Object: Text Field Displaying static texts
Text Much longer text Longer text Creating Text Fields Screen Painter Fullscreen Editor Directly_entered_text Much_longer_text ABAP Dictionary Data Element ... Texts Field name Short Medium Long
Screen Title bar Pushbutton Text field Input/Output field Status icon Group box Radio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
ABAP Screen Object: Input/Output Field Displaying and receiving data at the frontend • Automatic field input checks • Data consistency checks (foreign key) • Possible values help LH PROGRAM sapmzxxx. ...
General Dictionary Program Display • Object name • Object text • Icon display - Icon name - Quick info • Start position • Size - Static - Dynamic • Scrollable • Modif. groups • Data format • Memory ID - ID - SET attribute - GET attribute • Foreign key check • From Dictionary • Conversion exit • Matchcode • Upper-/lowercase active • Dialog properties - Input field - Output field - Output only - Required field • Possible entries - with or without - P. entries button • Output options - right-justified - leading zeros • Input options - *input possible - without reset - without template • Fixed font • Intensified • Invisible • 2-dimensional Input/Output Field:Attributes Attributes
Fullscreen Editor 3 4 Creating Input/Output Fields Screen Painter ABAP Dictionary Table: SDYN_CONN Field name Length Type CHAR CARRID NUMC CONNID Object Attributes HUGO Object name 8 defLg CHAR Data format ************************** INCLUDE MZxxxTOP * ************************** TABLES sdyn_conn DATA hugo(8) TYPE c . . .
Display/Change Display/Change This field is always This text is always displayed. displayed. This field can be hidden. Text field name: textfield1 Hiding a Field Dynamically
Dynamically Modifiable Attributes SCREEN-NAME Object Name SCREEN-GROUP1 SCREEN-GROUP2 SCREEN-GROUP3 SCREEN-GROUP4 Modification group 1 Modification group 2 Modification group 3 Modification group 4 SCREEN-REQUIRED SCREEN-INPUT SCREEN-OUTPUT SCREEN-INTENSIFIED SCREEN-INVISIBLE SCREEN-LENGTH SCREEN-ACTIVE SCREEN-DISPLAY 3D SCREEN-VALUE HELP SCREEN-REQUEST Required entry Ready for input Ready for output Intensified Invisible Object length Active object Display object in 3D Field with value help Input exists (only in PAI)
Screen Painter Object list: Modification groups Object name Gr1 Gr2 Gr3 Gr4 ... SDYN_CONN-CONNID SEL SDYN_CONN -CITYFROM SEL SDYN_CONN -CITYTO SEL ... Object Attributes: Modification Groups
ABAP Dynamic Screen Modifications: Program Screen painter PROCESS BEFORE OUTPUT. . . . MODULE modify_screen. . . . MODULE modify_screen OUTPUT. …... LOOP AT SCREEN. IF screen-name = ‘FEILD1’. Screen-invisible = 1. ENDIF. IF screen-group1 = ‘SEL’. Screen-input = 1. ENDIF. MODIFY SCREEN. ENDIF. ENDLOOP. ENDMODULE.
Transaction 1 SAP memory Airline LH 0400 Flight no. Transaction 2 Airline LH Set parameter Get parameter Input/Output Fields: Default Values in SAP Memory . . CAR LH CON 0400 . . 1 2
Defining SET/GET Parameter Attributes ABAP Dictionary Data element S_CARR_ID Data element . Parameter ID CAR Carrier ID Screen Painter List of General Object Attributes SPA GPA PID SPFLI-CARRID X X CAR . SPFLI-CONNID X X CON
? Required entry check Field format check Fixed values Foreign key check Field: Check table DEC INT4 DATS CLNT ... Domain: Fixed values Input/Output Fields: Automatic Field Input Checks (Review)
Screen Screen ABAP ABAP Painter Painter Programming Field Input Checks with an Error Dialog PROCESS AFTER INPUT. FIELD screen-field MODULE check_inp. MODULE check_inp INPUT. . . MESSAGE E……. . ENDMODULE. 1 1 1 E ? message 1 Ready for input again