ABAP selection screen design

Source: Internet
Author: User
Select Screen

The following is a typical screen selection example.
1. Set screen selection parameters.
* ** Begin (end) of block uses the screen element Logical Block.
Selection-screen begin of block BK1 with frame title title1.
* ** Defines the selection criteria, such as the scope of use of the screen sub-segments, set as required or use the memory ID.
Select-options <seltab> for <F> default │ no intervals │ obligatory │ no-display │ memory
ID...
* ** To write text on the selection screen, use screen comments and assign values during screen initialization.
Selection-screen comment...
* ** Draw a line on the screen.
Selection-screen uline...
* ** Begind (end) of line contains the screen parameters in the same line.
Selection-screen begin of line...
Selection-screen end of line...
* ** Set the screen position.
Selection-screen position...
* ** Create a button on the application toolbar to respond to events
Selection-screen function key...
* ** Create a button on the screen.
Selection screen Pushbutton...
Selection-screen end of block bk1.

Initialization.
* ** Initialize screen parameters, similar to the form_load event of VB ***

At selection-screen <on help (value)-request for field │>.
* ** Process when the system selects a screen. For example, you need to determine the conditions for some screen fields. For example, if some values are set, the screen is displayed.
Error message,ProgramThere is no need to waste time to continue execution.
* ** On help-request can display custom help for on-screen Fields
* ** On value-request, the recommended list value is displayed.
* ** It can be understood that at selection-screen is equivalent to PBO.
* ** Perform sub_validate_fieldxxx.
* ** After the screen is selected, it will be executed when you press ENTER or F8.
Start-of-selection.
* ** Set the inner table value to process all statements without any additional keywords.
* ** Generally, the form contained here is executed after you press F8.
END-OF_SELECTION.

At user-command.
* ** Process user request events. For example, if the report uses the ALV format, the call function exporting
* ** I _callback_user_command = 'user _ command'
*** Create another child program form user_command using ucomm like SY-UCOMM

At line-selection.
* ** This event is triggered when you select a row in the list after the report is displayed. If the report uses the write
* ** You can use this event.
* ** Set parameter ID 'xxx' field XXX.
* ** Call transaction 'xxx' and skip first screen.

Top-of-page.
* ** Display data. When top-of-page is used, you can display the defined page header at the end of each page.
* ** Perform write_page_header (page header is displayed on each page ).
* ** Perform display_alv_data.
End-of-page.
The following is a simple example of how to use the screen.
* ** This program is only used for demonstration, but includes the commonly used screen selection technology.
Copy the following program to run.

Report zselection no standard page heading
Message-ID zfimsg "message class
Line-size 255
Line-count 32 (3 ).

tables: bkpf, bseg, s070.
data: zbkpf like bkpf occurs 0,
zwa_bkpf like bkpf.
constants: p_variant (2) Type C value 'wl '.
** the following screen parameters have no relationship with the event, but only the parameter set.
selection-screen begin of block BK1 with frame title cond1.
select-options s_bukrs for bkpf-bukrs memory ID Buk.
select-options s_blart for bkpf-Blart no intervals.
select-options s_belnr for bkpf-belnr.
select-options s_budat for bkpf-budat default sy-datum.
select-options s_bldat for bkpf-bldat no intervals no-extension.
select-options s_gjahr for bkpf-gjahr memory ID gjr default sy-datum (4 ).
select-options weekran for s070-SPBUP no-extension.
selection-screen end of block bk1.

selection-screen begin of block BK2 with frame title cond2.
selection-screen comment/1 (30) comm1. "use screen comments
selection-screen begin of line. "Two single regions will be in the same line.
parameters pnor radiobutton group grp1 default 'x '. "Print normal doc
parameters ppark radiobutton group maid" Print parked doc
selection-screen end of line.
selection-screen end of block BK2.

*** 1 initialize the parameter.
initialization.
cond1 = '[condition ]'.
cond2 = '[Normal Doc │ parked Doc ]'.
comm1 = 'Choose Doc. type :'. "annotate the initial value.
*** initial company value, which is useful in some programs that require background running, except for variant, the following example can also be provided here. After initialization, the company Code selects 1000 and 3000 to exclude 2000
*** BR> S_bukrs-low = '000000 '.
S_bukrs-sign = 'I '. "I-> include, e-> exclude
S_bukrs-option = 'eq '. "ne
append s_bukrs.
S_bukrs-low = '000000 '.
S_bukrs-sign = 'E '.
S_bukrs-option = 'eq '.
append s_bukrs.
S_bukrs-low = '000000 '.
S_bukrs-sign = 'E '.
S_bukrs-option = 'eq '.
append s_bukrs.
*** initialize Doc range from 0100000000 to 1000000000
s_belnr-low = '20140901 '.
s_belnr-high = '000000 '.
s_belnr-sign = 'I '.
s_belnr-option = 'bt '.
append s_belnr.

