10-20-2008 8:11 PM
Hi All,
I need some help with this code...
DESCRIBE TABLE itab1 LINES lin.
IF lin = 1.
select single * INTO table itab2 from mara
where matnr = itab1-matnr.
IF sy-subrc EQ 0.
W_matnr = itab2-matnr.
ENDIF.
ENDLOOP.
My Itab1 is having 1 record but by select single statement is returning with subrc 4 as I don't have value in header, can you please help in this code.
Thank You.
Sunitha
10-20-2008 8:20 PM
try the changes..
DESCRIBE TABLE itab1 LINES lin.
IF lin = 1.
read table itab1 index 1. "add this , if it is with header line, else use work area
select single * INTO table itab2 from mara
where matnr = itab1-matnr.
IF sy-subrc EQ 0.
W_matnr = itab2-matnr.
ENDIF.
.
10-20-2008 8:16 PM
Hi,
Can you please share the complete LOOP.....ENDLOOP... that you written for itab1.
10-20-2008 8:21 PM
Hi Ajay,
Thank you for your quick reply, Actually there is no loop statements, I have mistypes it.
I have a internal table (itab1) with 1 record and I wanted to get data from mara table based on itab1-matnr.
How can I do that. Thank you.
Regards
Sunitha.
10-20-2008 8:36 PM
Hi,
I hope Vijay solution should work for you.......Have you tried that.....I believe in your code..the value of itab1-matnr is missing......Probably because you didn't filled the header line of itab1...and hence get the itab1 header line filled by using READ Statement
10-20-2008 8:44 PM
since you are using select single , so don't use internal table
data: wa_mara type mara.
select single * INTO wa_mara from mara
where matnr = itab1-matnr.
IF sy-subrc EQ 0.
W_matnr = wa_mara-matnr.
ENDIF
.
internal tables with Header line is old style. In OO context you have to use table with out header line, you have to use explict workarea.
10-20-2008 8:59 PM
HI Ajay/ Vijay,
Thank you for guiding me. I also thank SDN team for this opportunity.
I will give points to both of u.
Thank u.
10-20-2008 8:20 PM
try the changes..
DESCRIBE TABLE itab1 LINES lin.
IF lin = 1.
read table itab1 index 1. "add this , if it is with header line, else use work area
select single * INTO table itab2 from mara
where matnr = itab1-matnr.
IF sy-subrc EQ 0.
W_matnr = itab2-matnr.
ENDIF.
.
10-20-2008 8:39 PM
HI Vijay,
Thank You, I have changed the program according to your suggestion, I got the good results in itab2 but again when I am moving into w_matnr. Itab2-matnr field in not having any value.
Looks like always header line does not have any value. please suggest.
Thank you.
sunitha.
10-20-2008 8:42 PM
Hi,
Use this
select single * INTO corresponding fields of table itab2 from mara
where matnr = itab1-matnr.
10-20-2008 8:49 PM
Sorry that, I am confused since you are using "Select.. Single" you will be resulting in one set of records every time. So, why do you want to use a table to store it. If you want only one value for verification.
data: l_matnr like mara-matnr.
IF lin = 1.
select single * INTO l_matnr from mara
where matnr = itab1-matnr.
ENDIF.
you can use the same l_matnr for next processing steps.
10-20-2008 8:55 PM
Try it the easy way:
DESCRIBE TABLE itab1 LINES lin.
IF lin = 1.
READ TABLE itab1 INDEX 1.
SELECT SINGLE * FROM mara
WHERE matnr = itab1-matnr.
IF sy-subrc EQ 0.
w_matnr = mara-matnr.
ENDIF.
ENDIF.
Rob
10-20-2008 9:11 PM
Rob,
Your ABAP tip/trick is very useful.
Thank U,
Sunitha
Edited by: Sunitha Reddy on Oct 20, 2008 10:11 PM
10-20-2008 9:16 PM
But bear in mind that you need to use an explicit work area in classes.
Rob