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.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to find grand total

Former Member
0 Kudos

Hi experts,

I have one internal table containing 2 fields quantity and amount.In the output i want to show total quantity and total amount. How can i achive it..?

something like this

qty amt

-


1 10

2 20

3 30

-


6 60

-


reward guaranteed

thanks

Kaki

1 ACCEPTED SOLUTION

Former Member
0 Kudos

LOOP AT itab INTO line.

WRITE: / line-qty, line-amt.

AT END OF qty.

SUM.

ULINE.

WRITE: / line-qty, line-amt.

SKIP.

ENDAT.

AT LAST.

SUM.

ULINE.

WRITE: / line-qty, line-amt.

ENDAT.

ENDLOOP.

16 REPLIES 16

Former Member
0 Kudos

LOOP AT itab INTO line.

WRITE: / line-qty, line-amt.

AT END OF qty.

SUM.

ULINE.

WRITE: / line-qty, line-amt.

SKIP.

ENDAT.

AT LAST.

SUM.

ULINE.

WRITE: / line-qty, line-amt.

ENDAT.

ENDLOOP.

0 Kudos

Thank u asit.Solved problem....

I have another doubt.

How can we find very recent programs that we have modified in se38?

kaki

0 Kudos

Hi,

Go to se11->TRDIR.

Enter Unam as ur user name and udat as the date you want in selection criteria.That will display the programs.

Just make a try.

0 Kudos

hi asit

iam not able to get the totals correctly....can u see this code....every thing is correct except grand totals..

REPORT YVFJAUD_BILLDET no standard page heading

line-size 200

line-count 65

message-id Z1.

*-- Table Declaration

TABLES: ZFJAUD_BILL,RLGRAP.

DATA: BEGIN OF T_BILL OCCURS 0,

VBELN LIKE ZFJAUD_BILL-VBELN, " Billin Doc number

POSNR like ZFJAUD_BILL-POSNR, " Billing item

CHARG like ZFJAUD_BILL-CHARG, " Batch Number

FKDAT like ZFJAUD_BILL-FKDAT, " Posting date

FKART like ZFJAUD_BILL-FKART, " Billing type

KUNAG like ZFJAUD_BILL-KUNAG, " Customer(Sold-to-party)

MATNR like ZFJAUD_BILL-matnr, " Material number

FKIMG like ZFJAUD_BILL-FKIMG, " Batch Quantity

NETWR like ZFJAUD_BILL-NETWR, " Amount

WAERK like ZFJAUD_BILL-WAERK, " Currency

VERPR like ZFJAUD_BILL-VERPR, " TP

BNAME like ZFJAUD_BILL-BNAME, " End customer

AUGRU_AUFT like ZFJAUD_BILL-AUGRU_AUFT, "Order reason

END OF T_BILL.

select-options : s_vtweg for ZFJAUD_BILL-vtweg obligatory,

s_vkbur for ZFJAUD_BILL-vkbur,

s_kunag for ZFJAUD_BILL-kunag,

s_matnr for ZFJAUD_BILL-matnr,

s_prodh for ZFJAUD_BILL-prodh,

s_erdat for ZFJAUD_BILL-erdat obligatory,

s_werks for ZFJAUD_BILL-werks,

s_lgort for ZFJAUD_BILL-lgort.

selection-screen begin of block blk1 with frame title text-002.

parameters : p_file like rlgrap-filename

default 'C:\yvfjaud_billdet.xls'.

SELECTION-SCREEN SKIP 1.

PARAMETERS : p_flag AS CHECKBOX DEFAULT ' '.

selection-screen end of block blk1.

START-OF-SELECTION.

perform collect_data.

perform display_data.

if p_flag = 'X'.

perform download_to_localpc.

endif.

TOP-OF-PAGE.

perform set_page_header.

&----


*& Form collect_data

&----


  • text

----


FORM collect_data .

SELECT VBELN POSNR CHARG FKART KUNAG MATNR FKDAT

FKIMG NETWR WAERK NETPR VERPR BNAME AUGRU_AUFT BNAME

FROM ZFJAUD_BILL

INTO CORRESPONDING FIELDS OF TABLE T_BILL

WHERE

vtweg IN s_vtweg AND

vkbur IN s_vkbur AND

kunag IN s_kunag AND

matnr IN s_matnr AND

prodh IN s_prodh AND

erdat IN s_erdat AND

werks IN s_werks AND

lgort IN s_lgort.

ENDFORM. "collect_data

----


FORM download_to_localpc .

call function 'WS_DOWNLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

TABLES

data_tab = t_bill.

if sy-subrc <> 0.

message E000 with 'Download not successful'.

endif.

ENDFORM. " download_to_localpc

----


FORM display_data .

sort t_bill by vbeln.

loop at t_bill.

if t_bill-AUGRU_AUFT = '100' OR

