Download presentation
Presentation is loading. Please wait.
Published byJoanna Andrews Modified over 9 years ago
1
ABAP/4 程序员之路 —— 第 4 天 上海华和得易信息技术有限公司 王勇
2
本日学习内容 DIALOG 程序 Screen Object 和 PBO 、 PAI 处 理 特殊对象处理:对话屏幕,子屏幕以及 Table Control 的处理
3
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
4
Screen Object: Pushbuttons User-input using the mouse Display/Change A B A B
5
Creating Pushbuttons PAI. MODULE user_command.... Screen Painter Screen Painter Object name button ok_code Type OK FctCode SWIT FctTyp Object name Object text FctCode button Display/Change SWIT Object Attributes FctTyp ABAP Fullscreen Editor Display/Change 2 Object List 1 2 1 DATA: ok_code LIKE sy-ucomm, save_ok LIKE ok_code. MODULE user_command INPUT. Save_ok = ok_code. CLEAR ok_code. CASE save_ok. WHEN ‘SWIT’. …… ENDCASE. ENDMODULE.
6
Pushbuttons with Function Type E PAI. MODULE exit_command... Screen Painter Screen Painter Object name button ok_code Type OK FctCode CANC FctTyp Object name Object text FctCode button Cancel CANC Object Attributes FctTyp ABAP Fullscreen Editor Cancel Object List DATA: ok_code LIKE sy-ucomm. MODULE exit_command INPUT. CASE sy-dynnr. WHEN ‘0100’. Leave program. …… ENDCASE. ENDMODULE. E E AT EXIT-COMMAND.
7
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
8
Screen Object: GUI status Choose functions by clicking with the mouse Development object Edit GotoSystem Help Flight data xxxx ENTER F1Help F2Choose F3... Menu bar Standard toolbar Application toolbar Function keys
9
Create GUI Status(1) Double Click
10
Create GUI Status(2) Double Click
11
Create GUI Status(3) Enter
12
Status: Technical View Status 001Status 002Status... Menu bars M 1 Function key settings T 1 Application toolbars D 1
13
Menu Bar EnterTransactionCode EnterDescription _____ The max level is 4
14
Function Key
15
Function Key : Attributes Attributes Functional type E: Exit command S: System function T: Call a Transaction : Normal application Function P: Local GUI Function H: Internal use Function text Enter Function Key description Icon name 以符號方式 來表示此 Icon Icon text 以文字方式 來表示此 Icon Info. text Short description Fastpath One- character ID letter for function fast path
16
Standard Toolbar Functions and Their Reserved Function Keys Icon Function key Function Save Back Exit (program) Cancel (Screen) Print Find Find next First page Previous page Next page Last page Help Enter F11 F3 Ctrl-F3 F12 Ctrl-P Ctrl-F Ctrl-G Ctrl-Page up Page up Page down Ctrl-Page down F1
17
Navigation - Dialogs BackExitCancel YesYesNo Saves Dialog YesYesNo Checks Entries Check, then save Save, then check - Sequence Save data? Unsaved data will be lost! Cancel? Example popup_to_ confirm_step or popup_to_ confirm_ with_value popup_to_ confirm_step or popup_to_ confirm_ with_value popup_to_ confirm_ loss_of_data Function Module for Dialog
18
Application toolbar
19
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
20
Screen Object: Lists Displaying data at the front end Flight List CAR IDFromTo ListEditGoto System Help AA 0017 NEW YORK SAN FRANCISCO LH 0400 FRANKFURTNEW YORK LH 0402 FRANKFURT BERLIN Created on:01.01.1998 By: WITTMANN
21
Displaying a List Within a Transaction MODULE <Module_name>. LEAVE TO LIST-PROCESSING. SET PF-STATUS SPACE.... WRITE...SKIP...ULINE... ENDMODULE. MODULE <Module_name>. LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 300. SET PF-STATUS SPACE.... ENDMODULE. MODULE <Module_name>. SUPPRESS DIALOG. LEAVE TO LIST-PROCESSING. SET PF-STATUS SPACE.... ENDMODULE. PBO (100) 100 PBO (100) PAI (100) PAI (100) PBO (100) 100 PAI (100) Next screen Screen 300 F3 List 100 List 100
22
Lists in a Modal Dialog Box Dialog Box List 200 MODULELIST OUTPUT. SUPPRESS DIALOG. LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0. SET PF-STATUS SPACE.... ENDMODULE. ABAP PROCESS BEFORE OUTPUT. MODULELIST. Screen Painter 200 MODULE m INPUT.... CALL SCREEN 200 STARTING AT 20 10 ENDING AT 50 15.... ENDMODULE. 200 ABAP 100
23
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
24
Screen Object: Selection screen Restricting Database selections ListEditGoto System Help Airline to From AA Frankfurt This week This month This quarter Any Flight date
25
Entering Value Ranges Airline to... From LH SELECT-OPTIONS... PARAMETERS... Single value Greater than or equal Greater than Less than Not equal Less than or eqeual Select Exclude from selection Maintain Selection Options Airline Selection table SIGN I OPTION GE LOW LH HIGH
26
Defining and Calling a Selection Screen SELECTION-SCREEN BEGIN OF SCREEN.... SELECTION-SCREEN END OF SCREEN. SELECTION-SCREEN BEGIN OF SCREEN 1200. SELECT-OPTIONS se_carr FOR sflight-carrid. PARAMETERS pa_airpf LIKE spfli-airpfrom. SELECTION-SCREEN END OF SCREEN 1200.... CALL SELECTION-SCREEN 1200.
27
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
28
Screen Object: Subscreen Reserved area on a screen: Filled at runtime Subscreen area Subscreen area Subscreen Subscreen I
29
Creating a Subscreen Area
30
Subscreen Attributes
31
Calling a Subscreen Subscreen name Program name Screen number
32
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
33
Screen Object: Tabstrip Control An easy way to present data that logically belongs together From To Country Airport Time DE TXL 10:10:00 City Berlin Info
34
Tabstrip Elements Depart ArriveSeats Land Flughafen Zeit DE TXL 10:10:00 Stadt Berlin Current tab title Scrollbar for more tab pages List of all tab pages Current page is indicated Tab border Depart Arrive Seats Bookings Information
35
Tab Page: Technical View Text CONTENTS = Subscreen area Subscreen area + Text Pushbutton Contents = Subscreen +
36
Creating a Tabstrip Control Tabstrip area Tab titles Subscreen areas
37
Creating a Tabstrip Control: Tabstrip Area ************************************ * INCLUDE MZxxxTOP * ************************************ CONTROLS:my_tab_strip TYPETABSTRIP.... ABAP Type TABSTRIP corresponds to the structured type CXTAB _TABSTRIP with the individual types: activetabactive tab title...
38
Creating a Tabstrip Control: Tab Title
39
Creating a Tabstrip Control: Subscreens Subscreen Area or
40
Scrolling in a Tabstrip Control Depart Arr.Info Page 1 Depart Arr.Info Page 2 PAI Determines which page the user has chosen Calls the screen again PBO Sets the subscreen corresponding to the page chosen by the user
41
Scrolling in Tabstrip Controls: Coding R CONTROLS: my_tab_strip TYPE TABSTRIP. DATA : dynpro LIKE sy-dynnr, ok_code LIKE sy-ucomm, pressed_tab LIKEsy-ucomm value '0101'. MODULE user_command INPUT. CASE ok_code. WHEN 'R1'. pressed_tab = 'R1'. WHEN 'R2'. pressed_tab = 'R2'.... ENDMODULE. MODULE set_page OUTPUT. my_tab_strip-activetab = pressed_tab. CASE pressed_tab. WHEN 'R1'. dynpro ='0101'. WHEN 'R2'. dynpro ='0102'.... ENDMODULE. ABAP PROCESS BEFORE OUTPUT. MODULE SET_PAGE.... CALL SUBSCREENsubarea INCLUDING SYST-CPROGdynpro. PROCESS AFTER INPUT. CALL SUBSCREENsubarea.... MODULE user_command. Screen Painter Subarea R1 MY_TAB_STRIP Dynpro R3 FctTyp R2
42
ScreenTitle barPushbuttonText fieldInput/Output fieldStatus iconGroup boxRadio button and checkbox Selection screen List GUI status Table control Tabstrip control Subscreen
43
Screen Object: Table control LH FromTo Frankfurt Berlin 0400 0402 2407 New San F Airline Flgt Displaying large amounts of data in tabluar form
44
ABAP Table Control (Function) Automatic horizontal and vertical scrolling Fixed leading columns Mark rows Mark and swap columns Change column width Change and save table setting
45
Table Control Elements Table Control Creating a TableControl Processing a Table Control Further Techniques
46
Create Table Control Area 1-3 給一個 tablecontrol name 1-1 選取 table control 物件 1-2 圈選所需要的畫面 My_control ************************************ * INCLUDE MZxxxTOP * ************************************ CONTROLS: my_control TYPE TABLEVIEW USING SCREEN '0100'.... ABAP
47
Create Table Control Fields 或從 table 中 reference field 自己 creat field
48
Table Control Attributes Table control name Not delete all head line elements Show table control label Show table 直條線 Show table 橫條線 可選擇欄位的條件 增加 checkbox 固定不會移動的欄位 選擇視窗縮小時出現移動 bar 一次可選擇幾筆資料 Table control 抬頭
49
Table Control Elements Table Control Creating a TableControl Processing a Table Control Further Techniques
50
Processing a Table Control(Principle) Database table 6 7 8 5 Internal table buffer Database table 1 2 3 4 5 6 7 8 9... Next page 3 4 2 1 ABAP program Screen PBO PAI
51
Table Control Applications(Principle) Screen (with Table Control) PBO PAI LOOP... Read line-by-line from the internal table ENDLOOP. LOOP... Update the internal table line-by-line ENDLOOP. Scroll page by page Change database table Screen Painter In program Fill internal table - CALL SCREEN - Static screen sequence
52
Filling a Table Control PROCESS BEFORE OUTPUT. LOOP ATitab_sbook INTO sdyn_book WITH CONTROL my_control. ENDLOOP sdyn_book ABAP programm Screen 1 1 2 2 LH 0400... 3 3 itab_sbook LH 0400... Fields from sdyn_book 1 1 3 3 + Automatically done using loop in the flow logic! Screen Painter 2 2 2 3 2 4 3 4
53
Change the Contents of a TC PROCESS AFTER INPUT. LOOP ATitab_sbook. FIELDsdyn_book-smoker MODULE modify_ itabON REQUEST. ENDLOOP. MODULE modify_itab INPUT. MODIFY itab_sbook FROM sdyn_book INDEX my_control-current_line... ENDMODULE. ABAP Screen Painter sdyn_book ABAP program 1 1 3 LH 0400... 2 2 LH 0407... LH 2402... itab_sbook 1 1 2 2 + Performed automatically in the loop in the flow logic 3 Programmed in ABAP Screen LH 0402... 2 3 4. 1
54
Table Controls: Field Transport in the PBO Transport ABAP table control fields to screen fields LOOP end LOOP start MODULEoutput_1 Airline LH To 0400 0402 Frankfurt New 2407Berlin San From Flight
55
Table Controls: Field Transport in the PAI Airline LH To 0400 0402 Frankfurt New 2407Berlin San From Flight MODULEinput_1 Transport table cotrol fields from the screen to the ABAP fields LOOP start MODULEinput_2 LOOP end Transport all fields from the screen to the ABAP fields except table control fields and f1 1 2 Airline LH To 0400 0402 Frankfurt New 2407Berlin San From Flight 1 2
56
Table Control Elements Table Control Creating a TableControl Processing a Table Control Further Techniques
57
Type of TABLEVIEW - Type Group CXTAB TYPE-POOL CXTAB TYPES: BEGIN OF CXTAB_COLUMN, SCREEN LIKE SCREEN, “Attributes struktur SCREEN INDEX TYPE I, “Position of a column on the screen SELECTED(1) TYPE C, “Indicator ‘column selected’ VISLENGTH LIKE ICON-OLENG, “Visualised length of a column INVISIBLE(1) TYPE C, “Indicator ‘column invisible’ END OF CXTAB_COLUMN,
58
Type of TABLEVIEW - Type Group CXTAB BEGIN OF CXTAB_CONTROL, FIXED_COLS TYPE I, “Number of fixed columns LINES TYPE I, “Number of lines to display TOP_LINE TYPE I, “Top line during next PBO CURRENT_LINE TYPE I, “Current line during LOOP/ENDLOOP LEFT_COL TYPE I, “First scrollable column after fixed area LINE_SEL_MODE TYPE I, “Line-selection : none(0), single(1), multiple(2) COL_SEL_MODE TYPE I, “Column-selection : none(0), single(1), multiple(2) LINE_SELECTOR(1) TYPE C, “Indicator: ‘With line-selection col’ V_SCROLL(1) TYPE C, “not used H_GRID(1) TYEP C, “Indicator: ‘Horizontal grid-lines’ V_GRID(1) TYPE C, “Indicator: ‘Vertikal grid-lines’ COLS TYEP STANDARD TABLE OF CXTAB_COLUMN WITH NON-UNIQUE DEFAULT KEY, INVISIBLE(1) TYPE C, END OF CXTAB_CONTROL,
59
Type of TABLEVIEW - Type Group CXTAB BEGIN OF CXTAB_TABSTRIP, ACTIVETAB LIKE SCREEN-NAME, %_SCROLLPOSITION LIKE SCREEN-NAME, INVISIBLE(1) TYPE C, END OF CXTAB_TABSTRIP. * If you want to start the original setting, as below: REFRESH CONTROL my_control FROM SCREEN.
60
Screen Flow Logic PROCESS BEFORE OUTPUT. …… LOOP AT initial_table WITH CONTROL my_control CURSOR my_control-current_line. …… ENDLOOP. PROCESS AFTER INPUT. LOOP AT initial_table. …… ENDLOOP. …… MODULE USER_COMMAND_0100.
61
Changing the Attributes of a TC(1) General attrs Column attrs Table control attributes FIXED_COLS... PAI or PBO. FIELD dyn_col_num MODULE change_table_control_1 ON REQUEST. Screen Painter MODULE change_table_control_1.... my_control-fixed_cols = dyn_col_num.... ENDMODULE. ABAP dyn_col_num 3
62
Changing the Attributes of a TC(2)
63
Modifying Field Attributes Temporarily R... Screen table for line: Screen table for line: Name Col1 Col2 Col3... Name Col1 Col2 Col3... Input Output Intensified... 2 2 2 1 LOOP AT itab INTO sdyn_conn. MODULEmodify_screen. ENDLOOP. Screen Painter 1 MODULEmodify_screenOUTPUT. CHECK spfli_itab-flag = 'X'. LOOP AT SCREEN. IF screen-group1 = 'SEL'. screen-intensified = 1. MODIFY SCREEN. ENDIF. ENDLOOP. ENDMODULE. ABAP 2 2
64
Sorting a Table Control: Example DATA wa LIKE LINE OF my_control-cols.... MODULEuser_command_0200INPUT.... LOOP AT my_control-cols INTO wa. IF wa-selected = 'X'. SORT itab BY (wa-screen-name+5). ENDIF. ENDLOOP. ENDMODULE. ABAP
65
Scrolling Page by Page in a Table Control R DATA: looplines LIKE sy-loopc.... MODULE get_looplines OUTPUT. looplines = sy-loopc. ENDMODULE. MODULE user_command_0200 INPUT.... WHEN 'F21'. my_control-top_line = 1. WHEN 'F22'. my_control-top line = my_control-top _line - looplines. IFmy_control-top_line < 1. my_control-top_line = 1.... WHEN 'F24'. flights-top_line = flights_itab_lines - looplines + 1. ENDMODULE. ABAP PROCESS BEFORE OUTPUT. LOOP.... MODULE get_looplines. ENDLOOP. PROCESS AFTER INPUT. LOOP....... ENDLOOP. MODULE user_command_0200. Screen Painter
66
Table Control: Cursor Position(Example) R Syntax GET CURSOR FIELD f VALUE v LINE l OFFSET o. SET CURSOR FIELD f LINE l OFFSET o. Finding out the cursor position: Which line of the internal table corresponds to a line of the table control? DATA: selline LIKEsy-stepl, tabix LIKE sy-tabix.... GET CURSOR LINE selline. tabix = my_control-TOP_LINE + selline - 1. READ TABLE spfli_itab INDEX tabix. ABAP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.