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

query

Former Member
0 Likes
1,053

hai,

tell me what this query do..........

itab is my internal table

SELECT SINGLE matkl INTO mara-matkl

FROM mara

WHERE matnr EQ itab-matnr.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,029

If this code is not placed in the LOOP statement, then it will pick up header value present in ITAB-MATNR and use it to pick up MATKL from MARA. If there is an entry, the value is placed in MARA-MATKL.

If it is placed in a LOOP Statement, then it will pick up MATKL from MARA for each entry of MATNR from ITAB. If there is an entry, the value is placed in MARA-MATKL.

8 REPLIES 8
Read only

Former Member
0 Likes
1,030

If this code is not placed in the LOOP statement, then it will pick up header value present in ITAB-MATNR and use it to pick up MATKL from MARA. If there is an entry, the value is placed in MARA-MATKL.

If it is placed in a LOOP Statement, then it will pick up MATKL from MARA for each entry of MATNR from ITAB. If there is an entry, the value is placed in MARA-MATKL.

Read only

Former Member
0 Likes
1,029

this query

SELECT SINGLE matkl INTO mara-matkl

FROM mara

WHERE matnr EQ itab-matnr.

It will fetch one record i.e. matkl value from mara into temp memory mara-matkl

using the where condition matnr EQ itab-matnr(i.e) the values matching in internal table.

Example :

SELECT SINGLE batxt FROM t161t INTO t161t-batxt WHERE

bsart = wa_fitab2-bsart AND

spras = sy-langu.

Read only

0 Likes
1,029

so why they are moving tempraveryly in to database table.

Read only

0 Likes
1,029

It is not moved to database table. We are just using the work area of standard table MARA which acts like a variable of type MATKL (as we are using MARA-MATKL).

Read only

Former Member
0 Likes
1,029

so why they are moving tempraveryly in to database table.

Read only

Former Member
0 Likes
1,029

hi Vikram,

for the 'matnr' value present in the header line of the internal table itab, the select query will fetch the corresponding 'matkl' value from th DB table mara and store it in the field 'mara-matkl'.

Regards,

Viji

Read only

Former Member
0 Likes
1,029

If you dont want in that way, do in this below way

example :

SELECT SINGLE *

FROM lfa1 INTO wa_lfa1

WHERE lifnr = wa_fitab2-lifnr.

define as below

Data : wa_lfa1 TYPE lfa1.

<b>In your case do it as below

Data : wa_matkl TYPE matkl.

SELECT SINGLE matkl INTO wa_matkl

FROM mara

WHERE matnr EQ itab-matnr.</b>

Read only

Former Member
0 Likes
1,029

And moreover your not updating the database table in the below query

SELECT SINGLE matkl INTO mara-matkl

FROM mara

WHERE matnr EQ itab-matnr.

you are using temporory work area thats it.