Application Development and Automation 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: 
Read only

Inheritance clarification.

VenkatRamesh_V
Active Contributor
0 Likes
395

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.

1 REPLY 1
Read only

Former Member
0 Likes
367

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( ).