21天学会APAP4的基础 Day21

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Day 21

Selection Screens

∙Chapter Objectives

∙Event-Driven Programming

o Using the initialization Event

o Using the at selection-screen Event

o Using the at user-command Event

∙Data Validation Using Foreign Keys

∙Data Validation Using Matchcodes

o Syntax for Using a Matchcode

∙Formatting Selection Screens

∙Using selection-screen Statements

o Syntax for selection-screen block with frame

∙Selection Screen Parameters

∙Selection Screen checkbox

o Syntax for selection-screen checkbox

∙Selection Screen select-options

o Syntax for select-options

∙Selection Screen Radio Buttons

o Syntax for a radiobutton group

∙Selection Screen Example Program

∙Using the Message Statement

o Syntax for the message-id Statement

∙Summary

∙Q&A

∙Workshop

o Quiz

o Exercise 1

Chapter Objectives

After you complete this chapter, you should be able to

∙Code selection screens that interact with the user.

∙Understand how foreign keys can help validate user input.

∙Understand how matchcodes are used in ABAP/4 programs.

∙Use formatting elements to create efficient, well-designed selection screens.

∙Use selection screens to maintain data integrity.

∙Use messages to provide effective communication.

Event-Driven Programming

In this day and age, with the emergence of the World Wide Web and all that it entails, program code must be capable of interacting and communicating with the end user. This is done in ABAP/4 using events that are invoked by the users' actions.

475

Processing blocks are defined by event keywords and are thus executed on the invocation of certain relevant events.

By default, the event start-of-selection is attached to all events in ABAP/4. In your programs you can define a processing block and attach this block to an event keyword.

For generally easy-to-read code, it is good practice to define sequential processing blocks in the order by which they will most likely be triggered during selection screen execution. It is also good practice to utilize the most important events for selection screen programming. These events are as follows: ∙The initialization event

∙The at selection-screen event

∙The at user-command event

Using the initialization Event

The following code shows the syntax for the initialization event:

report ywhatyr.

tables: marc, mvke.

..

data: p_year for sy-datum.

initialization.

if sy-datum ge '01012000'

p_year = '2000'.

else.

p_year = 'Yesteryear'.

endif.

In this example, when the program executes for which a selection screen is defined, this initialization processing block is executed, setting the parameter field p_year equal to a value depending on the system date at the moment of execution. It is this block in which you specify the initial default values of your selection screen based on whatever criteria is necessary to maintain data integrity of user input. Some examples include setting title bars, assigning text elements to graphical user interface (GUI) elements, and function code status.

You have seen how the initialization event works, so now it's time to take a closer look at some uses of the at selection-screen and at user-command events.

Using the at selection-screen Event

The at selection-screen event is processed after user input on the active selection screen. This can occur when the user presses a function key or clicks a pushbutton, as well as a host of other elements that can be interacted on by the user. In addition to data validation checks, warning messages, GUI status change, or even pop-up windows can be called using the at selection-screen event. You will look at more examples of these later in the chapter when you look at formatting selection screens and the events involved with screen formatting elements. For now, however, let's take a look at a pushbutton on a selection screen and how the events at selection-screen and at user-command are used with this next example.

Using the at user-command Event

476

相关文档
最新文档