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 data from tables

Former Member
0 Likes
993

Hi,

this is basic question but iam confusing.

in my selection contains two fields like matnr and werks.

if user give matnr only i will get all matnrs.

if user give matnr and werks i need matnr no's based on werks.

how can i write select statement based on mara and marc.

Regards,

Suresh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
966

search sdn with <select ... For all entries>

or even an F1 wud do.

Edited by: kartik tarla on Dec 11, 2008 3:45 PM

8 REPLIES 8
Read only

Former Member
0 Likes
967

search sdn with <select ... For all entries>

or even an F1 wud do.

Edited by: kartik tarla on Dec 11, 2008 3:45 PM

Read only

GauthamV
Active Contributor
0 Likes
966

select matnr werks from marc into table itab

where matnr in s_matnr and werks in s_werks.

Read only

Former Member
0 Likes
966

hi,

Concatenate % sign at end of both matnr and werks.

write the selection statement as below.

select * from <tab-name> into table <itab>

where matnr like v_matnr

and werks like v_werks

Hope this helps,

Rajat

Read only

former_member203501
Active Contributor
0 Likes
966

hi do like this ..

if p_matnr is not initial .

select matnr from marc into table itab where matnr = p_matnr .

elseif p_matnr is initial and p_werks is not initial.

select matnr

werks

from marc

into table itab1

where matnr = p_matnr

and werks = p_werks .

endif.

Read only

Former Member
0 Likes
966

Hi,

For this when u enter only matnr details in select-options u get only matnrs.

so for select-option put if condition.

like this..

If s_matnr is not intitial .

select.....

endif.

if s_matnr is not intial and s_werks is not initial

select matnr werks......

endif.

for output printing also u use same if condition for both...

Try this....

Read only

Former Member
0 Likes
966

This message was moderated.

Read only

Former Member
0 Likes
966

Hi Suresh,

The following query may help you.

Here select option is used for both matnr and werks.

SELECT a~matnr
    INTO TABLE int_tab
    FROM mara AS a INNER JOIN marc AS b
    ON a~matnr = b~matnr
    WHERE a~matnr IN so_matnr AND
          b~werks IN so_werks.

Regards,

Manoj Kumar P

Edited by: Manoj Kumar on Dec 11, 2008 12:41 PM

Read only

Former Member
0 Likes
966

Hi,

Select matnr werks from table name

where matnr in s_matnr

and werks in s_werks.

Thanks,

Krishna...