09-15-2008 9:43 AM
Hi friends,
i am a new user of ABAP and also SDN.
i need a help.
i want to fetch data from one database table based on primary keys of 2 internal tables. how to put in where clause.
Thanks in advance.
09-15-2008 9:47 AM
hii
refer to following code ..i hope it will help you
SELECT matnr " Material Number
FROM mara
INTO TABLE i_mara
WHERE matnr IN s_matnr.
IF i_mara[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
prctr " Profit Center
FROM marc
INTO TABLE i_marc
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr
AND werks IN s_werks.
ENDIF. " IF i_mara[] IS NOT INITIAL
i_output = i_marc.
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
regards
twinkal
09-15-2008 9:47 AM
Hi...
> primary keys of 2 internal tables
Correst your post, because internal table fields never contains primary key and Non-primary key catogories!
Thanks,
Naveen.I
09-15-2008 9:49 AM
refer
[http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm]
09-15-2008 9:52 AM
HI,
Thanks for your message. As per your coding, it is fetching from 2 different tables, but my requirement is to fetch from one table based on 1 field from one internal table and 1 field from another internal table. Please help.
09-15-2008 9:57 AM
select * from <table name> where <field name1> = <itab1-field> and <field name2> = <itab2-field>.
09-15-2008 10:02 AM
Hi,
Use FOR ALL ENTRIES keyword
Examples
select * into table it_result from mara
for all entries in <itab>
where matnr eq <itab>-fieldname.
select * into table it_result1 from mara
for all entries in <itab2>
where matnr eq <itab2>-fieldname.
09-15-2008 10:04 AM