‎2006 Mar 02 6:35 PM
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
‎2006 Mar 02 6:47 PM
Select single will only return one row. You can take out the single and either add an 'endselect' or 'into table...'
Rob
‎2006 Mar 02 6:47 PM
Select single will only return one row. You can take out the single and either add an 'endselect' or 'into table...'
Rob
‎2006 Mar 02 6:52 PM
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.
‎2006 Mar 02 6:56 PM
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.
‎2006 Mar 02 7:15 PM
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)?
‎2006 Mar 02 7:19 PM
As far as you join these 3 tables - VBAK, VBAP & KONV, it should pick up all the records which satisfy the criteria.
‎2006 Mar 02 7:36 PM
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.
‎2006 Mar 02 7:38 PM
Is it possible to make use of KONH (Conditions Header) and KONP (Conditions Items) table instead of KONV?
‎2006 Mar 02 7:44 PM
Since ZAEHK is no longer in the where clause, it should return all of the records.
rob
‎2006 Mar 02 7:56 PM
KONH and KONP don't carry the PN00 conditions I need, I don't know why.
‎2006 Mar 02 8:19 PM
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