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

simple qa

Former Member
0 Likes
1,016

i get err why

select matnr kdmat

into (knmt-matnr , knmt-kdmat )

from knmt.

14 REPLIES 14
Read only

Former Member
0 Likes
993

select matnr kdmat
into (knmt-matnr, knmt-kdmat )
from knmt. 

no space before , ) !

Working example:

TABLES: knmt.

SELECT matnr kdmat

INTO (knmt-matnr, knmt-kdmat)

FROM knmt.

ENDSELECT.

Message was edited by: Rene Guenther

Read only

hymavathi_oruganti
Active Contributor
0 Likes
993

U HAVE TO USE SINGLE

select SINGLE matnr kdmat

into (knmt-matnr , knmt-kdmat )

from knmt.

Read only

Former Member
0 Likes
993

declare tables KNMT.

then as your are not passing any values in WHERE CLAUSE,

select up to 1 rows will be more efficient than select single

so use this.

SELECT MATNR

KDMAT

INTO ( KNMT-MATNR,

KNMT-KDMAT )

UP TO 1 ROWS

FROM KNMT.

ENDSELECT.

Regards

srikanth

Read only

0 Likes
993

single,endselect-- dost work

iget--"statment no accessible

Read only

0 Likes
993

this is the include

&----


& Include Zzzzzzzzzz

&----


data : begin of itab2 occurs 0,

matnr like knmt-matnr,

kdmat like knmt-kdmat,

maktx like makt-maktx,

matkl like mara-matkl,

bismt like mara-bismt,

end of itab2.

select single matnr kdmat

into (knmt-matnr , knmt-kdmat )

from knmt.

if sy-subrc = 0.

itab2-matnr = knmt-matnr.

itab2-kdmat = knmt-kdmat.

endif.

endselect.

Read only

0 Likes
993

tables KNMT.

SELECT MATNR

KDMAT

INTO (KNMT-MATNR,

KNMT-KDMAT)

UP TO 1 ROWS

FROM KNMT.

ENDSELECT.

when i execute my code sample, i am getting matnr values ??

what is the problem then ??

check this code ??

Read only

0 Likes
993

if you use SELECT-SINGLE, NO need of any ENDSELECT

remove it.

Read only

0 Likes
993

select matnr kdmat

into (knmt-matnr , knmt-kdmat )

from knmt.

in the above statement u r using,

please clarify, have u declared an internal table with name knmt in the program.

check that once.

Read only

0 Likes
993

in your code, i observed unrequired assignment of values ??

for example :knmt-matnr , knmt-kdmat these 2 variables not required to use.

use directly itab2 variables. and in if condition use append .

modified code :

clear itab2.

select single matnr kdmat

into (itab2-matnr , itab2-kdmat )

from knmt.

if sy-subrc = 0.

append itab2. "here we reduced 2 assignments from 2 temp variables to ITAB2 RECORD.

endif.

ONE MORE OBSERVATION :

YOU have NOT USED APPEND ITAB2. so the values coming from KNMT table will not appear in ITAB2 table.

GOT IT ???

added one more observation in the code sample

Message was edited by: Srikanth Kidambi Maruthi

Read only

0 Likes
993

i dont think it's the select i pass the include.

Read only

0 Likes
993

pl let me know,whats your exact problem ???

Read only

0 Likes
993

just curious...

you guys can activate the code with spaces before comma and ending bracket?

into (itab2-matnr , itab2-kdmat )

I would except, that only

into (itab2-matnr, itab2-kdmat)

is the correct syntax.

Read only

Former Member
0 Likes
993

Include tables statement

tables : knmt.

and

select single matnr kdmat
into (knmt-matnr , knmt-kdmat )
from knmt.

if sy-subrc = 0.
itab2-matnr = knmt-matnr.
itab2-kdmat = knmt-kdmat.
endif.

Read only

abdul_hakim
Active Contributor
0 Likes
993

Hi Liat,

add <b>TABLES KNMT</b> before using your SELECT statement.

You cannot have <b>SELECT SINGLE</b> and <b>ENDSELECT</b> combination,since you are not looping in this case.

Please refer to OPEN SQL libarary in http://help.sap.com

Regards,

Abdul