12-18-2013 8:04 AM
Hi experts;
I want to get data form mara,mbew,mard tables. But i am getting one more rows for material no. How can i get just one row for every material no.
My query and internal table
DATA : BEGIN OF gv_itab OCCURS 0,
matnr LIKE mara-matnr,"Malzeme Numarası
bwkey LIKE mbew-bwkey,"Değerleme birimi
bwtar LIKE mbew-bwtar,"Değerleme türü
werks LIKE mard-werks,"Üretim yeri
lgort LIKE mard-lgort,"Depo yeri
maktx LIKE makt-maktx,"Malzeme kısa metni
END OF gv_itab.
SELECT m~matnr mw~bwkey mw~bwtar md~werks mt~maktx mt~spras
INTO CORRESPONDING FIELDS OF TABLE gv_itab
FROM mara AS m
JOIN mbew AS mw
ON m~matnr = mw~matnr
JOIN mard AS md
ON m~matnr = md~matnr
JOIN makt AS mt
ON m~matnr = mt~matnr
WHERE m~matnr IN s_matnr AND
mw~bwkey IN s_bwkey AND
mw~bwtar IN s_bwtar AND
md~werks IN s_werks AND
md~lgort IN s_lgort AND
mt~spras EQ 'TR' .
Thanks for your help.
12-18-2013 8:18 AM
You can sort gv_itab by matnr and delete adjacent duplicates. Please note that each line in your screenshot has UY column different value..do you want to delete them
Nabheet
12-18-2013 8:11 AM
Use select distinct matnr.
SELECT DISTINCT t2~field
FROM table1 AS t1
INNER JOIN table2 AS t2
ON t1~id = t2~id
INTO TABLE lt
WHERE (lv_where).
12-18-2013 8:21 AM
12-18-2013 8:12 AM
Hi,
Don't understand the requirement, can you elaborate more! what exactly you want to display in the output!
12-18-2013 8:15 AM
You can write select distinct, but that is now obsolete from performance point of view.
Why don't you select all as updated above and the delete adjacent duplicates comparing MATNR.
Regards
Ansumesh
12-18-2013 8:23 AM
My educator want to different way. He said me dont use distinct or adjent duplicates.
12-18-2013 8:30 AM
What is the purpose of this exercise?
How can you ask for a way without knowing the target?
Isn't it just stupid to pick randomly a plant out of many?
What meaning will the report have in that case?
12-18-2013 8:18 AM
You can sort gv_itab by matnr and delete adjacent duplicates. Please note that each line in your screenshot has UY column different value..do you want to delete them
Nabheet
12-18-2013 8:37 AM
LOOP AT gv_itab.
DELETE ADJACENT DUPLICATES FROM gv_itab COMPARING werks.
MODIFY gv_itab.
ENDLOOP.
I used but i have same problem
12-18-2013 8:49 AM
Hi Omer
As Jurgen correctly pointed out what is the purpose of which you are doing..? It will be good if you can provide the detail for the same..
BTW above code should look like below no loop..
sort gv_itab by matnr.
DELETE ADJACENT DUPLICATES FROM gv_itab COMPARING MATNR.
Nabheet
12-18-2013 9:00 AM
I am trying to learn. They are saying it is your exercise then i am starting to do it. Jürgen is right absolutely but it is not solve my problem.
Thanks for your help.
12-18-2013 8:29 AM
Yes as mentioned above, from the performance point, it is not very efficient to use select distinct.
Rather, it would be better to filter the output internal table of the select statement.
loop at itab into wa_itab.
at new matnr.
continue.
endat.
delete itab from wa_itab .
endloop.
(Just make sure that matnr is the first field of your internal table. )
12-18-2013 11:13 AM
12-19-2013 5:25 AM
12-18-2013 8:57 AM
if u need sum of the quantities just collect after the query
LOOP AT gv_itab.
collect gv_itab into gv_itab1.
ENDLOOP.