Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

constants , but how can events be stored as such

Former Member
0 Kudos

q] We know that data can be stored as constants , but how can events be stored as such

See this from

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3d5c358411d1829f0000e829fbfe/content.htm

TYPE-POOL SABC .

CONSTANTS:

SABC_ACT_READ(4) VALUE 'READ',

SABC_ACT_WRITE(5) VALUE 'WRITE',

SABC_ACT_READ_WITH_FILTER(16) VALUE 'READ_WITH_FILTER',

SABC_ACT_WRITE_WITH_FILTER(17) VALUE 'WRITE_WITH_FILTER',

SABC_ACT_DELETE(6) VALUE 'DELETE',

SABC_ACT_INIT(4) VALUE 'INIT',

SABC_ACT_ACCEPT(6) VALUE 'ACCEPT',

SABC_ACT_CALL(4) VALUE 'CALL'.

Could you please explain.,

2 REPLIES 2

Former Member
0 Kudos

Hi,

Constants

Constants are named data objects that you create statically using a declarative statement. They allow you to store data under a particular name within the memory area of a program. The value of a constant must be defined when you declare it. It cannot subsequently be changed. The value of a constant cannot be changed during the execution of the program. If you try to change the value of a constant, a syntax error or runtime error occurs.

You declare them using the CONSTANTS statement. Within the program, you can also declare local variables within procedures using CONSTANTS. The same rules of visibility apply to constants as to types (see The TYPE Addition). Local constants in procedures obscure identically-named variables in the main program. Constants live for as long as the context in which they are declared.

The syntax of the CONSTANTS statement is exactly the same as that of the DATA statement, but with the following exceptions:

You must use the VALUE addition in the CONSTANTS statement. The start value specified in the VALUE addition cannot be changed during the execution of the program.

You cannot define constants for XSTRINGS, references, internal tables, or structures containing internal tables.

Elementary constants:

CONSTANTS: pi TYPE P DECIMALS 10 VALUE '3.1415926536'.

ref_c1 TYPE REF TO C1 VALUE IS INITIAL.

The last line shows how you can use the IS INITIAL argument in the VALUE addition. Since you must use the VALUE addition in the CONSTANTS statement, this is the only way to assign an initial value to a constant when you declare it.

Complex constants:

CONSTANTS: BEGIN OF myaddress,

name(20) TYPE c VALUE 'Fred Flintstone',

street(20) TYPE c VALUE 'Cave Avenue',

number TYPE p VALUE 11,

postcode(5) TYPE n VALUE 98765,

city(20) TYPE c VALUE 'Bedrock',

END OF myaddress.

This declares a constant structure MYADDRESS. The components can be addressed by MYADDRESS-NAME, MYADDRESS-STREET, and so on, but they cannot be changed.

Former Member
0 Kudos

Hi Abap Learner,

Events in Dialog Program

PBO - Process Before Output

PAI - Process After Input

POH - Process on Help Request

POV - Process on Value Request.

Events in ABAP Programming

Classical Reporting:

INITIALIZATION

AT SELECTION-SCREEN OUTPUT

AT SELECTION-SCREEN

START-OF–SELECTION.

TOP-OF-PAGE

END-OF-PAGE

END-OF-SELECTION.

Events in Interactive Report

TOP-OF-PAGE DURING LINE-SELECTION

AT USER-COMMAND.

AT LINE-SELECTION

AT PF-FUNCTION KEY

Control Break events related to Internal Tables:

AT NEW FIELD

AT END OF FIELD

AT FIRST

AT LAST

Triggering and Handling Events

In ABAP Objects, triggering and handling an event means that certain methods act as triggers and trigger events, to which other methods - the handlers - react. This means that the handler methods are executed when the event occurs.

This section contains explains how to work with events in ABAP Objects. For precise details of the relevant ABAP statements, refer to the corresponding keyword documentation in the ABAP Editor.

Triggering Events

To trigger an event, a class must

· Declare the event in its declaration part

· Trigger the event in one of its methods

Declaring Events

You declare events in the declaration part of a class or in an interface. To declare instance events, use the following statement:

EVENTS ...

The registration applies automatically to the whole class, or to all of the classes that implement the interface containing the static event. In the case of interfaces, the registration also applies to classes that are not loaded until after the handler has been registered.

Timing of Event Handling

After the RAISE EVENT statement, all registered handler methods are executed before the next statement is processed (synchronous event handling). If a handler method itself triggers events, its handler methods are executed before the original handler method continues. To avoid the possibility of endless recursion, events may currently only be nested 64 deep.

Handler methods are executed in the order in which they were registered. Since event handlers are registered dynamically, you should not assume that they will be processed in a particular order. Instead, you should program as though all event handlers will be executed simultaneously.

kindly reward if found helpful.

cheers,

Hema.