‎2007 Jun 25 10:12 PM
I have a internal table which contains material numbers. I need additional internal to hold material number and material description.
So is this a correct statement
loop at t_out.
select mtart from mara
into t_mara
where matnr = t_out-matnr.
endloop.
‎2007 Jun 25 10:13 PM
Hi Kartik,
Please Use Select Single Instead of Select Query
loop at t_out.
select single mtart from mara
into t_mara
where matnr = t_out-matnr.
endloop.This will work more faster
‎2007 Jun 25 10:20 PM
‎2007 Jun 25 10:16 PM
You better do it like this...
DATA: W_TABIX TYPE SY-TABIX.
FIELD-SYMBOLS: <OUT> LIKE LINE OF T_OUT.
IF NOT T_OUT[] IS INITIAL.
SELECT MTART
INTO T_MTART
FROM MARA
FOR ALL ENTRIES IN T_OUT
WHERE MATNR EQ T_OUT-MATNR.
LOOP AT T_OUT ASSIGNING <OUT>.
W_TABIX = SY-TABIX.
READ TABLE T_MTART WITH KEY MATNR = <OUT>-MATNR.
IF SY-SUBRC EQ 0.
MOVE T_MTART-MTART TO <OUT>-MTART.
MODIFY T_OUT FROM <OUT> INDEX W_TABIX.
ENDIF.
ENDLOOP.
ENDIF.
Greetings,
Blag.
‎2007 Jun 25 10:19 PM
If you use select in loop, it may leads to performance issues, so it will be better if you use 'For all entries' .
Regards,
Dj
reward for all useful answers.
‎2007 Jun 25 10:31 PM
better make your initial query with material desc also ie mtart. into ITAB1
select matnr mtart from mara into table ITAB1.
*copy Itab1 into itab2
itab2 = itab1.
I think performance wise this is good.
thanks
vinsee