abap/4 程序员之路 —— 第 4 天
DESCRIPTION
ABAP/4 程序员之路 —— 第 4 天. 上海华和得易信息技术有限公司 王勇. 本日学习内容. DIALOG 程序 Screen Object 和 PBO 、 PAI 处理 特殊对象处理:对话屏幕,子屏幕以及 Table Control 的处理. Screen. Title bar. Pushbutton. Text field. Input/Output field. Status icon. Group box. Radio button and checkbox. Selection screen. List. GUI status. - PowerPoint PPT PresentationTRANSCRIPT
ABAP/4程序员之路——第 4天
上海华和得易信息技术有限公司王勇
本日学习内容 DIALOG程序 Screen Object和 PBO、 PAI处理
特殊对象处理:对话屏幕,子屏幕以及 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: Pushbuttons
User-input using the mouse
Display/Change
Display/Change
A
B
A
B
Creating Pushbuttons
PAI. MODULE user_command. . . .
ScreenPainter
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 EditorDisplay/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.
Pushbuttons with Function Type E
PAI. MODULE exit_command
. . .
ScreenPainter
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 EditorCancel
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.
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: GUI status
Choose functions byclicking with the mouse
Development object Edit Goto System Help
Flight data xxxx
ENTERF1 HelpF2 ChooseF3...
Menu bar
Standard toolbar
Application toolbar
Function keys
Create GUI Status(1)
Double ClickDouble Click
Create GUI Status(2)
Double ClickDouble Click
Create GUI Status(3)
EnterEnter
Status: Technical View
Status 001 Status 002 Status ...
Menu bars
M 1
Function key settings
T 1
Application toolbars
D 1
Menu Bar
Enter Enter Transaction Transaction
CodeCode Enter Enter DescriptionDescription
_____
_____
_____
_____The max level is 4
Function Key
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-characterID letter for functionfast path
Standard Toolbar Functions and Their Reserved Function Keys
Icon Function key Function
SaveBackExit (program)Cancel (Screen)
PrintFindFind nextFirst pagePrevious pageNext page
Last pageHelp
EnterF11
F3Ctrl-F3F12
Ctrl-PCtrl-FCtrl-GCtrl-Page upPage up Page downCtrl-Page down
F1
Navigation - Dialogs
BackBack ExitExit CancelCancel
YesYes YesYes NoNoSaves DialogSaves Dialog
YesYes YesYes NoNoChecks EntriesChecks Entries
Check, then saveCheck, then save Save, then checkSave, then check --SequenceSequence
Save data?Save data? Save data?Save data?Unsaved data will Unsaved data will be lost!be lost!Cancel?Cancel?
ExampleExample
popup_to_popup_to_confirm_stepconfirm_stepororpopup_to_popup_to_confirm_confirm_with_valuewith_value
popup_to_popup_to_confirm_stepconfirm_stepororpopup_to_popup_to_confirm_confirm_with_valuewith_value
popup_to_popup_to_confirm_confirm_loss_of_dataloss_of_data
Function ModuleFunction Modulefor Dialogfor Dialog
Application toolbar
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: Lists
Displaying data at thefront end
Flight List
CAR ID From To
List Edit Goto System Help
AA 0017 NEW YORK SAN FRANCISCO
LH 0400 FRANKFURT NEW YORK
LH 0402 FRANKFURT BERLIN
Created on: 01 .01.1998By: WITTMANN
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-PROCESSINGAND 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)
100100
PBO(100)
PAI(100)
PAI(100)
PBO(100)
100100
PAI(100)
Next screen
Screen 300
F3
F3
List
List
100100
List
100100
100100
Lists in a Modal Dialog Box
Dialog Box
List
200
MODULE LIST OUTPUT. SUPPRESS DIALOG. LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0. SET PF-STATUS SPACE. ...
ENDMODULE.
ABAPABAP
PROCESS BEFORE OUTPUT. MODULE LIST .
ScreenScreenPainterPainter
200200
MODULE m INPUT. . . . CALL SCREEN 200 STARTING AT 20 10 ENDING AT 50 15. . . .ENDMODULE.
200
ABAPABAP
100
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: Selection screen
RestrictingDatabase selections
List Edit Goto System Help
Airline to
From
AA
Frankfurt
This week
This month
This quarter
Any
Flight date
Entering Value Ranges
Airline to ...
From
LHSELECT-OPTIONS ...
PARAMETERS ...
Single valueGreater than or equal
Greater than Less thanNot equal
Less than or eqeual
Select
Exclude from selection
Maintain Selection Options
Airline
Selection table
SIGNI
OPTIONGE
LOWLH
HIGH
Defining and Calling a Selection Screen
SELECTION-SCREEN BEGIN OF SCREEN <nnnn>. ...SELECTION-SCREEN END OF SCREEN <nnnn>.
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.
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: Subscreen
Reserved area on ascreen:Filled at runtime
SubscreenSubscreenareaarea
SubscreenSubscreenareaarea
Subscreen Subscreen
Subscreen I
Creating a Subscreen Area
Subscreen Attributes
Calling a Subscreen
Subscreen name
Program nameScreen number
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: Tabstrip Control
An easy way to present data that logically belongstogetherFrom To
Country
Airport
Time
DE
TXL
10:10:00
City Berlin
Info
Tabstrip Elements
Depart Arrive Seats
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
DepartArrive SeatsBookingsInformation
Tab Page: Technical View
Text
CONTENTS =Subscreen
areaSubscreen
area
+
TextText
PushbuttonPushbutton
Contents =
Subscreen
+
Creating a Tabstrip Control
Tabstrip areaTabstrip area
Tab titlesTab titles
Subscreen areasSubscreen areas
Creating a Tabstrip Control: Tabstrip Area
************************************* INCLUDE MZxxxTOP *************************************CONTROLS: my_tab_strip TYPE TABSTRIP.. . .
ABAPABAP
Type TABSTRIP TABSTRIP corresponds to the structured type CXTABCXTAB _TABSTRIP withthe individual types:
activetab active tab title. . .
Creating a Tabstrip Control: Tab Title
Creating a Tabstrip Control: Subscreens
SubscreenArea
or
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
Scrolling in Tabstrip Controls: Coding
R
CONTROLS: my_tab_strip TYPE TABSTRIP.DATA : dynpro LIKE sy-dynnr, ok_code LIKE sy-ucomm, pressed_tab LIKE sy-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.
ABAPABAP
PROCESS BEFORE OUTPUT. MODULE SET_PAGE. ... CALL SUBSCREEN subarea INCLUDING SYST-CPROG dynpro .
PROCESS AFTER INPUT. CALL SUBSCREEN subarea . ... MODULE user_command.
ScreenScreen
PainterPainter
Subarea
R1
MY_TAB_STRIPMY_TAB_STRIP
Dynpro
R3
FctTyp FctTyp
R2
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: Table control
LH
From To
Frankfurt
Frankfurt
Berlin
0400
0402
2407
New
New
San F
Airline
Flgt
Displaying large amounts
of data in tabluar form
ABAP Table Control (Function)
Automatic horizontal and vertical scrolling
Fixed leading columns
Mark rows
Mark and swapcolumns
Change column widthChange and savetable setting
Table Control Elements
Table Control
Creating a Table Control
Processing a Table Control
Further Techniques
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'.. . .
ABAPABAP
Create Table Control Fields
或從 table 中 reference field
自己 creat field
Table Control Attributes Table control name
Not delete all head line elements
Show table control label
Show table 直條線
Show table 橫條線
可選擇欄位的條件
增加 checkbox
固定不會移動的欄位
選擇視窗縮小時出現移動 bar
一次可選擇幾筆資料Table control 抬頭
Table Control Elements
Table Control
Creating a Table Control
Processing a Table Control
Further Techniques
Processing a Table Control(Principle)
Databasetable
678
5
Internal tablebuffer
Database table
1
2345
678
9...
Next page
34
21
ABAP program Screen
PBO
PAI
Table Control Applications(Principle)
Screen (with Table Control)
PBO
PAI
LOOP ...
Read line-by-line from the internal table
ENDLOOP.
LOOP ...
Update the internal tableline-by-line
ENDLOOP.
Scroll page by pageChange database table
ScreenScreenPainterPainter
In programFill internal table
- CALL SCREEN- Static screen sequence
Filling a Table Control
PROCESS BEFORE OUTPUT.LOOP AT itab_sbook INTO sdyn_book
WITH CONTROL my_ control.ENDLOOP
sdyn_book
ABAP programmScreen
1122
LH 0400 ...
LH 0400 ...
33
itab_sbook
LH 0400 ...
Fields fromsdyn_book
11 33+ +
Automatically done using loop in the flowlogic!
ScreenScreenPainterPainter 22
23
24
34
Change the Contents of a TC
PROCESS AFTER INPUT.LOOP AT itab_sbook.
FIELD sdyn_book-smoker MODULE modify_ itab ON REQUEST.
ENDLOOP.
MODULE modify_itab INPUT.MODIFY itab_sbook FROM sdyn_book
INDEX my_control-current_line ...ENDMODULE.
ABAPABAP
ScreenScreenPainterPainter
sdyn_book
ABAP program11 3
LH 0400 ...
22
LH 0400 ...
LH 0407 ...LH 2402 ...
itab_sbook
11 22+
Performed automaticallyin the loop in the flow logic
3
Programmed in ABAP
Screen
LH 0402 ...
2
34
.
1
Table Controls: Field Transport in the PBO
Transport ABAP
table control fields
to screen fields
LOOP end
LOOP start
MODULE output_1
Airline LH
To
0400
0402
Frankfurt
Frankfurt New
New
2407 Berlin San
FromFlight
Table Controls: Field Transport in the PAI
Airline LH
To
0400
0402
Frankfurt
Frankfurt New
New
2407 Berlin San
FromFlight
MODULE input_1
Transport table cotrol
fields from the screen to
the ABAP fields
LOOP LOOP startstart
MODULE input_2
LOOP LOOP endend
Transport all fields from
the screen to the ABAP
fields except table
control fields and f1
1
2Airline LH
To
0400
0402
Frankfurt
Frankfurt New
New
2407 Berlin San
FromFlight
1
2
Table Control Elements
Table Control
Creating a Table Control
Processing a Table Control
Further Techniques
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,
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,
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 <screen_number>.
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.
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.
ScreenScreenPainterPainter
MODULE change_table_control_1 ... . my_control-fixed_cols
= dyn_col_num. ...ENDMODULE.
ABAPABAP
dyn_col_num 3
Changing the Attributes of a TC(2)
R
PBO or PAI
MODULE change_table_control_2.
ScreenScreenPainterPainter
...
Gen. attributes Col. attributes
Table control attributes
INDEX ...
COLS
... INTENSIFIEDSCREEN-
DATA wa LIKE LINE OF my_control-cols. ...MODULE change_table_control...LOOP AT my_control-cols INTO wa. IF wa-index BETWEEN 1 AND 3
wa-screen-intensified = 1. ELSE. wa-screen-intensified = 0. ENDIF. MODIFY my_control-cols FROM wa. ENDLOOP.ENDMODULE.
ABAPABAP
Modifying Field Attributes Temporarily
R
...
Screen table for line: Screen table for line:
Name
Col1
Col2
Col3
. . .
Name
Col1
Col2
Col3
. . .
InputInput OutputOutput IntensifiedIntensified ......
222
1
LOOP AT itab INTO sdyn_conn. MODULE modify_screen .ENDLOOP.
ScreenScreenPainterPainter
1
MODULE modify_screen OUTPUT. CHECK spfli_itab-flag = 'X'.
LOOP AT SCREEN. IF screen-group1 = 'SEL'. screen-intensified = 1. MODIFY SCREEN. ENDIF. ENDLOOP.
ENDMODULE.
ABAPABAP
2
2
Sorting a Table Control: Example
DATA wa LIKE LINE OF my_control-cols. ...MODULE user_command_0200 INPUT. ...LOOP AT my_control-cols INTO wa. IF wa-selected = 'X'. SORT itab BY (wa-screen-name+5). ENDIF. ENDLOOP.
ENDMODULE.
ABAPABAP
Scrolling Page by Page in a Table Control
R
DATA: looplines LIKE sy-loopc. ...MODULE get_looplinesget_looplines OUTPUT. looplines = sy-loopc.ENDMODULE.
MODULE user_command_0200user_command_0200 INPUT. ... WHEN 'F21'. my_control-top_line = 1. WHEN 'F22'. my_control-top line = my_control-top _line - looplines. IF my_control-top_line < 1. my_control-top_line = 1. ... WHEN 'F24'. flights-top_line = flights_itab_lines - looplines + 1.ENDMODULE.
ABAPABAP
PROCESS BEFORE OUTPUT.
LOOP... . MODULE get_looplinesget_looplines. ENDLOOP.
PROCESS AFTER INPUT.
LOOP... . ... ENDLOOP.
MODULE user_command_0200user_command_0200.
ScreenScreenPainterPainter
Table Control: Cursor Position(Example)
R
SyntaxSyntax
GET CURSOR FIELD f VALUE v LINE l OFFSET o.
SET CURSORSET CURSOR FIELD f FIELD f LINE l LINE l OFFSET o. OFFSET o.
Finding out the cursor position:Which line of the internal table corresponds to a line of the table control?
DATA: selline LIKE sy-stepl, tabix LIKE sy-tabix. ...
GET CURSOR LINE selline.tabix = my_control-TOP_LINE + selline - 1.READ TABLE spfli_itab INDEX tabix.
ABAPABAP