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

Former Member
0 Likes
1,060

Hi All,

I have a small problem while fetching data from the data base using a select statement. the where clause is matching with the data from an internal table which is inturn filled using GUI_upload. here is the code,

select single * from marc into t_marc

where matnr = itab-matnr

and werks = itab-werks.

i am able to fetch the same matnr directly from MARC table, but not through this statement.

Thank You.

11 REPLIES 11
Read only

Former Member
0 Likes
1,037

You can try like this,

loop at itab.

select single * from marc into t_marc

where matnr = itab-matnr

and werks = itab-werks.

endloop.

or

data:

it_marc TYPE TABLE OF marc.

SELECT * FROM marc INTO table it_marc

FOR ALL ENTRIES IN itab

WHERE matnr = itab-matnr

AND werks = itab-werks.

Edited by: Rengith Skariah on Apr 17, 2008 7:27 AM

Read only

Former Member
0 Likes
1,037

hi,

set a parameter for matnr field and werks

select single * from marc into t_marc

where matnr = p_matnr

and werks = p_werks.

u will get the corresponding data

Regards,

priya

Read only

Former Member
0 Likes
1,037

t_marc is a structure here.

Read only

0 Likes
1,037

Hi you cant move the data in Structure.

Write an internal table with same structure fiormat.

Like first you declare an internal table

it_marc type standard table of t_marc.

then in select statement you write :

select single * from marc into it_marc.......

Reward if useful.

Thanks.

Swati.

Read only

manubhutani
Active Contributor
0 Likes
1,037

Hi

There's no problem with ur statement.

just debug it and see whether there is a value in itab-matnr

and itab-werks field....

U may do this in loop so that data can come in header line

or if ur internal table is without header line then firstly transfer data from internal table to work area.

like

loop at int_tab into wa_tab..

then use wa_tab-werks etc..

Please reward points

Read only

Former Member
0 Likes
1,037

HI,

U can do like this

t_marc should be the same as MARC table.

select * 
          from marc into t_marc 
          for all entries IN itab
           where matnr = itab-matnr
           and    werks = itab-werks.

Then u can use

LOOP AT ...
READ TABLE itab WITH KEY.....

if sy-subrc = 0.

endif.
ENDLOOP.

This is a better approach.

Read only

Former Member
0 Likes
1,037

HI,

User conversion exist for material number field before select statement

Check Dataelement->domain of MATNR for conversion exit.

Best regards

Read only

Former Member
0 Likes
1,037

Hi Salma,

Try this, it might solve your problem.

Data:i_marc TYPE TABLE OF MARC.

Select * from MARC

into table i_marc

FOR ALL ENTRIES IN itab

where matnr = itab-matnr AND

werks = itab-werks.

Reward if useful.

Thanks & Regards,

Ahmed Khan.

Read only

Former Member
0 Likes
1,037

Hi

First Define Parameters for the fields matnr and werks.

than Write Select Statement as

select single * from marc into t_marc

where matnr = p_matnr

and werks = p_matnr.

This will solve your problem

Thank You

Nikunj Shah

Read only

Former Member
0 Likes
1,037

hello,

use conversion exit for the matnr feild, u wil get correct value.

tirumal

Read only

Former Member
0 Likes
1,037

so you want to validate the data in the internal table.

you can write like this. but it is a perormance issue.

i,e once you obtain the data from file to itab using GUI_UPLOAD,

loop at itab.

select *

from MARC

into table I_MARC

where matnr = itab-matnr

and werks = itab-werks.

if sys-subrc ne o.

error msg.

endif.

endloop.

-


loop at itab.

read table itab with key matnr = itab-matnr

werks = itab-werks.

if sys-subrc ne o.

error msg.

endif.

endloop.

Reward if helpful

Rgds

Umakanth