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 from KONV using Additional Code in ABAP Query

Former Member
0 Likes
2,626

I'm attempting to modify an ABAP Query Infoset (using transaction SQ02) that already has a join in it between tables VBAP and VBAK, and two additional alias tables on KONV (to get price history for sales documents). I wish to get history of all PN00 records from KONV. I can get ONE record with the following code in the Record Processing of the Extras element in my Infoset:

SELECT SINGLE KBETR KPEIN KMEIN KDATU

INTO (PN00_PRICE, PN00_PER, PN00_UOM, PN00_DATE) FROM KONV

WHERE KNUMV = VBAK-KNUMV

AND KPOSN = VBAP-POSNR

AND STUNR = 198

AND ZAEHK = 01.

But we have many counters (field ZAEHK) for the PN00 condition and I want to have a new row for each PN00 record in KONV. I've tried some loop syntax, but I've not been able to get any code to function or return more than one row for each sales order item row (VBAP-POSNR).

Thanks for any hints.

Dan Gallagher

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,795

Select single will only return one row. You can take out the single and either add an 'endselect' or 'into table...'

Rob

10 REPLIES 10
Read only

Former Member
0 Likes
1,796

Select single will only return one row. You can take out the single and either add an 'endselect' or 'into table...'

Rob

Read only

Former Member
0 Likes
1,795

Join VBAK, VBAK and KONV and do not use SELECT single. Select all records for that Condition Header and Item no.

Condition Header No can be populated from VBAK and item no = VBAP-POSNR. Do not use SELECT SINGLE.

Read only

Former Member
0 Likes
1,795

Change it like this


SELECT KBETR KPEIN KMEIN KDATU
  INTO (PN00_PRICE, PN00_PER, PN00_UOM, PN00_DATE) 
  FROM KONV
 WHERE KNUMV = VBAK-KNUMV
   AND KPOSN = VBAP-POSNR
   AND STUNR = 198.

..... do something with this record and store

ENDSELECT.

Read only

0 Likes
1,795

OK ... this is a start. In ABAP Query Infosets, there's a bunch of code already created for me, and the code below, without the (maybe even with the) ".... do something with this record and store ... " comment from you returns just the first record in KONV that satisfies my WHERE clause. Don't I need to do a loop to get them all (field ZAEHK starts at 01 and goes up to 99)?

Read only

0 Likes
1,795

As far as you join these 3 tables - VBAK, VBAP & KONV, it should pick up all the records which satisfy the criteria.

Read only

0 Likes
1,795

VBAK and VBAP are joined, KONV cannot be joined because it is a cluster table - that's the problem.

So, in the InfoSet I have two alias tables, but alias tables require all key fields to be defined explicitly. So I've tried the extra code, and this is where I've tried this selection.

Read only

0 Likes
1,795

Is it possible to make use of KONH (Conditions Header) and KONP (Conditions Items) table instead of KONV?

Read only

0 Likes
1,795

Since ZAEHK is no longer in the where clause, it should return all of the records.

rob

Read only

0 Likes
1,795

KONH and KONP don't carry the PN00 conditions I need, I don't know why.

Read only

Former Member
0 Likes
1,795

You will have to do this in one of the coding blocks. In SQ02, enter the infoset name and go in change mode. In there you will see the little icon in the application toolbar that is in blue colour with white dots. Click on that, it will bring up the tab 'Code'. Select the appropriate coding section and insert the code there. That same can be accessed from the menu, 'Goto>Code>'

Srinivas