‎2007 May 31 7:05 AM
‎2007 May 31 7:14 AM
Hi rajesh
we can use loop in select statement
as follows
LOOP AT ITAB.
SELECT * FROM ZPAVAN_EMP INTO CORRESPONDING FIELDS OF ITAB.
APPEND ITAB.
ENDSELECT.
WRITE : / ITAB-EMPNO, ITAB-EMPNAME,ITAB-DEPTNO.
ENDLOOP.but it was not advisable it may lead to problem in SAP system so u plz follow this
SELECT * FROM ZPAVAN_EMP INTO CORRESPONDING FIELDS OF ITAB.
APPEND ITAB.
ENDSELECT.
LOOP AT ITAB.
WRITE : / ITAB-EMPNO, ITAB-EMPNAME,ITAB-DEPTNO.
ENDLOOP.Rewards if helpfull
Regards
Pavan
‎2007 May 31 7:06 AM
technically, yes you can.
It may not be always gud from performance perspective.
You can fetch all the data into internal table at once.
Or you can use FOR ALL ENTRIES.
‎2007 May 31 7:06 AM
‎2007 May 31 7:06 AM
Hi,
Yes, but its never adviced...
As it reduces the performance
Regards,
pritha
‎2007 May 31 7:07 AM
Hi,
You can do but its not advisable. As an alternative you can use read statement inside the loop.
Regards,
Ram
‎2007 May 31 7:07 AM
‎2007 May 31 7:07 AM
yes you can use but it may affect your performance . better to use for all entries statement with different itab.
reagrds
shiba dutta
‎2007 May 31 7:07 AM
‎2007 May 31 7:10 AM
‎2007 May 31 7:12 AM
hi,
u can loop at read statement.
here is an example,
LOOP AT IT_VBAP INTO WA_VBAP.
READ TABLE IT_VBAK INTO WA_VBAK WITH KEY VBELN = WA_VBAP-VBELN BINARY SEARCH.
IF SY-SUBRC = 0.
*MOVE DATA INTO IT_FINAL.
MOVE: WA_VBAK-VBELN TO WA_FINAL-VBELN,
WA_VBAK-AUGRU TO WA_FINAL-AUGRU,
WA_VBAP-POSNR TO WA_FINAL-POSNR,
WA_VBAP-MATNR TO WA_FINAL-MATNR,
WA_VBAP-ZMENG TO WA_FINAL-ZMENG.
ENDIF.
endloop.
Regards,
pritha
Message was edited by:
Pritha Agrawal
‎2007 May 31 7:14 AM
Hi rajesh
we can use loop in select statement
as follows
LOOP AT ITAB.
SELECT * FROM ZPAVAN_EMP INTO CORRESPONDING FIELDS OF ITAB.
APPEND ITAB.
ENDSELECT.
WRITE : / ITAB-EMPNO, ITAB-EMPNAME,ITAB-DEPTNO.
ENDLOOP.but it was not advisable it may lead to problem in SAP system so u plz follow this
SELECT * FROM ZPAVAN_EMP INTO CORRESPONDING FIELDS OF ITAB.
APPEND ITAB.
ENDSELECT.
LOOP AT ITAB.
WRITE : / ITAB-EMPNO, ITAB-EMPNAME,ITAB-DEPTNO.
ENDLOOP.Rewards if helpfull
Regards
Pavan
‎2007 May 31 7:15 AM
hi,
We should try to avoid writing select statements inside the loop.It decreases the performance of the program as it hits the database as many times you are looping.You can select the data from database table outside the loop and read those tables indide the loop.
instead of this use FORALL ENTRIES.
SELECT * FROM BSAK INTO TABLE T_IBSAK
FOR ALL ENTRIES IN T_IAUG
WHERE BUKRS = T_IAUG-BUKRS
AND AUGDT = T_IAUG-AUGDT
AND AUGBL = T_IAUG-AUGBL
regards
null
‎2007 May 31 7:19 AM
yeah u can but it effects the performance .
so it is better to go for other options