2007 Jun 11 11:58 AM
hi all
My requirement is
if more than one kondm 'material pricing group' has been found then select the kondm which is appearing
the most for this material in this table
example
matnr mat pricing grp
101 c7
102 c7
103 c1
104 c2
105 c7
then the value for 101,102,105 shud be displayed this is an just an rough example i don know the records
and the code wich i wrote is
SELECT matnr
kondm
into table it_mvke
from mvke
where matnr in p_matnr
loop at it_mvke
WRITE: / it_mvke-matnr UNDER 'material no',it_mvke-kondm UNDER 'material gp'.
endloop.
top-OF-PAGE.
WRITE: /'material no','material gp'.
this code is displaying all the records but my requirement is
if more than one kondm 'material pricing group' has been found then select the kondm which is appearing
the most for this material in this table
hi all
My requirement is
if more than one kondm 'material pricing group' has been found then select the kondm which is appearing
the most for this material in this table
example
matnr mat pricing grp
101 c7
102 c7
103 c1
104 c2
105 c7
then the value for 101,102,105 shud be displayed this is an just an rough example i don know the records
and the code wich i wrote is
SELECT matnr
kondm
into table it_mvke
from mvke
where matnr in p_matnr
loop at it_mvke
WRITE: / it_mvke-matnr UNDER 'material no',it_mvke-kondm UNDER 'material gp'.
endloop.
top-OF-PAGE.
WRITE: /'material no','material gp'.
this code is displaying all the records but my requirement is
if more than one kondm 'material pricing group' has been found then select the kondm which is appearing
the most for this material in this table
2007 Jun 11 12:03 PM
Hi,
After selecting the data u sort the internal table.
Sort it_mvke by kondm.
Then u write.
reward if helpful
regards
arun
2007 Jun 11 12:07 PM
hi arun,
i done the sort also but the i need select kondm which is appearing the most for this material can u tell me the code 4 this condition
2007 Jun 11 12:11 PM
Hi
In the internal table take 2 fields KONDM and MATNR
sort itab by KONDM.
in the Loop keep a counter like thing.
Check for the occurances of same KONDM field.
if it is more than 1 then the counter will be 2.
so for each KONDM count the records.
and put all the data into another int table with 3 fields
counter,kondm,matnr.
sort this new itab1 with counter decending.
take the first record
then display the MATNR and KONDM.
<b>
Reward points for useful Answers</b>
Regards
Anji
2007 Jun 11 12:27 PM
hi anji,
is this going to work
declare a variable var1.
g_tabix = sy-tabix + 1
sort kondm
loop at internal table( where the values are taken)
var1 = kondm
if sy-tabix = 2
read internal table index g_tabix.
endif.
2007 Jun 11 12:19 PM
Hi Anji,
If the counter is same for two KONDM, then what to do.
regards
arun
2007 Jun 11 12:24 PM
Hi,
try like this...
sort it_mvke by kondm.
loop at it_mvke into wa1_mvke.
v_index = sy-tabix + 1.
read table it_mvke into wa2_mvke index v_index.
if wa2_mvke-kondm = wa1_mvke-kondm.
move : wa2_mvke - matnr to wa3_mvke-matnr,
wa2_mvke-kondm to wa3_mvke-kondm.
append wa3_mvke-kondm to it1_mvke.
endif.
clear : wa3_mvke-kondm,
wa2_mvke-kondm,
wa1_mvke-kondm,
v_index.
endloop.
Regards,
nagaraj
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |