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

sum row in internal table

Former Member
0 Likes
659

Hallo,

How can I insert a summation row in a internal Table. I have inserted one but due to the type there are

also other fields in this row. I have cleared them but they have default value 0. And this value appears

in summation row. But I want that only field show value and other should be empty. I write the code perhaps somebody have an idea

SELECT carrid FROM spfli INTO CORRESPONDING FIELDS OF TABLE lt_one.

SELECT * FROM spfli INTO TABLE lt_two.

READ TABLE lt_one INDEX 1 INTO ls_one.

carr_id = ls_one-carrid.

LOOP AT lt_one INTO ls_one.

IF ls_one-carrid = carr_id.

READ TABLE lt_two INTO ls_two INDEX sy-tabix.

ls_summe-distance = ls_summe-distance + ls_two-distance.

APPEND ls_two TO lt_3.

ENDIF.

ENDLOOP.

ls_two-distance = ls_summe-distance.

free: ls_two-carrid,

ls_two-connid,

ls_two-countryfr,

ls_two-cityfrom,

ls_two-airpfrom,

ls_two-countryto,

ls_two-cityto,

ls_two-airpto,

ls_two-FLTIME,

ls_two-DEPTIME,

ls_two-arrtime,

ls_two-fltype,

ls_two-period.

*ls_two-mandt = ''.

*ls_two-fltime = ''.

*ls_two-deptime = ''.

*ls_two-arrtime = 'Summenzeile'.

APPEND ls_two TO lt_3.

regards

rana

Hallo,

How can I insert a summation row in a internal Table. I have inserted one but due to the type there are

also other fields in this row. I have cleared them but they have default value 0. And this value appears

in summation row. But I want that only field show value and other should be empty. I write the code perhaps somebody have an idea

SELECT carrid FROM spfli INTO CORRESPONDING FIELDS OF TABLE lt_one.

SELECT * FROM spfli INTO TABLE lt_two.

READ TABLE lt_one INDEX 1 INTO ls_one.

carr_id = ls_one-carrid.

LOOP AT lt_one INTO ls_one.

IF ls_one-carrid = carr_id.

READ TABLE lt_two INTO ls_two INDEX sy-tabix.

ls_summe-distance = ls_summe-distance + ls_two-distance.

APPEND ls_two TO lt_3.

ENDIF.

ENDLOOP.

ls_two-distance = ls_summe-distance.

free: ls_two-carrid,

ls_two-connid,

ls_two-countryfr,

ls_two-cityfrom,

ls_two-airpfrom,

ls_two-countryto,

ls_two-cityto,

ls_two-airpto,

ls_two-FLTIME,

ls_two-DEPTIME,

ls_two-arrtime,

ls_two-fltype,

ls_two-period.

*ls_two-mandt = ''.

*ls_two-fltime = ''.

*ls_two-deptime = ''.

*ls_two-arrtime = 'Summenzeile'.

APPEND ls_two TO lt_3.

regards

rana

3 REPLIES 3
Read only

former_member242255
Active Contributor
0 Likes
617

Instead of that you can move the SUM into a variable and then write at the end after writing all the records.

Read only

Former Member
0 Likes
617

Hi,

Before displaying the summation move the sum value in to a variable of character data type before this check for the condition NE '0' this should solve your problem.

Regards,

Murthy.

Read only

Former Member
0 Likes
617

Hi,

Move it to a character type field..