‎2007 Feb 20 12:30 PM
Hi all
Here is a query.pls help me
in the o/p i need to get 5 fields for ekpo-menge ( i mean 5 different columns in the output are required ) ie. quantity of po in jan in a different column, like wise for feb, mar...may. similarly i need to get the netpr and peinh 5 times each for corresponding months. in this case how to define the internal table and how to write the select query? pls tell me.
do i need to do like te folowing?
data: begin of itab occurs 0,
menge1 type ekpo-menge,
menge2 type ekpo-menge,
menge3 type ekpo-menge,
menge4 type ekpo-menge,
menge5 type ekpo-menge,
netpr1 type ekpo-netpr,
netpr2 type ekpo-netpr,
netpr3 type ekpo-netpr,
netpr4 type ekpo-netpr,
netpr5 type ekpo-netpr,
end of itab.
then how to write the select query for this?
pls tell me
thanks in advance
‎2007 Feb 20 12:33 PM
I will suggest you to write a single select query specifying the required condition in where clause and get the data into one internal table. From this internal table append the data in columns of your final internal table that u have defined.
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
‎2007 Feb 20 1:05 PM
hi
thanks for the solution. do i need to declare the mnege feld 5 times/
this is wht i wanted to know
thanks
‎2007 Feb 20 1:08 PM
If you need the fields as columns then u can declare it 5 times.
‎2007 Feb 20 12:38 PM
Hi,
First define an internal table with menge and netpr alone.
then
Select menge netpr
from ekpo
into table i_ekpo
where ....Then u loop at the table based on month and date move it to the final table of the structure defined by u.
Then append the values to the itab.
Hope this helps.
‎2007 Feb 20 1:06 PM
hi
thanks for the answer
i am not clear abt it
do u mean to say that there is no need to declare mnege 5 times or netpr 5 times?
in loop how can i do it?
pls can u send me sample code
thanks a lot
‎2007 Feb 20 1:19 PM
Hi,
DATA: begin of i_ekpo,
menge........
netpr............
date ..........
end of i_ekpo.
Select menge netpr date
from ekpo
into table i_ekpo
where ....
if sy-subrc = 0.
LOOP AT i_ekpo.
v_month = i_ekpo-date+4(2).
CASE v_month.
WHEN '01'
itab-menge1 = i_ekpo-menge.
..................
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
WHEN '02'.
itab-menge1 = i_ekpo-menge.
..................
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
WHEN '03'.
itab-menge1 = i_ekpo-menge.
..................
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
...
WHEN '12'.
itab-menge1 = i_ekpo-menge.
..................
itab-menge5 = i_ekpo-menge.
itab-netpr1 = i_ekpo-netpr.
itab-netpr5 = i_ekpo-netpr.
ENDCASE.
APPEND itab.
ENDLOOP.
Please be more specific with some sample outputs how is should be.