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

Can't return multiple values (OO)

former_member295881
Contributor
4,473

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_vkorgTYPE vkorg.

     

Please advise how to return all of them like I IMPORTED them above (in get_details method)

Many thanks in advance.

4 REPLIES 4
Read only

Former Member
0 Likes
2,173

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

Read only

0 Likes
2,173

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,

Read only

0 Likes
2,173

Yes, its like FM.

What you have done is correct, now just assign the values inside this method and it will work fine.

Read only

0 Likes
2,173

Thanks for sharing the concept mate, I just exported the values and all looks good.