‎2011 Sep 09 4:17 AM
Hi All,
I have created a class ZZ_CL_ABC and its methods :
ZZ_M1
ZZ_M2
in method ZZ_M1, one table gets filled up ITAB and I want to access this ITAB in the ZZ_M2.
These methods are getting called from one report
DATA I_ZZ_CL_ABC TYPE REF TO ZZ_CL_ABC .
CREATE OBJECT I_ZZ_CL_ABC .
call method I_ZZ_CL_ABC->zz_M1
exporting
imat = imat.
call method I_ZZ_CL_ABC->zz_M2.
Now I want to access the ITAB which gets filled up in method ZZ_M1 and I want to access that in ZZ_M2, when ZZ_M2 gets called through the program.
rgds,
Madhuri
Edited by: Matt on Sep 9, 2011 6:11 AM - changed tags to lower case
‎2011 Sep 09 5:12 AM
So what's the problem? Define ITAB as an attribute of the class.
‎2011 Sep 09 5:14 AM
the values of ITAB are getting cleared at the time I call the second method through program
‎2011 Sep 09 5:35 AM
You need to restate your issue. At the moment you simply haven't given sufficient information. Unless zz_m1 clears the table, or neglects to set it, it won't be cleared.
Have you tried debug?
Edited by: Matt on Sep 9, 2011 6:35 AM
‎2011 Sep 09 5:44 AM
I have created a class through class builder zcl_material.
in it I have written 2 methods:
get_material
get_quantity
in method get_material, the materials are getting stored in table it_material.
in method get_quantity, the quantity for materials in it_quantiry, for materials present in the it_material table is calculated
Now I am using this class in one report and calling its methods
get_material : select * from mara into it_material.
get_quantity : select * from mard in it_quantity for all entries in it_material.
The it_material table, I dont want to pass to the report. So what i did is, I declared this table in the attributes tab of the class builder with level instance and visibility as private.
after calling method get_material, the data is present in the it_material.
but when I am calling the method get_quantity, in the select query, the it_material is blank???
So how should I define any variable/ table so that it will be present till the class object is there????
is it possible through class builder->attribute?
‎2011 Sep 09 5:49 AM
Defining the attribute as instance/private is correct. Attributes do not get cleared between method calls. You must go through in debug and find out where the table is being cleared.
Is the instance of your object the same each time, for example? Have you declared in the method a local variable with the same name as the attribute?
‎2011 Sep 09 5:49 AM
after calling method get_material, the data is present in the it_material.
but when I am calling the method get_quantity, in the select query, the it_material is blank???
Can you post the code how you are calling the methods get_material( ) & get_quantity( ) ?
BR,
Suhas
‎2011 Sep 09 6:05 AM
thanks Matt,
It got solved. I was maintaing that table in 2 places . in the exporting parameter for method get_material and in the attribute also. So it was clearing out. Now I removed it_material from exporting parameter, and its storing values till the object persists.
thanks a lot for follow up of question.
thanks Suhas for reply, the doubt got solved.