2013 Mar 21 6:02 PM
Hello experts,
I’m a newbie in ABAP OO and need a suggestion from you experts. I’m trying to populate values on the selection screen from a custom (config) table. I need to do it on INITIALIZATION event so that when screen loads then user can see them. To accomplish it I wrote a CLASS-METHOD: get_details.
CLASS-METHODS: get_details IMPORTING im_file TYPE string
im_vkorg TYPE vkorg
im_vtweg TYPE vtweg
im_spart TYPE spart
im_ktokd TYPE tt_ktokd
im_kunnr TYPE tt_kunnr
im_date TYPE tt_date
im_time TYPE tt_time
im_test TYPE c,
This way I get all the variables (parameters) and tables (select-options) I need to populate. My question is can I write a CLASS-METHOD with EXPORTING parameters? The intend is to export all the values/tables back in one-shot. Currently I’m using few RETURN methods but they only return one variable/table at a time.
return_file RETURNING VALUE(r_file) TYPE string,
return_org RETURNING VALUE(r_vkorg) TYPE vkorg.
Please advise how to return all of them like I IMPORTED them above (in get_details method)
Many thanks in advance.
2013 Mar 21 6:24 PM
Hi,
Yes, you need to use exporting when you want to return multiple values, Importing variables cannot be changed inside a class method.
Returning just lets you return a single value, If you are assigning value inside the method you can use Exporting, or else if you already have a value assigned and you want to update it you can use Changing.
Hope you Understood the Difference
2013 Mar 21 6:36 PM
Many thanks Pratheek for the details. So it's like FM isn't it?
Here is how I wrote method to export values.
CLASS-METHODS:
return_values EXPORTING ex_file TYPE string
ex_vkorg TYPE vkorg.
ex_vtweg TYPE vtweg
ex_spart TYPE spart
ex_ktokd TYPE tt_ktokd
ex_kunnr TYPE tt_kunnr
ex_date TYPE tt_date
ex_time TYPE tt_time
ex_test TYPE c,
2013 Mar 21 6:43 PM
Yes, its like FM.
What you have done is correct, now just assign the values inside this method and it will work fine.
2013 Mar 21 6:53 PM
Thanks for sharing the concept mate, I just exported the values and all looks good.