Application Development and Automation 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: 
Read only

help me plz

Former Member
0 Likes
895

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

6 REPLIES 6
Read only

Former Member
0 Likes
856

Hi,

After selecting the data u sort the internal table.

Sort it_mvke by kondm.

Then u write.

reward if helpful

regards

arun

Read only

0 Likes
856

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

Read only

Former Member
0 Likes
856

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

Read only

0 Likes
856

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.

Read only

Former Member
0 Likes
856

Hi Anji,

If the counter is same for two KONDM, then what to do.

regards

arun

Read only

former_member404244
Active Contributor
0 Likes
856

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