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: 

Problem with Select Statement.

Former Member
0 Kudos

Hi Gurus,

I have written select statement in INITIALIZATION event, and trying to call that in

Start of Selection(Using LDB ).

I know that once we write select statement in INITIALIZATION then by using READ Table statement we can call where ever we required.

I have done the same but its not picking the data from the Select statement which is decalred in INITIALIZATION event. can any one help me out.

Thanks in advanace.

1 REPLY 1

Former Member
0 Kudos

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.

Regards

vasu