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 replace Internal table data.

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

Hi,

Could not understand the question,

what do you need exactly?

0 Kudos

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

0 Kudos

hi,

you can use AT NEW Event..

Regards,

Venkat

0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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!!!

raymond_giuseppi
Active Contributor
0 Kudos

Did you perform some search at scn with keywords like dynamic internal table ?

Regards,

Raymond

Former Member
0 Kudos

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