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

different field type error

Karan_Chopra_
Active Participant
0 Likes
1,046

plz solve this query:

SELECT ERDAT KUNNR NAME1 NAME2 LAND1 REGIO ORT01 PSTLZ SORTL STRAS TELF1 MCOD1 MCOD2 MCOD3 FROM KNA1

INTO CORRESPONDING FIELDS

OF TABLE IKNA1 .

SELECT CHANGENR CHANGE_IND FROM CDHDR INTO CORRESPONDING FIELDS

OF TABLE ICDHDR for all entries in ikna1 WHERE OBJECTCLAS = 'DEBI' AND

<b>OBJECTID = IKNA1-KUNNR</b> AND UDATE IN S_UDATE.

here the bolded field are showing error as one is of length 90 and other of 10.

please help how to check this.

<b>error</b> - when using "for all entries in itab" the fields OBJECTID and IKNA-KUNNR must have same type and length

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
845

Hi,

While declaring type of ICDHDR

declare kunnr(90) type c.

it will solve your problem.

regards,

Ruchika

Reward if useful.

6 REPLIES 6
Read only

Former Member
0 Likes
845

change field length of KUNNR in IKNA1 to 90.

Both the queries will work then.

Read only

Karan_Chopra_
Active Participant
0 Likes
845

no i cannot change the length

Read only

0 Likes
845

then create one more table ikna1_temp, which will have KUNNR length as 90.

LOOP AT IKNA1.

MOVE-CORRESPONDING IKNA1 TO IKNA1_TEMP.

APPEND IKNA1_TEMP.

ENDLOOP.

and use the other table in second query.

Because the field type and length has to be same otherwise it will give an error

SELECT CHANGENR CHANGE_IND FROM CDHDR INTO CORRESPONDING FIELDS

OF TABLE ICDHDR for all entries in ikna1 WHERE OBJECTCLAS = 'DEBI' AND

OBJECTID = <b>IKNA1_TEMP-KUNNR</b> AND UDATE IN S_UDATE.

I had to take similar steps in order to get data from CDHDR table.

Message was edited by:

Darshil Shah

Read only

S0025444845
Active Participant
0 Likes
845

Hi,

create types,

begin of ty_knai,

kunnr(90) type c,

name1 type knai-name1,

name2 type kna1-name2,

.............

...........

mcod3 type knai-mcod3,

end of ty_knai.

data: iknai type standard table of ty_knai.

now use first select query as

SELECT ERDAT KUNNR NAME1 NAME2 LAND1 REGIO ORT01 PSTLZ SORTL STRAS TELF1 MCOD1 MCOD2 MCOD3 FROM KNA1

INTO TABLE IKNA1 .

regards,

sudha.

reward points if helpful

Read only

Former Member
0 Likes
846

Hi,

While declaring type of ICDHDR

declare kunnr(90) type c.

it will solve your problem.

regards,

Ruchika

Reward if useful.

Read only

Karan_Chopra_
Active Participant
0 Likes
845

thanx to alll

for helping especially ruchika ..i did the same thing ...its working now