- SAP Community
- Groups
- Interest Groups
- Application Development
- Discussions
- use do - enddo.

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.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

use do - enddo.

Former Member

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-05-2008 7:40 PM

please can anybody write this using do -

enddo

```
*DATA: BEGIN OF numbers,
* one TYPE p LENGTH 8 DECIMALS 0 VALUE 10,
* two TYPE p LENGTH 8 DECIMALS 0 VALUE 20,
* three TYPE p LENGTH 8 DECIMALS 0 VALUE 30,
* four TYPE p LENGTH 8 DECIMALS 0 VALUE 40,
* five TYPE p LENGTH 8 DECIMALS 0 VALUE 50,
* END OF numbers,
*
* sum TYPE i.
*
*
*SELECT-OPTIONS position FOR sum.
*
*ADD numbers-one THEN numbers-two
* UNTIL numbers-five
* ACCORDING TO position
* GIVING sum.
*
* write:/ sum.
```

Code Formatted by: Alvaro Tejada Galindo on Feb 5, 2008 3:24 PM

- SAP Managed Tags:
- ABAP Development

2 REPLIES 2

Former Member

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-05-2008 7:48 PM

Why not give it a try yourself and get back to the forum if you have problems.

Rob

- SAP Managed Tags:
- ABAP Development

Former Member

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

02-05-2008 8:51 PM

Hi Shaik,

I donot know what the select option field position is for , but assuming that all you need to do is sum all the fields of numbers structure i.e numbers-one + numbers-two.....and so on to get the result 150 and using do ..enddo.

To that, use the following code:

DATA : BEGIN of NUMBERS ,

place type p decimals 0, "place represents one, two, three and so on.....I dont need 5 different memory areas,i can achieve the

END of NUMBERS, "same result with just one field.

SUM type i value 0.

select-options position for sum.

numbers-place = 10. "initialising with first value for one =10.

do 5 times.

sum = sum + numbers-place."first time in do loop this is 0 = 0*10 i.e 10, then 10*20 ,then 30+30 and so on.

numbers-place = numbers-place + 10.

enddo.

write : sum. "this gives result as 10*20*30*40*50 =150.

Hope this helps answering your problem. **<REMOVED BY MODERATOR>**

Thanks.

Deepti

Edited by: Alvaro Tejada Galindo on Feb 5, 2008 4:38 PM

- SAP Managed Tags:
- ABAP Development