* ** 2 Use sug_get_week to obtain the current week number of the selected date. This is triggered only when the weekrag field is selected.
* ** When you select the weekran field.
At selection-screen on value-request for weekran-low.
Perform sub_get_week changing weekran-low.

At selection-screen.
* ** It is usually not necessary to determine whether the selected company code is valid.
* ** Of course, you can also omit this step and directly judge it in start-of-selection.
* ** You can determine many Vaid fields as needed.
Perform sub_validate_comp.

* ** 3. Start Screen Selection
Start-of-selection.
Perform sub_get_doc.
Perform sub_wrt_doc.
End-of-selection.

* ** 4. The page header or page footer is displayed on the page.
Top-of-page.
Perform sub_wrt_header.
End-of-page.

*** 5. when you click a row and click Document No. call fb03.
at line-selection.
perform sub_line_response.
form sub_line_response.
data: zfldname like DD01L-DOMNAME,
zfldvalue like TTREET-TEXT,
zwa_bkpf like bkpf.
Get cursor field zfldname value zfldvalue.
If zfldname = 'zwa _ BKPF-BELNR '.
* read Table zbkpf into zwa_bkpf with key belnr = zfldvalue.
* Set parameter ID 'buk' field zwa_bkpf-BUKRS.
* Set parameter ID 'gjr 'field zwa_bkpf-GJAHR.
* Set parameter ID 'bln' field zwa_bkpf-BELNR.
set parameter ID 'bln' field zfldvalue.
call transaction 'fb03' and skip first screen.
endif.
endform.

Form sub_get_doc.
Refresh zbkpf.
Select * From bkpf into Table zbkpf
Where bukrs in s_bukrs
And belnr in s_belnr
And gjahr in s_gjahr
And budat in s_budat.
Endform.

Form sub_wrt_header.
Format intensified color = 6.
Write at:/01 'finaincial document list: '(h07 ).
Format color col_normal on.
Format color col_heading on.
Write at:/01 (48) sy-uline.
Format color col_heading off.
Format color off.
Endform.

Form sub_wrt_doc.
Uline/1 (41 ).
Loop at zbkpf into zwa_bkpf.
Write:/'│', zwa_bkpf-bukrs, '│', zwa_bkpf-belnr, '│', zwa_bkpf-gjahr, '│', zwa_bkpf-
Budat, '│ '.
Uline/1 (41 ).
Endloop.
Endform.

Form sub_validate_comp.
Data itab_bukrs like bkpf-bukrs occurs 0.
Select bukrs into Table itab_bukrs
From t001
Where bukrs in s_bukrs.
If itab_bukrs is initial.
Message e002 (00 ).
Endif.
Endform.

Form sub_get_week changing wkran like s070-SPBUP.
Data: l_date like workflds-gkday,
L_period like t009b-poper,
L_year like t009b-bdatj.
* ** Obtain the number of the current week based on the selected date.
Call function 'f4 _ date'
Exporting
Date_for_first_month = sy-Datum
Display =''
Importing
Select_date = l_date
Exceptions
Calendar_buffer_not_loadable = 1
Date_after_range = 2
Date_before_range = 3
Date_invalid = 4
Factory_calendar_not_found = 5
Holiday_calendar_not_found = 6
Parameter_conflict = 7
Others = 8.
Call function 'G _ period_get'
Exporting
Date = l_date
* ** If WL variant is used, the period is week/year, and if it is null, the period/year.
* In CO-PA or planning, usually weekly period.
Variant = p_variant "'wl'
Importing
Period = l_period
Year = l_year
Exceptions
Ledger_not_assigned_to_company = 1
Period_not_defined = 2
Variant_not_defined = 3
Others = 4.
Weekran-Sign = 'I '.
Weekran-option = 'eq '.
Concatenate l_year l_period + 1 (2) into wkran.
Endform.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.