‎2005 Oct 06 2:47 PM
Hi all,
Is it possible to declare the events in a report program twice. That is, can i declare an event 'initialization' or say 'start-of-selection' twice in the same report program. If yes, then what is the implication of such an instance.
Any help will be highly appreciated
Regards,
Hitanshu
‎2005 Oct 06 2:49 PM
Hi,
No You can't .
-> navigation in se80 (events) notifies an error
Andreas
‎2005 Oct 06 2:50 PM
No You can't Declare Same Events Twice in a Program.
‎2005 Oct 06 2:52 PM
hi,
these are the events are processed by the system, you can't declare twice . suppose if the orders are changed the system takes the correct order automatically
cheers,
sasi
‎2005 Oct 06 2:53 PM
Hi,
Yes, You cabn declare it.
The even at last will get processed in case yiu have
declared the same one twice.
But I don't know why you are doing this?
Please reward points if this explanation is useful.
Regads,
siva
‎2005 Oct 06 2:59 PM
Hi siva ,
thanks for the reply. I was just checking it out and the implication of such an instant.
if u can kindly look at my test code :
&----
*& Report Z_TEST_101 *
*& *
&----
*& *
*& *
&----
REPORT Z_TEST_101 .
TABLES : MARA, MARC, MARD.
DATA : BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
END OF I_MARA.
DATA : BEGIN OF I_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
END OF I_MARC.
DATA : BEGIN OF I_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
WERKS LIKE MARD-WERKS,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
END OF I_MARD.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
PARAMETERS : P_WERKS LIKE MARC-WERKS.
*START-OF-SELECTION.
INITIALIZATION.
SELECT MATNR MTART MEINS
INTO TABLE I_MARA
FROM MARA
WHERE MATNR IN S_MATNR.
*START-OF-SELECTION.
INITIALIZATION.
IF NOT I_MARA[] IS INITIAL.
SELECT MATNR WERKS
INTO TABLE I_MARC
FROM MARC
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR.
ENDIF.
START-OF-SELECTION.
LOOP AT I_MARA.
WRITE 😕 I_MARA-MATNR, I_MARA-MTART, I_MARA-MEINS.
ENDLOOP.
start-of-selection.
ULINE.
LOOP AT I_MARC.
WRITE 😕 I_MARC-MATNR, I_MARC-WERKS.
ENDLOOP.
it has two intialisations and two start of selections but
it is firing all the events.
Any thoughts ?
regards,
Hitanshu
‎2005 Oct 06 3:08 PM
‎2005 Oct 06 3:09 PM
Hi
You can't write this statament:
INITIALIZATION.
SELECT MATNR MTART MEINS
INTO TABLE I_MARA
FROM MARA
WHERE MATNR IN S_MATNR.
because this statament run before generate selection-screen, so it can't know how S_MATNR is.
TABLES : MARA, MARC, MARD.
DATA : BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
END OF I_MARA.
DATA : BEGIN OF I_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
END OF I_MARC.
DATA : BEGIN OF I_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
WERKS LIKE MARD-WERKS,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
END OF I_MARD.
SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
PARAMETERS : P_WERKS LIKE MARC-WERKS.
START-OF-SELECTION.
SELECT MATNR MTART MEINS
INTO TABLE I_MARA
FROM MARA
WHERE MATNR IN S_MATNR.
IF SY-SUBRC = 0.
SELECT MATNR WERKS
INTO TABLE I_MARC
FROM MARC
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND WERKS = P_WERKS.
ENDIF.
END-OF-SELECTION.
LOOP AT I_MARA.
WRITE 😕 I_MARA-MATNR, I_MARA-MTART, I_MARA-MEINS.
ENDLOOP.
IF SY-SUBRC = 0.
ULINE.
ENDIF.
LOOP AT I_MARC.
WRITE 😕 I_MARC-MATNR, I_MARC-WERKS.
ENDLOOP.
Max
‎2005 Oct 06 3:12 PM
hi,
why you want like this?
is there any logic behind there?
intialization executes only once
and start-of selection executes (and executes at F8)
cheers,
sasi
‎2005 Oct 06 3:34 PM
You can write the events in your code as many times as you wish and in whatever order you want. The program will execute them in the order of INITIALIZATION, SELECTION-SCREEN, START-OF-SELECTION, END-OF-SELECTION, AT events. TOP-OF-PAGE, END-OF-PAGE will get triggered as you output to the screen, whether in START-OF-SELECTION or END-OF-SELECTION.
Now if you have more than on occurance of an event, the system will execute all the occurances in the order they appear in the program.
Look at the following piece of program.
DATA: v_flag_init1,
v_flag_init2,
v_flag_init3,
v_flag_start,
v_flag_top,
v_flag_end.
INITIALIZATION.
v_flag_init1 = '1'.
END-OF-SELECTION.
v_flag_end = '1'.
WRITE:/ 'V_FLAG_END = ', v_flag_end.
INITIALIZATION.
v_flag_init2 = '3'.
START-OF-SELECTION.
WRITE:/ 'V_FLAG_INIT1 = ', v_flag_init1,
/ 'V_FLAG_INIT2 = ', v_flag_init2,
/ 'V_FLAG_INIT3 = ', v_flag_init3.
v_flag_start = '2'.
WRITE:/ 'V_FLAG_START = ', v_flag_start.
INITIALIZATION.
v_flag_init3 = '2'.
TOP-OF-PAGE.
v_flag_top = '2'.
WRITE:/ 'V_FLAG_TOP = ', v_flag_top.
START-OF-SELECTION.
v_flag_start = '1'.
WRITE:/ 'V_FLAG_START = ', v_flag_start.
END-OF-SELECTION.
v_flag_end = '2'.
WRITE:/ 'V_FLAG_END = ', v_flag_end.
TOP-OF-PAGE.
v_flag_top = '1'.
WRITE:/ 'V_FLAG_TOP = ', v_flag_top.
It gives the following output.
V_FLAG_TOP = 2
V_FLAG_TOP = 1
V_FLAG_INIT1 = 1
V_FLAG_INIT2 = 3
V_FLAG_INIT3 = 2
V_FLAG_START = 2
V_FLAG_START = 1
V_FLAG_END = 1
V_FLAG_END = 2
If this helps, please reward and close the thread.
Srinivas
‎2005 Oct 07 6:45 AM
‎2005 Oct 07 5:43 PM
Please reward and close if answered.
Thanks,
Srinivas