‎2008 Jun 12 3:07 PM
Hi ,
I had a problem with a select query.
I have taken 4 internal tables.
1)it_kna1
2)it_item1
3)it_item2
4) it_item3.
I am filling the it_kna1 with the following select query.
select kunnr
name1
stras
pstlz
ort01
land1
from kna1 into corresponding fields of table it_kna1 where kunnr
in s_kunnr and brsch in s_brsch.
Next for all customers selected in it_kna1 i am getting the data from the bsad by using following query.
IF it_kna1[] IS NOT INITIAL.
select blart belnr kunnr xblnr zuonr sgtxt budat augdt augbl shkzg from
bsad INTO CORRESPONDING FIELDS OF TABLE it_item1
FOR ALL ENTRIES IN it_kna1
where kunnr = it_kna1-kunnr and
blart = p_blart and
budat in s_budat and
augdt in s_augdt and
shkzg in s_shkzg and
bukrs = p_bukrs.
endif.
But in the it_kna1 i need to fill up some more fields based on the following.So how to fill only those records.I am using the following query to fill up.But it is deleting the existing records in it_item1.
select hkont dmbtr from bseg into corresponding fields of table it_item3
for all entries in it_item1 where belnr = it_item1-belnr and koart in
s_koart and dmbtr > '8000' and bukrs = p_bukrs.
How to solve this problem
‎2008 Jun 12 3:09 PM
‎2008 Jun 12 3:11 PM
hii
use READ statement & MODIFY to solve this.i think it will work here.
use it like given below.here select query will not work for an internal table so you need to use loop at & READ statement
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
wa_output-lgort = wa_mard-lgort.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0<REMOVED BY MODERATOR>
thx
twinkal
Edited by: Alvaro Tejada Galindo on Jun 12, 2008 12:29 PM