Skip to Content
author's profile photo Former Member
Former Member

how to add different numeric fields

hai,

How to sum the different numeric fields like eno,esal and dno for a table EMP between eno= 51 to 57 of 100 records.

Please provide the code for this.

regards,

bhargav.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Sep 26, 2005 at 02:03 PM

    Hi,

    to avoid a dump you can try sth like this:

    DATA pval TYPE p DECIMALS 0.

    data cval(8).

    DATA n TYPE n.

    DATA i TYPE i.

    CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.

    MOVE cval TO pval.

    ENDCATCH.

    if sy-subrc = 0.

    sum = cval + n + i.

    endif.

    Andreas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi,

      let us assume all the values in the internal table.

      in the loop we get get values one by one then we need to check if the eno is greter than 50 and less than 57 you do the sum and keep it into separate variable, that's it.

      cheers,

      sasi

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 02:05 PM

    hi,

    loop at itab_emp.

    if itab_emp-eno ge 51 and itab_emp-eno le 57

    esal = esal + itab_emp-esal.

    endif

    endloop.

    is this you want.

    sasi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 02:11 PM

    You can use

    sort itab by empno.

    Loop at itab where empno ge '51'

    and empno le '57' .

    <You adding logic here >.

    Endloop.

    Cheers

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.