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

READ_KNA1

Former Member
0 Likes
713

Hello Friends.

I am trying to use READ_KNA1 function module in a program to get some detials fom KNA1 table. However the following code does not give any results, just giving a blank screen.

I do not understand what am I doing wrong?

Can any one help me.

Regards,

Murali.

**********************************************************************************

REPORT ZTX1910.

PARAMETERS: PKUNNR(10).

DATA: YKNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE,

XKUNNR LIKE KNA1-KUNNR.

XKUNNR = PKUNNR.

CALL FUNCTION 'READ_KNA1'

EXPORTING

XKUNNR = XKUNNR

IMPORTING

XKNA1 = YKNA1

EXCEPTIONS

KEY_INCOMPLETE = 1

NOT_AUTHORIZED = 2

NOT_FOUND = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

ENDIF.

READ TABLE YKNA1 INDEX 1.

WRITE: / YKNA1-NAME1.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
639

Hello Murali

Your negative result is the consequence of poor programming.

A simple change in your program would have solved this (answer of Rob):


...
" PARAMETERS: PKUNNR(10).
PARAMETERS:  p_kunnr    TYPE kunnr.
...

Using the correct type for your PARAMETER the system would "know" that is has to use the conversion-exit assigned to the domain of data element kunnr.

Regards

Uwe

Hello Friends.

I am trying to use READ_KNA1 function module in a program to get some detials fom KNA1 table. However the following code does not give any results, just giving a blank screen.

I do not understand what am I doing wrong?

Can any one help me.

Regards,

Murali.

**********************************************************************************

REPORT ZTX1910.

PARAMETERS: PKUNNR(10).

DATA: YKNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE,

XKUNNR LIKE KNA1-KUNNR.

XKUNNR = PKUNNR.

CALL FUNCTION 'READ_KNA1'

EXPORTING

XKUNNR = XKUNNR

IMPORTING

XKNA1 = YKNA1

EXCEPTIONS

KEY_INCOMPLETE = 1

NOT_AUTHORIZED = 2

NOT_FOUND = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

ENDIF.

READ TABLE YKNA1 INDEX 1.

WRITE: / YKNA1-NAME1.

3 REPLIES 3
Read only

Former Member
0 Likes
639

You have to left pad PKUNNR with zeroes.

This sort of question has been asked and answered many times before - please search before posting.

Rob

Read only

uwe_schieferstein
Active Contributor
0 Likes
640

Hello Murali

Your negative result is the consequence of poor programming.

A simple change in your program would have solved this (answer of Rob):


...
" PARAMETERS: PKUNNR(10).
PARAMETERS:  p_kunnr    TYPE kunnr.
...

Using the correct type for your PARAMETER the system would "know" that is has to use the conversion-exit assigned to the domain of data element kunnr.

Regards

Uwe

Read only

0 Likes
639

My question was very basic, as I am beginner in ABAP programming.

Thanks Rob and Uwe.

Problem solved.