Hi all,
In my quest to improving my understanding of SAP ABAP, I have come accross a question, which is as follows:
When writing events such as Top-of-page, start-of-selection, etc. we do specify the name of the event & then write the processing statements.
However, there is no closing statement for the event unlike other structures/blocks like if..endif, module..endmodule, etc.
When the ABAP interpreter parses the code, how does it differentiate the statements to be included within the event block from the other following statements?
For example, how does the interpreter determine that the value assigment of SOME_INDICATOR is not to be processed in START-OF-SELECTION?
*******************************************************
S T A R T O F S E L E C T I O N E V E N T *
*******************************************************
START-OF-SELECTION.
DBCNT = -1.
SELECT
MATKL
MATNR
MEINS
MTART
MTPOS_MARA
INTO
CORRESPONDING FIELDS OF TABLE IT_MM
FROM
MARA.
DBCNT = SY-DBCNT.
*********************************************************
THIS BLOCK IS TO BE PROCESSED FOR INFORMATION DISPLAY *
*********************************************************
SOME_INDICATOR = 1.
WRITE 'TITLE OF THE REPORT COMES HERE'.
LOOP AT IT_MM.
WRITE: /1 IT_MM-MATNR , 17 SY-VLINE,
18 IT_MM-MTART , 32 SY-VLINE,
71 IT_MM-MEINS , 87 SY-VLINE,
88 IT_MM-MATKL , 103 SY-VLINE,
123 IT_MM-MTPOS_MARA , 141 SY-VLINE.
ENDLOOP.
How do I tell the interpreter to process a set of statements within a certain event block and leave out the rest?
Please clarify...
Regards,
Madhur
Hello Madhur,
The following conditions terminate an Event Block.
1. Beginning of the next event block.
2. A Subroutine Definition.
3. A Module Definition.
Now, to answer your question, so long as an <i>executable</i> statement falls under an event block, you cannot ask the interpreter to ignore it.
The only exception is to use the comment, but then a <i>comment</i> is not considered to be an <i>executable</i> statement !
Regards,
Anand Mandalika.
Message was edited by: Poornanand Mandalika
Hi,
You asked: How do I tell the interpreter to process a set of statements within a certain event block and leave out the rest?
Well, the only way to tell the interpreter is to place your code in that event block. When the code is compiled and run, respective code segments are called from these events by the runtime. For leaving out a particular segment, you need to incorporate the logic in your program to skip a portion of code based on a particular condition being met.
Regards
Add a comment