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

adding numbers in report

Former Member
0 Likes
758

hi guru,

i developed a report.

IF S_BGPRO = 'X'.

SELECT AUFNR GMNGA FROM

AFRU INTO CORRESPONDING FIELDS OF TABLE IT_AFRU12 WHERE WERKS = 'PD01'

AND BUDAT IN S_BUDAT.

IF NOT IT_AFRU12[] IS INITIAL.

SELECT AUFNR KTEXT PLNBEZ INTO CORRESPONDING FIELDS OF

TABLE IT_CAUFV1 FROM CAUFV

FOR ALL ENTRIES IN IT_AFRU12

WHERE AUFNR = IT_AFRU12-AUFNR.

IF SY-SUBRC 0.

MESSAGE E000(ZPP) WITH 'VALUE NOT EXISTING '.

ENDIF.

ENDIF.

ENDIF.

LOOP AT IT_AFRU12 INTO WA_AFRU12.

LOOP AT IT_CAUFV1 INTO WA_CAUFV1 WHERE AUFNR = WA_AFRU12-AUFNR.

WA_AFRU12-KTEXT = WA_CAUFV1-KTEXT.

WA_AFRU12-PLNBEZ = WA_CAUFV1-PLNBEZ.

MODIFY IT_AFRU12 FROM WA_AFRU12.

ENDLOOP.

ENDLOOP.

IN THE ABOVE COADING :

GMNGA value is in numbers . i want to add all the no.s and

displayed to last in my alv report.how to do this..

please help me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
739

Hi,

place this block in loop.

LOOP AT IT_AFRU12 INTO WA_AFRU12.

LOOP AT IT_CAUFV1 INTO WA_CAUFV1 WHERE AUFNR = WA_AFRU12-AUFNR.

WA_AFRU12-KTEXT = WA_CAUFV1-KTEXT.

WA_AFRU12-PLNBEZ = WA_CAUFV1-PLNBEZ.

MODIFY IT_AFRU12 FROM WA_AFRU12.

ENDLOOP.


total = total + WA_AFRU12-GMNGA.

at last.
  write:/ 'Total:',total.
endat.

ENDLOOP.

rgds,

bharat.

5 REPLIES 5
Read only

Former Member
0 Likes
739

Simply put at last statement in the last do loop. it will add the numebers and simply put your write statement within this.

loop .....

at last.

sum.

write:/ 'Total:', GMNGA.

endat.

endloop.

anya

Read only

Former Member
0 Likes
739

Hi,

To display the totals,u need to use control break statements

AT END OF <fld>(subtotals) or AT LAST(totals).

Have a look on the following code.

DATA: BEGIN OF ITAB OCCURS 0,

BUKRS LIKE LFC1-BUKRS,

UM01H LIKE LFC1-UM01H,

UM01U LIKE LFC1-UM01U,

END OF ITAB.

SELECT BUKRS UM01H UM01U INTO TABLE ITAB FROM LFC1.

SORT ITAB BY BUKRS.

LOOP AT ITAB.

WRITE:/ ITAB-BUKRS,7 ITAB-UM01H,ITAB-UM01U.

AT END OF BUKRS.

SUM.

WRITE:/ ITAB-BUKRS COLOR 7,7 ITAB-UM01H COLOR 7,ITAB-UM01U COLOR 7.

ENDAT.

AT LAST.

SUM.

WRITE:/ ‘TOTAL’ COLOR 3,ITAB-UM01H COLOR 1,ITAB-UM01U COLOR 1.

ENDAT.

ENDLOOP.

Reward,if it is useful.

Thanks,

Chandu.

Read only

Former Member
0 Likes
740

Hi,

place this block in loop.

LOOP AT IT_AFRU12 INTO WA_AFRU12.

LOOP AT IT_CAUFV1 INTO WA_CAUFV1 WHERE AUFNR = WA_AFRU12-AUFNR.

WA_AFRU12-KTEXT = WA_CAUFV1-KTEXT.

WA_AFRU12-PLNBEZ = WA_CAUFV1-PLNBEZ.

MODIFY IT_AFRU12 FROM WA_AFRU12.

ENDLOOP.


total = total + WA_AFRU12-GMNGA.

at last.
  write:/ 'Total:',total.
endat.

ENDLOOP.

rgds,

bharat.

Read only

0 Likes
739

HI GURU,

I AM DOING IN ALV REPORT.

PLEASE HELP

Read only

0 Likes
739

Hi,

Use DO_SUM in fieldcatalog for the field which u want to display the total.

This is used in manual development of fieldcatalog.

Regards,

Chandu.