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: 

pls tell me what it actually means

Former Member
0 Kudos

SELECT werks matnr FROM mara

into (mara-werks, mara-matnr)

WHERE matnr = it_mara-matnr

AND werks IN plant.

ENDSELECT.

what the above code does. how can we achieve the same without using endselect. pls tell me.

thanks & regards

7 REPLIES 7

Former Member
0 Kudos

HI,

this code will select the values of werks and matnr from mara tables into fields mara-werks and mara-matnr respectively where matnr = it_mara-matnr and werks in the range of plant.

in ur case.

it_mara-matnr is variable andplant is select-options(means user can enter a range from selection-screen)

u can achieve it as below without using endselect.

SELECT single werks matnr FROM mara

into (mara-werks, mara-matnr)

WHERE matnr = it_mara-matnr

AND werks IN plant.

rgds,

bharat.

Former Member
0 Kudos

Hi

This code is wrong in reality.

because werks field will not be there in MARA table it is there in MARC table.

This codes fetches the Material and Plant numbers according to the entered values on selection screen in the fields of Plant(select-options) and Material No(parameter).

to avoid endselect..declare a ITAB

data: begin of itab occurs 0,

matnr like mara-matnr,

werks like marc-werks,

end of itab.

SELECT werks matnr FROM <b>marc</b>

into table ITAB

WHERE matnr = it_mara-matnr

AND werks IN plant.

<b>

Reward points for useful Answers</b>

Regards

Anji

former_member235056
Active Contributor
0 Kudos

Hi,

The code fetches all the records for plant and material number from mara table simultaneously at one time.

An alternative way is,

loop at it_mara.

select single werks matnr from mara into it_mara-werks it_mara-matnr

where matnr = it_mara-matnr and werks in plant.

endloop.

pls reward points.

Regards,

Ameet

Former Member
0 Kudos

Hi Chinnu,

If u want multiple records then it is not possible with out endselect retreiving into variable. If u select the data into internal table then use INTO TABLE. Then no need to use ENDSELECT.

Hope this helps you. Reply for queries, shall post the updates.

Regards.

Kumar

former_member200338
Active Contributor
0 Kudos

Hi,

I hope the table it_mara is a internal table which has all the values. Now you want to fetch werks matnr for all the entries in it_mara.

use the following code.. i hope it helps.

Types: begin of ty_output,

werks type WERKS_D,

former_member200338
Active Contributor
0 Kudos

Hi,

The code which you have posted will retrieve single values from mara table into variables mara-matnr and mara-matnr.

if you want to retrieve the single value then you can use the following code

Note: Werks and Matnr is not in Mara. i am using MARC. i hope plant is a select-options.

select single matnr werks into (mara-werks, mara-matnr)

from Marc where matnr = it_mara-matnr and

werks in plant.

(or)

select matnr werks into (mara-werks, mara-matnr)

from Marc where matnr = it_mara-matnr and

werks in plant upto 1 rows.

Now if you want to fetch werks matnr for all the values in it_mara.

use the following code..

Types: begin of ty_output,

matnr type MATNR,

werks type WERKS_D,

end of ty_output.

data lt_output type standard table of ty_output.

check not it_mara is initial.

select matnr werks into table lt_output from marc

for all entries in it_mara

where matnr = it_mara-matnr

and werks in plant.

Awards points if usefull..

Regards,

Niyaz

anversha_s
Active Contributor
0 Kudos

hi,

use this.

data : Begin of itab,
         werks like mara-werks,
         matnr like mara-matnr,
        end of ita.

SELECT werks matnr FROM mara
into table itab
for all entries in it_mara
WHERE matnr = it_mara-matnr
AND werks IN plant.

Regards,

Anversha