02-14-2007 1:22 PM
02-14-2007 1:24 PM
Hi,
Example:
data : it_vbap like vbap occurs 0 with header line.
data : it_vbak like vbap occurs 0 with header line.
select *
from vbak
into it_vbak.
if not it_vbak[] is in initial.
select * from vbap
into it_vbap
for all entries in it_vbak
where vbeln eq it_vbak-vbeln.
endif.
02-14-2007 1:24 PM
Check this.
CLEAR: G_T_VBRK,G_T_VBFA,G_T_VBAK,G_T_VBPA,G_T_KNA1.
REFRESH: G_T_VBRK,G_T_VBFA,G_T_VBAK,G_T_VBPA,G_T_KNA1.
SELECT VBRKBUKRS VBRKFKART VBRKFKDAT VBRKFKSTO VBRK~KUNRG
VBRKSFAKN VBRKVBELN VBRKVKORG VBRKVTWEG KNA1~KUNNR
KNA1LAND1 KNA1NAME1 INTO CORRESPONDING FIELDS OF
TABLE G_T_VBRK
FROM VBRK INNER JOIN KNA1 ON KNA1KUNNR = VBRKKUNRG
WHERE VBRK~BUKRS IN BUKRS
AND VBRK~VKORG IN VKORG
AND VBRK~FKART IN FKART
AND VBRK~FKDAT IN SP$00004
AND VBRK~FKSTO IN SP$00014
AND VBRK~KUNRG IN SP$00005
AND VBRK~SFAKN IN SP$00015
AND VBRK~VBELN IN SP$00006
AND VBRK~VTWEG IN SP$00008
AND KNA1~LAND1 IN SP$00016.
IF NOT G_T_VBRK[] IS INITIAL.
SELECT * FROM VBPA INTO TABLE G_T_VBPA
FOR ALL ENTRIES IN G_T_VBRK
WHERE VBELN = G_T_VBRK-VBELN
AND PARVW = 'ZE'.
IF NOT G_T_VBPA[] IS INITIAL.
SELECT * FROM KNA1 INTO TABLE G_T_KNA1
FOR ALL ENTRIES IN G_T_VBPA
WHERE KUNNR = G_T_VBPA-KUNNR.
ENDIF.
Vasanth
02-14-2007 1:25 PM
Hi,
1. First check that first Int Table(ITAB) is not Initial.
2. Select all the Key fields of the Table from which you are fetching data(DB Table).
3. Use for all entries.. and equate the key/same fields in both tables:
If not ITAB[] is initial.
Select f1 f2... from <DB Tabale>
into (int table) for all entries in ITAB
where f1 = <f1> and F2 = <f2>.
endif.
Regards,
Anji
02-14-2007 1:27 PM
Hi,
You use for all entries as an:
LOOP AT itab.
...
...
SELECT ... FROM ... WHERE ... = itab-anything.
..
..
ENDLOOP.
Here's an example:
SELECT matnr mtart
FROM mara
INTO TABLE t_mara
WHERE matnr IN s_matnr.
IF NOT t_mara[] IS INITIAL.
SELECT matnr maktx
FROM makt
INTO TABLE t_makt
FOR ALL ENTRIES IN t_mara
WHERE matnr EQ t_mara-matnr.
ENDIF.
If any response helps you, award with forum points.
02-14-2007 1:28 PM
Hi,
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE it_vbap
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vbeln.
In the above code, for all entries in internal table it_vbak, corresponding entries from table VBAP will be fetched into table it_vbap comparing values of vbeln.
Reward points if the answer is helpful.
Regards,
Mukul