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: 

Problem with select statement

0 Kudos

DATA : lv_matnr TYPE matnr,
lv_extwg TYPE extwg.


DATA: BEGIN OF TKOMP OCCURS 10.
INCLUDE STRUCTURE KOMP.
DATA: END OF TKOMP.
"DATA: tkomp TYPE komp.

SELECT SINGLE matnr extwg FROM mara INTO (lv_matnr,lv_extwg)
WHERE matnr = lv_matnr.
IF sy-subrc EQ 0.
tkomp-extwg = lv_extwg.
ENDIF.
WRITE 😕 lv_extwg.

My problem is while execute this statement the output is empty. May i know why?

Please guide me to get a value for lv_extwg... by using mara and komp table.

1 ACCEPTED SOLUTION

abo
Active Contributor

You're reading MARA with key matnr = lv_matnr and at the same time writing the result for MATNR into lv_matnr.

Somehow I don't think this is what you want... also, what is the value of lv_matnr to begin with?

7 REPLIES 7

abo
Active Contributor

You're reading MARA with key matnr = lv_matnr and at the same time writing the result for MATNR into lv_matnr.

Somehow I don't think this is what you want... also, what is the value of lv_matnr to begin with?

0 Kudos

We will fill TKOMP-EXTWG with the value from MARA?

TKOMP-EXTWG = MARA-EXTWG ?

need to fill the structure tkomp.

SimoneMilesi
Active Contributor
0 Kudos

naveena_10 check your code as Andrea suggested: put a break point on the select and check how you read MARA table...

If this is the full code, you are reading with empty LV_MATNR: whatelse do you expect?

0 Kudos

how to modify this code to get lv_extwg value..?

matt
Active Contributor

You can use the same variable in the WHERE as in the INTO. I've done it many times.

My guess is that data isn't there, or the lv_matnr is in external format and needs to go through that ALPHA conversion exit.

abo
Active Contributor
0 Kudos

It is a tiny bit more confusing, I know it works.

I agree on your hunch.

BhargavaReddy
Active Participant
0 Kudos

SELECT SINGLE extwg FROM mara INTO lv_extwg

WHERE matnr = lv_matnr.