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

using at last statement

Former Member
0 Likes
7,783

hi,

I am using at last statement in my code in the following code:-

LOOP AT ITAB1.

AT LAST.

SUM .

WRITE: / ITAB1-SPART,ITAB1-TOT1.

ENDAT.

ENDLOOP.

The code above perform the calculation of the field ITAB1-TOT1.

But in output it does not display the division number (ITAB1-SPART) and instead of it shows **.

I want to show the division no also but due to using of the keyword SUM it does not display it and i had tried to define field spart along with sum but it gives the syntax error.

can any body provide me guidlines for solving this problem.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,287

use READ ..

LOOP AT ITAB1.

AT LAST.

read table ITAB1 index sy-tabix.

SUM .

WRITE: / ITAB1-SPART,ITAB1-TOT1.

ENDAT.

ENDLOOP.

6 REPLIES 6
Read only

Former Member
0 Likes
4,287

Hi,

The fileds left to tot1 will not be worked with in the cotrol command statements like at new,at end of,at lat.

So Modify the code as follows.

data:

w_SPART type vbak-SPART.

LOOP AT ITAB1.

w_SPART = itab1-spart.

AT LAST.

SUM .

WRITE: / w_SPART,ITAB1-TOT1.

ENDAT.

ENDLOOP.

Read only

Former Member
0 Likes
4,288

use READ ..

LOOP AT ITAB1.

AT LAST.

read table ITAB1 index sy-tabix.

SUM .

WRITE: / ITAB1-SPART,ITAB1-TOT1.

ENDAT.

ENDLOOP.

Read only

0 Likes
4,287

HI SRINIVAS,

i had assigned the full points to u as u had solved my problem.

thanks

Read only

Former Member
0 Likes
4,287

try writing using the position(length) information..

ex write 30(50) ITAB1-Field1.

~Piyush Patil

Read only

Former Member
0 Likes
4,287

hi,

the SUM statement in control break events like AT LAST works only for numeric value and not for character fields, it will sum up all the numeric fields of your internal table.

so if you wants to sum SPART, you cannot do it in AT LAST, you have to do it outside this AT LAST event.

With luck,

Pritam.

Read only

Former Member
0 Likes
4,287

Hi Abaper,

Use..

LOOP AT ITAB1.

WRITE: /5 ITAB1-SPART, 15 ITAB1-TOT1.

AT LAST.

SUM .

WRITE: /5 'Total', 15 ITAB1-TOT1.

ENDAT.

ENDLOOP.