Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select statement logic

Former Member
0 Likes
518

Hi,

I have two internal tables one is contains matnr and another contains objnr.

i want to select the data from another database table which contains same matnr,objnr in internaltables.

How to write select statement.

Regards,

Suresh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
499

Hi

If there some relation B/W matnr and objnr then put these two in one intenal table and then write SELECT with these two in where condition .

Otherwise read table based on material (also select objnr ) then filter entries comparing OBJNR form earlier Intrenal Table.

Regards

Sachin Sharma

4 REPLIES 4
Read only

Former Member
0 Likes
499

hi,

at first merge the two internal tables into it_merge in which matnr & objnr both fields are present...

now


select .......
          <fieldname>
         from <dbtab>
         into corresponding fields of table it_final
         for all entries in it_merge
         where matnr eq it_merge-matnr
         and objnr eq it_merge-objnr.

Arunima

Read only

Former Member
0 Likes
500

Hi

If there some relation B/W matnr and objnr then put these two in one intenal table and then write SELECT with these two in where condition .

Otherwise read table based on material (also select objnr ) then filter entries comparing OBJNR form earlier Intrenal Table.

Regards

Sachin Sharma

Read only

Former Member
0 Likes
499

Hi Suresh,

Retrieve the data for first internal table. After that use the for all entries command to fetch the data for second internal table.

Eg:

DATA: tab_spfli TYPE TABLE OF spfli,

tab_sflight TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY table_line,

wa LIKE LINE OF tab_sflight.

SELECT carrid connid

INTO CORRESPONDING FIELDS OF TABLE tab_spfli

FROM spfli

WHERE cityfrom = 'NEW YORK'.

SELECT carrid connid fldate

INTO CORRESPONDING FIELDS OF TABLE tab_sflight

FROM sflight

FOR ALL ENTRIES IN tab_spfli

WHERE carrid = tab_spfli-carrid AND

connid = tab_spfli-connid.

LOOP AT tab_sflight INTO wa.

WRITE: / wa-carrid, wa-connid.

ENDLOOP.

Regards,

Santosh

Read only

Former Member
0 Likes
499

Hi,

Please see the link below for mapping tables

http://www.sap-img.com/general/sap-r3-tables.htm

Regards

Raheed