2014 Oct 17 7:24 AM
Hello Sir,
I am beginner object oriented
Requirement:
Created two radio buttons as 'VENDOR' and 'Customer' based on radio button get the corresponding vendor/Customer and GL Details .
Eg: Vendor - Bsik, Bsak,
Customer - Bsid, Bsad.
Gl - Bsis, Bsas. (Common For both)
Attempted: Created two local class Vendor/Customer , Gl.
Used Inheritance Considering Vendor/Customer as Main class and Gl as Subclass while accessing the subclass the main class internal table displayed null.Seen many sample examples displayed only with write statement(Clarification).
To declare common select Select Query(GL) for fetching vendor and customer Details Considering Field-Symbols to assign internal table in select query but its never worked.
So I tried with vendor details first. In inheritance subclass wrote a select query to fetch data based on main class itab, Code is activated without error and main class itab contains data, but subclass displaying values null ? .
Regards,
Venkat.
2014 Oct 17 8:30 AM
Hi,
Create one superclass, having one method for fetching GL details, leave it blank.
Now define two subclass , Vendor and Customer inheriting from superclass, here you can redefine the method for fetching GL details based on whether customer or vendor.
Same code will work irrespective of radio button selected.
Say lcl_super is your superclass
lcl_vendor is vendor
lcl_customer is customer.
Redefine the method(for fetching GL account ) in vendor and customer classes
Data: lob_super type ref to lcl_super,
lob_vendor type ref to lcl_vendor,
lob_cust type ref to lcl_customer.
if p_rad1 = 'X'.
create object lob_vendor.
lob_super = lob_vendor.
elseif p_rad2 = 'X'.
create object lob_cust.
lob_super = lob_cust.
endif.
call method lob_super->fetch_gl( ).