‎2008 Mar 10 12:13 PM
Hi all,
Below i m providing my code where we are looping in between two select statements , but i dont want to use loop in between two select statements so can anyone give any other way of approach.
<code>
SELECT a~vbeln
a~erdat
a~erzet
a~auart
b~posnr
b~matnr
b~kwmeng
FROM vbak AS a INNER JOIN vbap AS b
ON amandt = bmandt
AND avbeln = bvbeln
INTO TABLE it_orders.
*append lines of it_orders-vbeln to it_vbeln-vbeln.
*append lines of it_orders to it_vbeln.
LOOP AT it_orders.
CLEAR it_vbeln.
it_vbeln-vbeln = it_orders-vbeln.
APPEND it_vbeln.
ENDLOOP.
IF NOT it_vbeln[] IS INITIAL.
SELECT objky
kschl
FROM nast
INTO TABLE it_nast
FOR ALL ENTRIES IN it_vbeln
WHERE objky = it_vbeln-vbeln.
ENDIF.
</code>
thanks,
satish
‎2008 Mar 10 12:25 PM
Hi,
The loop which you are using is not WITHIN the select statement.
ie ... It is not executing within the select statement.
So it should not cause any kind of performance issues.
What exactly is the problem which you are facing ?
Reward if helpful.
Regards.
‎2008 Mar 10 12:30 PM
Hi,
SELECT a~vbeln
FROM vbak AS a INNER JOIN vbap AS b
ON amandt = bmandt
AND avbeln = bvbeln
INTO TABLE it_vbeln.
try this...
‎2008 Mar 10 12:33 PM
Satish,
There is enough of your code missing that makes this a bit difficult to debug.
Like:
Is this code being performed from somewhere else?
How are the tables defined?
If the tables are defined like this,
DATA:
BEGIN OF vbeln_rec,
vbeln LIKE nast-objky,
END OF vbeln_rec,
it_vbeln LIKE vbeln_rec OCCURS 0 WITH HEADER LINE.
it is possible, that you need to refresh the table like this:
**append lines of it_orders-vbeln to it_vbeln-vbeln.
**append lines of it_orders to it_vbeln.
refresh: it_vbeln.
LOOP AT it_orders.
CLEAR it_vbeln.
it_vbeln-vbeln = it_orders-vbeln.
APPEND it_vbeln.
ENDLOOP.
Edited by: Paul Chapman on Mar 10, 2008 1:35 PM
‎2008 Mar 10 12:44 PM
SELECT a~vbeln
a~erdat
a~erzet
a~auart
b~posnr
b~matnr
b~kwmeng
FROM vbak AS a INNER JOIN vbap AS b
ON a~mandt = b~mandt
AND a~vbeln = b~vbeln
INTO TABLE it_orders.
*append lines of it_orders-vbeln to it_vbeln-vbeln.
*append lines of it_orders to it_vbeln.
*LOOP AT it_orders.
*CLEAR it_vbeln.
*it_vbeln-vbeln = it_orders-vbeln.
*APPEND it_vbeln.
*ENDLOOP.
*
"Your final table is it_nast.
"My doubt is why your filling it_vbeln in between???
"instead of it_vbeln why can't you use it_orders???.
IF NOT it_orders[] IS INITIAL.
SELECT objky
kschl
FROM nast
INTO TABLE it_nast
FOR ALL ENTRIES IN it_odrers
WHERE objky = it_orders-vbeln.
ENDIF.