06-06-2012 4:58 AM
Hi,
My Problem is Ztable have 10 Columns kunnr,year,mic_qty,mic_val ,digital_qty,digital_val,thread_qty,thread_val.
I Upload data into ztable customer wise and year wise .My problem is when i fetch data into ztable all customer are come to internal table.
But i want Year wise data into one customer column in the output.
Ex: I upload data into internal table like : x7931(cust code) 2008(year) mic_qty(111) mic_val(1200) digital_qty(10) digital val(2100)......
x7931 2010 0 0 21 1254 ....
Output like x7931 2008(mic_qty) 2008(mic_val) 2010(mic_qty) 2010(mic_val).......................
111 1200 0 0
Thanks & Regards,
Balakrishna Gajula.
06-06-2012 9:30 AM
Hi,
As your below code
Select kunnr year mic_qty mic_val dig_qty dig_val bow_qty bow_val
into table itab
from ztable
where zyear in s_year.
sort itab by kunnr.
I display output customer wise. but in the output one customer comes repeat.
I want output like one customer years wise data in one column.
ex: x7901 2008mic_qty 2009mic_qty 2010mic_qty 2011mic_qty 2012mic_qty
After sorting the tab by kunnr.
Declare the one more internal table(itab1) which is like itab.
copy the records of itab to itab1.
itab1[] = itab[].
delete the adjacent duplicates of itab comparing kunnr.
now loop at itab.
loop at itab1 where kunnr eq itab-kunnr.
do the calculation of quantities year wise here.
endloop.
write:/1 kunnr,mic1,mic2,
endloop.
Hope this will help.
Thanks&Regards,
Shankar Darbha
06-06-2012 5:49 AM
06-06-2012 7:06 AM
hi,
One customer comes with different years.like x7901 comes 2008, 2009,2010,2011,2012.
He purchase different products in the above years.
I'm upload records Customer and Year wise Details into ztable.
I wrote one select query like
Select kunnr year mic_qty mic_val dig_qty dig_val bow_qty bow_val
into table itab
from ztable
where zyear in s_year.
sort itab by kunnr.
I display output customer wise. but in the output one customer comes repeat.
I want output like one customer years wise data in one column.
ex: x7901 2008mic_qty 2009mic_qty 2010mic_qty 2011mic_qty 2012mic_qty
Thanks & Regards
Balakrishna Gajula
06-06-2012 7:26 AM
06-06-2012 7:50 AM
Hi,
sort itab by name year.
loop at itab to wa(say itab internal table).
if lv_var <> wa-year or sy-tabix <> 1.
append wa to lit1(required internal table type)
lv_var = wa-year.
AT END OF name
append lines of lit1 to lit2.
endloop.
loop at lit2 to wa2.
*display
endloop.
Revert back for any help.
Thank and regards
06-06-2012 10:09 AM
Hi,
In this case you need to use Dynamic Internal Table.
Make a dynamic itab1 with columns 'Cust' 'yr1' yr2' .....'yrn'.
maintain customers in itab2.
now, you need to populate data 1 by 1 column-wise in itab1 for each row and the repeat for all the rows.
first value will be customer and then the values yearwise.
06-06-2012 7:42 AM
Hi,
you can use AT New or AT End events.
syntax will be :
ex:
Loop at itab into wa.
AT New Kunnr.
Your logic.
endat.
endloop.
The event will be trigger only when a new Kunnr comes, all the x7901 in your example will be assigned once. But please do take care that Kunnr is the first field, also you need to handle other field assignments other than kunnr out of this events else they will be displayed as *.
Hope this will be helpful!!!
06-06-2012 8:22 AM
06-06-2012 9:30 AM
Hi,
As your below code
Select kunnr year mic_qty mic_val dig_qty dig_val bow_qty bow_val
into table itab
from ztable
where zyear in s_year.
sort itab by kunnr.
I display output customer wise. but in the output one customer comes repeat.
I want output like one customer years wise data in one column.
ex: x7901 2008mic_qty 2009mic_qty 2010mic_qty 2011mic_qty 2012mic_qty
After sorting the tab by kunnr.
Declare the one more internal table(itab1) which is like itab.
copy the records of itab to itab1.
itab1[] = itab[].
delete the adjacent duplicates of itab comparing kunnr.
now loop at itab.
loop at itab1 where kunnr eq itab-kunnr.
do the calculation of quantities year wise here.
endloop.
write:/1 kunnr,mic1,mic2,
endloop.
Hope this will help.
Thanks&Regards,
Shankar Darbha