‎2005 Dec 26 11:15 AM
hi frnds,
can any1 tell me when exactly to use the event "initialization".? coz we can as well pass the values by "default" or "value" options of the data or parameter and select-options statements.
I kno that it is only once that the initialization event is excuted b4 the values are passed into "at selection-screen" events.
any precise reason for using initialization???
is it true that when the program is run back ground , only the values in "initialization " events are considered ?
points assured!!!.
madan..
‎2005 Dec 26 11:18 AM
by default if want to initialize a value on selection
by selecting a value from data base table on condition as u cannot do this in data declaration statement
‎2005 Dec 26 11:18 AM
by default if want to initialize a value on selection
by selecting a value from data base table on condition as u cannot do this in data declaration statement
‎2005 Dec 26 11:21 AM
hi,
a bit clearer plz...
can we have a select statement in initialization and then based on the database selection made, initialize the values ?
regrds..
‎2005 Dec 26 11:22 AM
‎2005 Dec 26 11:24 AM
Hi,
Select statement can be used. But Select single is preferred.
Some times we may have Select Option on the Selection Screen. I don't think we can give default values for
both high and low.
Regards,
GSR.
‎2005 Dec 26 11:44 AM
Hi
The INITIALIZATION event is run only once, so you should use this event to do something has to be done only once and before the program is completly loaded.
Infact while running this event the SELECTION-SCREEN is not active, so you can't read the data passed to selection-screen:
REPORT Z1.
PARAMETERS: P_BUKRS LIKE T001-BUKRS.
INITIALIZATION.
SELECT SINGLE * FROM T001 WHERE BUKRS = P_BUKRS.
Now if you call this report in another report:
SUBMIT Z1 WITH P_BUKRS = 'Z001' AND RETURN.
The INITIALIZATION event doesn't work because it can't see the selection-screen, for this event P_BUKRS is null.
So you can use this event to inizializate the selection-screen:
INITIALIZATION.
P_BUKRS = 'Z001'.
but this statament is the same of:
PARAMETERS P_BUKRS LIKE T001-BUKRS DEFAULT 'Z001'.
But you could initializate the SELECT-OPTION with many data:
INITIALIZATION.
SO_BUKRS(3) = 'IEQ'.
SO_BUKRS-LOW = 'Z001'.
APPEND SO_BUKRS.
SO_BUKRS-LOW = 'Z002'.
APPEND SO_BUKRS.
SO_BUKRS-LOW = 'Z003'.
APPEND SO_BUKRS.
..........
SO_BUKRS-LOW = 'Z00N'.
APPEND SO_BUKRS.
So you can't do a select statament in order SELECTION-SCREEN: you should do it in AT SELECTION-SCREEN OUTPUT, this event is always run before showing selection-screen.
But you can do a selection screen based on some constants, for example transaction code.
INITIALIZATION.
SELECT SINGLE * ZMY_TABLE WHERE CODE = SY-TCODE.
IF SY-SUBRC <> 0.
MESSAGE E..... WITH 'No data in ZMY_TABLE'.
ENDIF.
In this case the abend is raised because a my table is not correctly filled for transaction.
So I think the only rule to use this event is if I have to do something only once.
Max
Message was edited by: max bianchi
‎2005 Dec 26 11:20 AM
‎2005 Dec 26 11:24 AM
just to pass the default values ??
will hte values not be passed if u define it by "VALUE" and "DEFAULT" options???
regrds,
madan..
‎2005 Dec 26 11:49 AM
Hi,
One more addition.
INITIALIZATION is only processed with the SUBMIT,
and not with CALL SELECTION-SCREEN.
Regards,
GSR.
‎2005 Dec 26 11:23 AM
Hi madan,
1. good question.
2. It is not only the parameters default value
which are required/accessed/controlled
in initialization event.
3. In a program there are so many variables,
the values of these variables
can be set in intiailization event.
4. Such values sometimes cannot be hardcoded.
They may be requried to fetch from database
or do some calculations,
(which is not possible while declaration
data and parameters)
5. Sometimes, some variant can also be imported
for selection screen.
regards,
amit m.
Message was edited by: Amit Mittal
‎2005 Dec 26 11:25 AM
Hi,
The parameters (PARAMETERS) and selection criteria (SELECT-OPTIONS) defined in the program already contain default values (if specified). You can assign different values during the initialization event and also change the database-specific selections.
Regards,
Suresh Datti
‎2005 Dec 26 11:25 AM
Hi Madan,
Initialization is the section where the initialization of internal tables, variables, select-option fields, parameters etc takes place.
True, that you can default the values too for parameters/select-option fields in selection-screen.
This event is invoked directly after LOAD-OF-PROGRAM and before the selection screen processing of any existing standard selection screen.
This gives you the one-time opportunity to initialize the input fields of the selection screen, including those defined in the logical database linked with the program.
When run in background, values initialized in initialization event are considered.
For eg: if you want to initialize like this:
carrid-sign = 'I'.
carrid-option = 'EQ'.
carrid-low = 'AA'.
carrid-high = 'LH'.
APPEND carrid TO carrid.
You cannot achieve this by giving 'default' or 'value' at selection-screen.
Regards,
Raj
‎2005 Dec 26 11:27 AM
Hi Madan,
One more advantage of using Initialization event is that you cannot default multiple select-option values at the time of declaration.
eg:
Initialization.
s_matnr-low = '00000008'.
S_matnr-sign = 'I'.
s_matnr-option = 'EQ'.
append s_matnr.
s_matnr-low = '00000009'.
S_matnr-sign = 'I'.
s_matnr-option = 'EQ'.
append s_matnr.
REgards,
Ravi
‎2005 Dec 26 11:58 AM
Hi Madan Kochana,
Here is a clear picture how different events are called in abap. Check it out. Very Usefull.
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm
Hope this helps.
Regards,
Maheswaran.B