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

Match first three character

Former Member
0 Likes
2,472

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,358

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

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

8 REPLIES 8
Read only

Former Member
0 Likes
2,358

Hi Liyana

if you manually perform this search how many entries do you find?

Your code looks right

Regards

Arden

Read only

0 Likes
2,358

Hi, Arden,
if manually check from table, there are 7 entries found.

reagrds,

liyana

Read only

0 Likes
2,358

Hi Liyana

Any chance you can screen shot just the column in question, your code should really be working.

Regards

Arden

Read only

former_member185613
Contributor
0 Likes
2,358

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

Read only

Former Member
0 Likes
2,358

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.

Read only

vinodkumar_thangavel
Participant
0 Likes
2,358

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.

Read only

satvik_panchal
Participant
0 Likes
2,358

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%'..

Read only

Former Member
0 Likes
2,359

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