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

select and count

Former Member
0 Likes
3,789

Hello everyone,

I need codding to process VBAK table and get information for KNUMVs wchich appears more than 1.
KNUMV is not key field here and im processing data to KONV where KNUMV is a key field, and I need check it before processing to not get any errors about duplicates.

Anyone can help?

5 REPLIES 5
Read only

GK817
Active Contributor
3,104

Hi Beata,

Distinct Column:

SELECT COUNT( DISTINCT carrid )  FROM spfli  WHERE cityto = 'NEW YORK'  INTO @DATA(count).

Distinct Row:

SELECT DISTINCT cityto
FROM spfli
WHERE carrid = 'LH' AND
cityfrom = 'FRANKFURT'
INTO TABLE @DATA(destinations).

Gaurav

Read only

VeselinaPeykova
Active Contributor
3,104

Would you please share an example where you have more than one entry in VBAK for a specific VBAK-KNUMV?

Read only

former_member1716
Active Contributor
0 Likes
3,104

plmalekbe,

I don't think that is necessary because every sales order in VBAK table will have unique Condition record numbers.

If you still need to check you can use below code, after the delete statement if you still have any entries left in table GT_VBAK then those are the KNUMV entries which are assigned to multiple VBELN values.

SELECT knumv,
       COUNT( vbeln ) AS count
FROM vbak
INTO TABLE @DATA(gt_vbak)
GROUP BY knumv.
IF sy-subrc EQ 0.
  DELETE gt_vbak WHERE count EQ 1.
ENDIF.

Regards!

Read only

DoanManhQuynh
Active Contributor
0 Likes
3,104

so why don't inner join those table?

Read only

Former Member
0 Likes
3,104

Hi,

Thank you all for help, Satish your codding its very nice,

I will use it for sure. You may be right with VABK because I was checking it for many tables and this is true that VABAK was fine, but for example in VFKONV i found duplicates in KNUMV and I had to change approchach. Thanks again!

Example from se16h:

przechwytywanie.png