Application Development 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: 

Urgent: returning values

Former Member
0 Kudos

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

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

9 REPLIES 9

Former Member
0 Kudos

Hi Siddhartha,

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

Regards,

Atish

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

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

0 Kudos

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

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

Regards,

RIch Heilman

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

marcelo_ramos
Active Contributor
0 Kudos

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