Application Development 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: 

select data from tables

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

or even an F1 wud do.

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

GauthamV
Active Contributor
0 Kudos

select matnr werks from marc into table itab

where matnr in s_matnr and werks in s_werks.

Former Member
0 Kudos

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

former_member203501
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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....

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Select matnr werks from table name

where matnr in s_matnr

and werks in s_werks.

Thanks,

Krishna...