I wonder if anyone can spot anything wrong with the following select statement or at least give me a clue on how I might work out why its not working!!
Code: Select all
SELECT vakpa~vbeln vakpa~auart vbap~matnr vbap~zmeng FROM vakpa INNER JOIN vbap ON vakpa~vbeln = vbap~vbeln INNER JOIN vbkd ON vbkd~vbeln = vakpa~vbeln AND vbkd~posnr = '000000' INTO TABLE lt_history FOR ALL ENTRIES IN lt_t066 WHERE vakpa~kunde = i_parent_employer AND vakpa~parvw = 'AG' AND ( vakpa~auart = lt_t066-lookup_doc_type OR vakpa~auart = 'ZDR' ) AND vakpa~vbeln <> i_current_doc AND vbap~matnr = lt_t066-lookup_para AND vbap~abgru IN lt_abgru AND vbkd~prsdt = l_grant_yr.
It should return three rows of data; one from one sales order and two items from another. However, it is only returning two rows, one from each sales order. The sales order with two items to be returned has four items on it in total but only two should be selected. Each of these items have pretty much the same data as far as this select is concerned i.e. same material code and rejection reason (different billing dates but I don't see how that's relevant). I can see nothing wrong when debugging it i.e. all the variables appear to be populated correctly. I've run the SQL trace and that also looks ok and is indicating three records are being returned but within the program only two are showing. I've also tried replicating the above in an SQL utility we have and that also returns the rows correctly.
The fact that the trace is indicating three rows are being returned makes me think the SQL and variables are ok but I don't see how a row can then disappear between being returned from the database and appearing within the program.
I'm sure its something simple/obvious but I can't figure it out! I'd be glad to hear any ideas or suggestions...