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

Urgent: returning values

Former Member
0 Likes
1,111

Hi All,

how to get the value from a returning pararmeter when we call a method from the main program.

call method obj1->withdraw exporting amount = 100

regards

Siddhartha

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,079

There are a few ways, but the way that I prefer is like so. Here, SOME_VALUE is the returning parameter.

data: some_value type i.


some_value = obj1->get_some_value( ).

Regards,

RIch Heilman

Hi All,

how to get the value from a returning pararmeter when we call a method from the main program.

call method obj1->withdraw exporting amount = 100

regards

Siddhartha

9 REPLIES 9
Read only

Former Member
0 Likes
1,079

Hi Siddhartha,

If that method has the return parameter then only you can get it.Check if this method has return parameters.

Regards,

Atish

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,080

There are a few ways, but the way that I prefer is like so. Here, SOME_VALUE is the returning parameter.

data: some_value type i.


some_value = obj1->get_some_value( ).

Regards,

RIch Heilman

Read only

0 Likes
1,079

Hi RIch,

NEW_BALANCE = obj1->deposit.

New balance is my returning parameter of the method, but at the same time i have to export some values too to that method.

its not working for me.

regards

Siddhartha

Read only

0 Likes
1,079

You can still use this syntax. Here the IM_VALUE is your importing parameter.

NEW_BALANCE = obj1->deposit( im_value = 100 ).

Regards,

RIch Heilman

Read only

0 Likes
1,079

HI,

In addition to the code

new_balance = obj1->deposit( 'some value' ).

You can use the following syntax also.

CALL METHOD obj1->deposit
  EXPORTING
    iv_value   = 'some value'
  RECEIVING
    iv_balance = new_balance.

Regards

Geogy

Read only

0 Likes
1,079

Hi Geogy,

thanks for the reply, but you know none of the things are working for me, i dont know why.

CALL METHOD obj1->deposit

EXPORTING

iv_value = 'some value'

RECEIVING

iv_balance (main program parameter) = new_balance(returning parameter).

when i am using this one, its saying the reverse is accepted, its throwing a syntax error.

e.g.

CALL METHOD obj1->deposit

EXPORTING

iv_value = 'some value'

RECEIVING

new_balance(returning parameter) = iv_balance (main program parameter).

and the output is coming as zero. as the program parameter value is Zero.

Please help.

Regards

Siddhartha

Read only

0 Likes
1,079

If the returning parameter is defined as NEW_BALANCE within the method, then the following should work fine. But you must be move some result to this parameter inside the method itself.

CALL METHOD obj1->deposit
EXPORTING
iv_value = 'some value'
RECEIVING
new_balance = iv_balance .

So for example, inside this method, you should be filling it.

method deposit.

  new_balance = 100.  "or whatever your logic is

endmethod.

Regards,

RIch Heilman

Read only

0 Likes
1,079

Hi RIch,

Thanks a lot for the help, actually i was missing on that part where some operation has to be carried out for the parameter which i am returning, now the problem is solved. Once again Thanks a lot.

regards

Siddhartha Sengupta

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
1,079

Hi,

You can use the other form also.

<data> = obj1->withdraw ( exporting amount = 100 ).

or.

call method obj1->withdraw

exporting amount = 100

receiving <parameter> = <data>.

Regards.

Marcelo Ramos