‎2006 Jul 26 11:25 PM
Hi,
I am having problems executing this program using events. I think it is a simple problem but am not able to solve it.
REPORT Z_KMADHUR_PROGRAM5.
class declarations.
class pilot definition.
public section.
methods: call_flight_attendant.
EVENTS: call_button_presses.
endclass.
class passenger definition.
public section.
methods: constructor importing value(i_seatnumber) type i,
service_number importing value(i_servicenumber) type i,
service_type importing value(i_servicetype) type i,
call_for_help.
EVENTS: call_button_pressed exporting value(e_seatnumber) type i,
call_service_number exporting value(e_servicenumber) type i,
call_service_type exporting value(e_servicetype) type i.
PROTECTED SECTION.
data seatnumber type i.
data servicenumber type i.
data servicetype type i.
endclass.
class flight_attendant DEFINITION.
PUBLIC SECTION.
METHODS: constructor
importing i_id type string,
help_the_pilot for EVENT
call_button_presses OF pilot,
help_a_passenger FOR EVENT
call_button_pressed OF passenger
IMPORTING e_seatnumber,
give_service_number for event
call_service_number of passenger
IMPORTING e_servicenumber,
give_service_type for event
call_service_type of passenger
IMPORTING e_servicetype.
PROTECTED SECTION.
DATA id TYPE string.
ENDCLASS.
class Implementations
class pilot implementation.
method call_flight_attendant.
RAISE EVENT call_button_presses.
ENDMETHOD.
ENDCLASS.
class passenger implementation.
method: constructor.
seatnumber = i_seatnumber.
servicenumber = servicenumber.
servicetype = servicetype.
endmethod.
method: call_for_help.
RAISE EVENT call_button_pressed
EXPORTING e_seatnumber = seatnumber.
RAISE EVENT call_service_number
exporting e_servicenumber = servicenumber.
RAISE EVENT call_service_type
exporting e_servicetype = servicetype.
endmethod.
endclass.
class flight_attendant implementation.
method: constructor.
id = i_id.
endmethod.
method: help_the_pilot.
write: / id, 'helps pilot'.
endmethod.
method: help_a_passenger.
write: / id, 'helps passenger on seat',e_seatnumber.
endmethod.
method: give_service_number.
write: 'to have', e_servicenumber.
endmethod.
method: give_service_type.
write: e_servicetype.
endmethod.
endclass.
global data
DATA: o_pilot type ref to pilot,
o_passenger_1 type ref to passenger,
o_passenger_2 type ref to passenger,
o_passenger_3 type ref to passenger,
o_passenger_4 type ref to passenger,
o_passenger_5 type ref to passenger.
DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant,
classical processing blocks
start-of-selection.
create object o_pilot.
create object o_passenger_1 exporting i_seatnumber = 11.
create object o_passenger_2 exporting i_seatnumber = 17.
create object o_passenger_3 exporting i_seatnumber = 21.
create object o_passenger_4 exporting i_seatnumber = 25.
create object o_passenger_5 exporting i_seatnumber = 31.
create object: o_purser
exporting i_id = 'purser',
o_stewardess
exporting i_id = 'stewardess',
set handler: o_purser->help_the_pilot for o_pilot,
o_stewardess->help_a_passenger for all instances,
o_stewardess->give_service_number for all instances,
o_stewardess->give_service_type for all instances.
call method: o_pilot->call_flight_attendant,
o_passenger_1->call_for_help,
o_passenger_1->call_service_number.
I am getting an error near the start-of-selection. It says "statement is not acceptable".
If i remove the start-of-selection, it says "unable to interpret object. Incorrect spelling or coma error".
<b>My output should look like:
purser helps pilot
stewardess helps passenger on seat 11 to have 2 foodservice.
stewardess helps passenger on seat 11 to have 2 drinkservice.
stewardess helps passenger on seat 17
stewardess helps passenger on seat 17 to have 1 foodservice.
stewardess helps passenger on seat 17 to have 1 drinkservice.
stewardess helps passenger on seat 21
stewardess helps passenger on seat 21 to have 3 foodservice.
stewardess helps passenger on seat 21 to have 3 drinkservice.
stewardess helps passenger on seat 25
stewardess helps passenger on seat 25 to have 1 foodservice.
stewardess helps passenger on seat 25 to have 1 drinkservice.
stewardess helps passenger on seat 31
stewardess helps passenger on seat 31 to have 2 foodservice.
stewardess helps passenger on seat 31 to have 2 drinkservice.</b>
Thanks in advance..
cheers,
Madhuri
‎2006 Jul 26 11:38 PM
Hi,
Simple mistake...
<b>DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant,</b>
you are placing , instead of period.
Check the below code...
<b>DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant.</b>
‎2006 Jul 26 11:38 PM
Hi,
Simple mistake...
<b>DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant,</b>
you are placing , instead of period.
Check the below code...
<b>DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant.</b>
‎2006 Jul 27 2:37 AM
Hi,
No need to remove the start-of-selection event. You just forgot to place a period here:
DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant, <----
That is why the erros says comma error.
Hope this helps...
P.S. Please award points for useful answers.
‎2006 Jul 27 4:44 AM
Hi,
The error is in this statement.
DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant,
It can be corrected as follows:
DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant.
Regards,
Vijay.
‎2006 Jul 27 5:20 AM
Hi all,
This is not where my error is. I have corrected this one already.
The error I posted is near the start-of-selection line.
Please help me with that error. it says statement is not accessible.
Thanks,
Madhuri
‎2006 Jul 27 7:29 AM
Is there any difference between my, Azaz, Viray and Vijay's answer???
‎2006 Jul 27 4:59 AM
Hi
u jus need to put a period thts it!!!
well dint u activated ur prog or dint check syntactically?? it shows this minor mistakes there itself anyways here is the code-
DATA: o_purser type ref to flight_attendant,
o_stewardess type REF to flight_attendant.
Regards,
Seema.
‎2006 Jul 27 5:29 AM
Hi,
Thanks for all your replies. This is not the error I was talking about. I forgot to put the period by mistake.
My error is near the start-of-selection line and the error says "statement cannot be accessed".
Thanks,
Madhuri
‎2006 Jul 27 6:28 AM
Hi Madhuri,
Usually such errors happen when you fail to put start-of-selection statement to demarcate the variable declaration and the object creation while dealing with local classes.
It can also happen when you fail to close the class definition or implementation using endclass statement or you fail to put a period (.) after the endclass statement..
Just check in your program for similar cases.Of if you don't mind, can you just post the final, modified source-code so that we can analyse it for errors..
Regards,
Amit.
‎2007 Mar 11 1:05 PM
Hi madhun,
whereever you copied the program
exporting i_id = 'stewardess'. "<== no comma here
Implementation missing for method "SERVICE_NUMBER" .
Implementation missing for method "SERVICE_TYPE" .
That's where I gave up.
Regards,
Clemens