01-29-2015 2:13 AM
Hi Expert!
Kindly, need your help and guide.
I want to get customer code, customer name from KNA1 table where customer name start with 'ACP'.
I try to code as below, but, the program return wrong
TABLES: KNA1.
types:
begin of lty_kna1,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of lty_kna1.
data: it_kna1 type standard table of lty_kna1 with header line.
select kunnr name1
into table it_kna1
from kna1 where name1 LIKE 'ACP%'.
if sy-subrc = 0.
write:/ it_kna1-name1.
else.
write:/ 'wrong program'.
endif.
Your help is really appreciated,
regards,
Liyana
01-29-2015 5:41 AM
Hi, Everyone.
thank you for helping,
The program already success with amendment as below:
TABLES: KNA1.
types:
begin of lty_kna1,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of lty_kna1.
data: it_kna1 type standard table of lty_kna1 with header line.
select kunnr name1
into table it_kna1
from kna1 where name1 LIKE 'ACP%'.
write:/1 'Customer',20 'Name1'.
LOOP AT it_kna1.
write:/1 it_kna1-kunnr, 20 it_kna1-name1.
ENDLOOP.
regards,
liyana
01-29-2015 2:22 AM
Hi Liyana
if you manually perform this search how many entries do you find?
Your code looks right
Regards
Arden
01-29-2015 2:35 AM
Hi, Arden,
if manually check from table, there are 7 entries found.
reagrds,
liyana
01-29-2015 2:59 AM
Hi Liyana
Any chance you can screen shot just the column in question, your code should really be working.
Regards
Arden
01-29-2015 3:55 AM
Hi Liyana,
The code looks fine but be aware that the LIKE statement is case sensitive. The query is fetching all the customers whose name starts with 'ACP' (all in caps) where as you may be looking for customers whose name starts with 'ACP' irrespective of the letter case.
Hope this helps,
~Athreya
01-29-2015 4:19 AM
Here you need to do a little change.
data : RESULT(4) type c.
CONCATENATE 'ACP' '%' INTO RESULT.
you just put result after your like clause.
select kunnr name1
into table it_kna1
from kna1 where name1 LIKE RESULT.
01-29-2015 4:22 AM
Hi,
You shall try using range table and pass values as
lr_mara-sign = 'I'.
lr_mara-option = 'CP'.
lr_name-low = 'ACP*'.
finally pass this range table in the select query.
Regards,
Vinodkumar.
01-29-2015 4:38 AM
I think 'ACP' will be your Customer code(KUNNR) and not Customer Name(NAME1). So check accordingly and write your select query.
select.....
......where kunnr like 'ACP%'..
01-29-2015 5:41 AM
Hi, Everyone.
thank you for helping,
The program already success with amendment as below:
TABLES: KNA1.
types:
begin of lty_kna1,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of lty_kna1.
data: it_kna1 type standard table of lty_kna1 with header line.
select kunnr name1
into table it_kna1
from kna1 where name1 LIKE 'ACP%'.
write:/1 'Customer',20 'Name1'.
LOOP AT it_kna1.
write:/1 it_kna1-kunnr, 20 it_kna1-name1.
ENDLOOP.
regards,
liyana