Professional Documents
Culture Documents
Spring 2011
Enterprise Programming
3/22/2011
Event blocks
An ABAP program is a collection of processing blocks.
Event blockscalled by runtime environment when related event
has been triggered through natural program flow of control or
when triggered by a user action.
action
Our initial programsone blockso no need to declare event blocks.
Program event blocks:
LOAD-OF-PROGRAM (called at initial program setup)
START-OF-SELECTION (beginning of main processing)
Example use: PARAMETERS triggered at beginning of main
processing. If want to set a default value for field based on
processing (calculation, data retrieval), must do this before
START-OF-SELECTION.
Example
PARAMETERS date LIKE sy-datum DEFAULT sy-datum.
WRITE date.
DATA pastdate LIKE sy-datum.
pastdate = pastdate - 7.
PARAMETERS date LIKE sy-datum DEFAULT pastdate.
WRITE date.
LOAD-OF-PROGRAM.
DATA pastdate LIKE sy-datum.
pastdate = sy-datum - 7.
PARAMETERS date LIKE sy-datum DEFAULT pastdate.
START-OF-SELECTION.
WRITE date.
3/22/2011
More on Parameters--checkboxes
PARAMETERS can be designated AS CHECKBOX.
PARAMETERS: myvar AS CHECKBOX.
3/22/2011
More on Parameters--checkboxes
PARAMETERS: male AS CHECKBOX, female AS CHECKBOX.
IF male =
WRITE /
ENDIF.
IF female
WRITE /
ENDIF.
'X'.
'You are male!'.
= 'X'.
'You are female!'.
ENDCASE.
3/22/2011
3/22/2011
3/22/2011
Supplemental Text
COMMENT can be used to place text on the form.
Must use column and length format specifier.
SELECTION-SCREEN BEGIN OF BLOCK name WITH FRAME
TITLE title.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(40) comment.
PARAMETERS: var1 TYPE i,
var2 TYPE i,
var3 TYPE i.
SELECTION SCREEN END OF LINE.
SELECTION-SCREEN
LINE
SELECTION-SCREEN END OF BLOCK name.
LOAD-OF-PROGRAM.
title = 'Enter choices'.
comment = 'Enter your three favorite numbers'.
3/22/2011
3/22/2011
3/22/2011
10
3/22/2011
Let's Practice
Let's Practice
11
3/22/2011
AT LINE-SELECTION EVENT
When outputting a list, the AT LINE-SELECTION event is triggered
when a line is double clicked or the user chooses the choose icon.
SY-LSIND starts out at 0 for the initial list output and is incremented
each time the event fires.
fires It is decremented as the user moves
BACK.
START-OF-SELECTION.
WRITE: /'hello', 'sy-lsind', sy-lsind.
AT LINE-SELECTION.
WRITE: /'Now at selection level', sy-lsind.
12
3/22/2011
13
3/22/2011
Copyrights
Presentation prepared by and copyright of Dr. Tony
Pittarese, East Tennessee State University, Computer and
Information Sciences Dept. (pittares@etsu.edu)
Podcast lecture related to this presentation available via
ETSU iTunesU.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries,
xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+,
POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF,
Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of
IBM Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Oracle is a registered trademark of Oracle Corporation.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems,
Microsystems Inc
Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their
respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.
Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business
Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the
United States and in other countries. Business Objects is an SAP company.
Other products mentioned in this presentation are trademarks of their respective owners.
14