t_bill-AUGRU_AUFT = '101' OR

t_bill-AUGRU_AUFT = '102'.

t_bill-FKIMG = '0.00'.

endif.

write :/1 t_bill-VBELN ,

15 t_bill-POSNR,

25 t_bill-CHARG,

40 t_bill-FKDAT,

55 t_bill-FKART,

70 t_bill-KUNAG,

85 t_bill-matnr,

100 t_bill-FKIMG,

115 t_bill-NETWR,

140 t_bill-WAERK,

145 t_bill-VERPR,

165 t_bill-BNAME.

endloop.

data: line line like t_bill occurs 0 with header line.

loop at t_bill into line.

write:/ line-FKIMG,line-netwr.

AT END OF FKIMG.

SUM.

ULINE.

WRITE: / line-FKIMG, line-netwr.

SKIP.

ENDAT.

AT LAST.

SUM.

ULINE.

WRITE: / line-FKIMG, line-netwr.

ENDAT.

endloop.

ENDFORM. " display_data

----


FORM set_page_header .

call function 'Z_REPORT_TITLE'

EXPORTING

line_size = sy-linsz

sy_title = 'Billing Details with Cost'

uline = 'X'

first_page_only = ' '.

write :1(15) 'Billing Doc' color col_heading,

15(15) 'Item' color col_heading,

25(15) 'Batch' color col_heading,

40(15) 'Posting Date' color col_heading,

55(15) 'Billing Type' color col_heading,

70(15) 'Sold-to-party' color col_heading,

85(30) 'Material' color col_heading,

110(15) 'Qty' color col_heading,

125(15) 'Amount' color col_heading,

140(15) 'Currency' color col_heading,

155(15) 'TP' color col_heading,

165(15) 'End Customer' color col_heading.

ENDFORM. " set_page_header

0 Kudos

Hi,

Did you tried my suggestions?

Kindly reward points if it is helpful.

0 Kudos

If from your program you want to have most recent programs then just use table TRDIR .In that giv unam as sy-UNAM and date as desired by you.U can take these paramters from selection screen.

But if want to see the programs manually , the crude way is just go to se38 leave progam name as empty and press f4..it will show latest objects sorted alphabatically..

0 Kudos

hi jayanti,

rewared points for TRDIR...

could u pls check my code at At & endat statements....

kaki

0 Kudos

sorry kaki..

just remove the end at sub total..

i.e ..use this one:

loop at t_bill into line.

write:/ line-FKIMG,line-netwr.

AT LAST.

SUM.

ULINE.

WRITE: / line-FKIMG, line-netwr.

ENDAT.

0 Kudos

Hi,

v_fkimg = 0.

v_netwr = 0.

loop at t_bill into line.

write:/ line-FKIMG,line-netwr.

v_fkimg = line-fkimg + v_fkimg.

v_netwr = line-netwr + v_netwr.

ENDloop.

write:/ v_FKIMG,v_netwr.

Try like this.Kindly reward points if it helps.

0 Kudos

Hi Asit,

I want to write 'Grand Total' at the side of the totals.

Could u pls tell me how to do??

Kaki

0 Kudos

Just do this.

loop at t_bill into line.

write:/ line-FKIMG,line-netwr.

AT LAST.

SUM.

ULINE.

WRITE: / line-FKIMG, line-netwr , 'GRAND TOTAL'.

ENDAT.

ENDLOOP

0 Kudos

Hello Asit

Beside means i want 'Grand total' before the figure...

Not after.....sorry iam not able to get this one...

something like this

Amount

5000

5000

-


GRAND TOTAL 10000

-


0 Kudos

Hi Kaki..

Kindly try this one

loop at t_bill into line.

write:/ line-FKIMG,line-netwr.

AT LAST.

SUM.

ULINE.

WRITE: / 'Grand Total ' , 12 line-FKIMG, line-netwr .

ENDAT.

ENDLOOP

If this solves ur problem then kindly reward and close this thread .

0 Kudos

Hi Asit..

I did not understand where is the problem...

Iam not able to get Grand total...

this is the code...

loop at t_bill into line.

write:1(115) line-FKIMG,line-netwr.

AT LAST.

SUM.

ULINE.

WRITE:/'Grand total',1(115) line-FKIMG, line-netwr.

ULINE.

ENDAT.

endloop.

0 Kudos

Hi Kaki try this..

loop at t_bill into line.

write:/115 line-FKIMG,line-netwr.

AT LAST.

SUM.

ULINE.

WRITE:/100 'Grand total',115 line-FKIMG, line-netwr.

ULINE.

ENDAT.

endloop.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Loop at itab into wa.

v_qty = v_qty + wa-qty.

v_amt = v_amt + wa-amt.

write : wa-qty, wa-amt.

endloop.

write : v_qty , v_amt.

Kindly reward points if it helps.