‎2010 May 11 12:06 PM
HI
i use this part of code:
loop at i_mapping into wa.
if wa-xblnr ne m_xblnr and wa-mwskz ne m_mwskz.
clear : wa1.
move m_xblnr to wa1-xblnr.
move m_mwskz to wa1-mwskz.
move m_net to wa1-znet.
append wa1 to i_new.
clear m_net.
endif.
append wa to i_new.
add wa-znet to m_net.
move wa-xblnr to m_xblnr.
move wa-mwskz to m_mwskz.
endloop.
clear : wa1.
move m_xblnr to wa1-xblnr.
move m_mwskz to wa1-mwskz.
move m_net to wa1-znet.
append wa1 to i_new.this appends the i_mapping to i_new and appends some new lines with the summation of znet by xblnr.
i want not to sum only by xblnr but with xblnr mwskz.
to be more clear if the xblnr and mwszk in first line for example is equal with the third ( let's say that is the last line ) then i want to append a new line (forth line) with the summation of znet of first and third line.
‎2010 May 11 12:15 PM
Try this
the itab1 has the out put
data : BEGIN OF itab OCCURS 0,
field1 type i,
field2 type i,
field3 type i,
end of itab.
DATA itab1 LIKE HASHED TABLE OF itab
WITH UNIQUE KEY field1 field2.
itab-field1 = 11.
itab-field2 = 10.
itab-field3 = 10.
append itab.
itab-field1 = 11.
itab-field2 = 20.
itab-field3 = 20.
append itab.
itab-field1 = 12.
itab-field2 = 10.
itab-field3 = 20.
append itab.
itab-field1 = 12.
itab-field2 = 10.
itab-field3 = 30.
append itab.
loop at itab.
collect itab into itab1.
endloop.
output.
11 10 10
11 20 20
12 10 50
‎2010 May 11 12:22 PM
Hi,
Check the IF condition
sort <first itab> by xblnr mwskz.
if wa-xblnr ne m_xblnr or wa-mwskz ne m_mwskzThis will insert the summary record for each change of xblnr or mwskz. If you want only summary records use the collect statement.
Regards
Vinod
‎2010 May 11 12:23 PM
Hi,
Before loop at i_mapping into wa.
sort i_mapping by XBLNR MWSKZ.
Regards
Dillip Sahoo
‎2010 May 11 12:28 PM
i have tried everything but it works only for xblnr . what about the combination of xblnr and mwskz.
‎2010 May 11 12:29 PM
‎2010 May 11 12:33 PM
yes. it is better but appends a line without doing summation.
if in first itab there is no line to sum ( unique xblnr mwskz) then i dont want to add an extra line.
Edited by: antonis nezos on May 11, 2010 2:37 PM
‎2010 May 11 12:40 PM
Hi, add a counter variable to check the same
data : m_cnt(5) type n value 0. "added"
loop at i_mapping into wa.
if wa-xblnr ne m_xblnr and wa-mwskz ne m_mwskz.
if m_cnt gt 1. " added"
clear : wa1.
move m_xblnr to wa1-xblnr.
move m_mwskz to wa1-mwskz.
move m_net to wa1-znet.
append wa1 to i_new.
clear m_net, m_cnt . "added"
endif. "added"
endif.
append wa to i_new.
add wa-znet to m_net.
add 1 to m_cnt. "added"
move wa-xblnr to m_xblnr.
move wa-mwskz to m_mwskz.
endloop.
if m_cnt gt 1. "added"
clear : wa1.
move m_xblnr to wa1-xblnr.
move m_mwskz to wa1-mwskz.
move m_net to wa1-znet.
append wa1 to i_new.
endif. "added"
Regards
Vinod
Edited by: Vinod Kumar on May 11, 2010 5:12 PM
Edited by: Vinod Kumar on May 11, 2010 5:14 PM
‎2010 May 11 12:52 PM
THANK YOU!!!
Edited by: antonis nezos on May 11, 2010 3:24 PM
‎2010 May 11 1:25 PM
i noticed that sums and the lines with different mwskz.
the number of lines is correct but not the summation.
Edited by: antonis nezos on May 11, 2010 3:25 PM
‎2010 May 11 1:31 PM
i noticed that sums and the lines with different mwskz.
the number of lines is correct but not the summation.
any ideas?
‎2010 May 12 5:39 AM
‎2010 May 11 12:50 PM
‎2010 May 11 1:07 PM
hi,
change data of wa1-mwskz to character
then loop internal table
collect into another other internal table of same type
endloop.
and you will get your desired result .
Regards
Deepak.