Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:54:55+00:00 2026-06-11T12:54:55+00:00

I get used to JAVA, thus having problem to write this code in ABAP.

  • 0

I get used to JAVA, thus having problem to write this code in ABAP.

I call a method with two parameters. It should return a number, so I can save it.

What I want is

int result = generate_num(40,5);

int generate_num(int thisNum, int newDigit){
    return thisNum * 10 + newDigit;
}

In ABAP I tried this so far.

//Declared Method

methods GENERATE_NUM
importing
  !thisNum type I
  !NEWDIGIT type DIGIT_NUMBER_VALUE.

//Calling Method

CALL METHOD me->Generate_NUM
   EXPORTING
       thisNUm = 40
       newDigit = 5.

//Method itself

METHOD GENERATE_NUM.

  
DATA: newNum type i.

  If thisnum < 0.
    newNum = thisnum * 10 - newdigit.
  Else.
    newNum = thisnum * 10 + newdigit.
  ENDIF.

  RETURNING VALUE(newNum).   

ENDMETHOD.

But I get lost in this code, have no idea how to return a value and how to save it in another variable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:54:56+00:00Added an answer on June 11, 2026 at 12:54 pm

    That’s how you declare a method with a return parameter:

    METHODS generate_num 
      IMPORTING
        thisNum TYPE i   
        newdigit TYPE digit_number_value
      RETURNING
        value(result) TYPE i.
    

    Note that a method can only have one RETURNING parameter, and that parameter must always be passed by value.

    In the method implementation, you set the return value by modifying the local variable you declared as returning parameter:

    METHOD generate_num.
    
      IF thisnum < 0.
        result = thisnum * 10 - newdigit.
      ELSE.
        result = thisnum * 10 + newdigit.
      ENDIF.     
    
    ENDMETHOD.
    

    The returned value will be whatever value result has when the method returns. Just like with EXPORTING parameters.

    When you call a method you can either use the classic CALL syntax which is more like the syntax seasoned ABAP developers are used to:

    DATA lv_foo TYPE i. " the variable you want to store the return value in
    
    CALL METHOD me->generate_num
       EXPORTING
           thisNUm = 40
           newDigit = 5
       RECEIVING
           result = lv_foo.
    

    or the functional syntax which is more like the Java syntax you might be used to:

    lv_foo = me->generate_num( thisNUm = 40 newDigit = 5).
    

    If the method doesn’t just have importing parameters but also changing or exporting parameters, the syntax looks like this:

    lv_foo = me->generate_num( 
       EXPORTING thisNUm = 40 
                 newDigit = 5
       CHANGING cv_bar = lv_bar ).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the code from http://www.rgagnon.com/javadetails/java-0580.html to get Motherboard Id, but the result is
i used java reflections to get methods from a class(loaded those classes).Now i want
i use java reflections to get methods used in a class.I also want to
Question Is it possible to get the version of the Java Plugin being used
Our company uses checkstyle to ensure the java source code having no nested if..else.
I get used to eclipse and know that ctrl+F9 is used for running java
I wrote a very simple program in java to get used with the use
So I'm writing an introductory java program to get used to multithreading, however, I'm
I'm trying to get to grips with the visitor method in Java. I'm trying
I'm developing spring MVC application and I used AirPortForm.java to get information in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.