Application Development 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: 

Error in code for in where condition

Former Member
0 Kudos
137

Dear,

I am facing a problem in code :

When using the addition "FOR ALL ENTRIES IN itab", the fields

"OBJECTID" and "LIT_KNA1-KUNNR" must have the same type and length . .

the code is as below:

length of kna1-kunnr is char 10 and length of cdhdr-objectid is char 90.we have to compare both of them.

SELECT kunnr name1 name2 stras ort01 erdat sortl

FROM kna1 INTO TABLE it_kna1

WHERE ktokd IN s_ktokd

AND kunnr IN s_kunnr.

IF sy-subrc NE 0.

REFRESH it_kna1.

ENDIF.

IF it_kna1 IS NOT INITIAL.

DATA: lit_kna1 TYPE TABLE OF ty_kna1.

lit_kna1[] = it_kna1[].

SORT lit_kna1 BY kunnr.

DELETE ADJACENT DUPLICATES FROM lit_kna1 COMPARING kunnr.

SELECT kunnr kunn2 FROM knvp

INTO TABLE it_knvp

FOR ALL ENTRIES IN lit_kna1

WHERE kunnr EQ lit_kna1-kunnr

AND parvw EQ 'PY'.

SELECT objectid udate FROM cdhdr INTO TABLE it_cdhdr

FOR ALL ENTRIES IN lit_kna1

WHERE tcode EQ 'XD05'

AND objectid eq lit_kna1-kunnr. >>>>>>here is the problem

Thanks & Regards----yatendra Sharma

1 ACCEPTED SOLUTION

Former Member
0 Kudos
76

Hi:

Do like this

data: lv_OBJECT type CDOBJECTV.

data : lt_CDHDR type table of cdhdr,

l_tCDHDR1 type tABLE CDHDR.

*--


Your Code--


SELECT kunnr name1 name2 stras ort01 erdat sortl

FROM kna1 INTO TABLE it_kna1

WHERE ktokd IN s_ktokd

AND kunnr IN s_kunnr.

IF sy-subrc NE 0.

REFRESH it_kna1.

ENDIF.

IF it_kna1 IS NOT INITIAL.

DATA: lit_kna1 TYPE TABLE OF ty_kna1.

lit_kna1] = it_kna1[.

SORT lit_kna1 BY kunnr.

DELETE ADJACENT DUPLICATES FROM lit_kna1 COMPARING kunnr.

SELECT kunnr kunn2 FROM knvp

INTO TABLE it_knvp

FOR ALL ENTRIES IN lit_kna1

WHERE kunnr EQ lit_kna1-kunnr

AND parvw EQ 'PY'.

SELECT objectid udate FROM cdhdr INTO TABLE it_cdhdr

FOR ALL ENTRIES IN lit_kna1

WHERE tcode EQ 'XD05'

AND objectid eq lit_kna1-kunnr. >>>>>>here is the problem

*-------New Code

Loop at lit_kna1.

lit_kna1-kunnr to lv_object.

call function BUS_CDHDR_GET

importing

(I_OBJECTCLAS) LIKE CDHDR-OBJECTCLAS

I_OBJECTID) = lv_object

exporting

T_CDHDR =lT_CDHDR .

if lT_CDHDR is not iinitial.

append lines of lT_CDHDR to lT_CDHDR.

clear lT_CDHDR[]

endif.

clear lv_object.

endloop.

Regards

Shashi

1 REPLY 1

Former Member
0 Kudos
77

Hi:

Do like this

data: lv_OBJECT type CDOBJECTV.

data : lt_CDHDR type table of cdhdr,

l_tCDHDR1 type tABLE CDHDR.

*--


Your Code--


SELECT kunnr name1 name2 stras ort01 erdat sortl

FROM kna1 INTO TABLE it_kna1

WHERE ktokd IN s_ktokd

AND kunnr IN s_kunnr.

IF sy-subrc NE 0.

REFRESH it_kna1.

ENDIF.

IF it_kna1 IS NOT INITIAL.

DATA: lit_kna1 TYPE TABLE OF ty_kna1.

lit_kna1] = it_kna1[.

SORT lit_kna1 BY kunnr.

DELETE ADJACENT DUPLICATES FROM lit_kna1 COMPARING kunnr.

SELECT kunnr kunn2 FROM knvp

INTO TABLE it_knvp

FOR ALL ENTRIES IN lit_kna1

WHERE kunnr EQ lit_kna1-kunnr

AND parvw EQ 'PY'.

SELECT objectid udate FROM cdhdr INTO TABLE it_cdhdr

FOR ALL ENTRIES IN lit_kna1

WHERE tcode EQ 'XD05'

AND objectid eq lit_kna1-kunnr. >>>>>>here is the problem

*-------New Code

Loop at lit_kna1.

lit_kna1-kunnr to lv_object.

call function BUS_CDHDR_GET

importing

(I_OBJECTCLAS) LIKE CDHDR-OBJECTCLAS

I_OBJECTID) = lv_object

exporting

T_CDHDR =lT_CDHDR .

if lT_CDHDR is not iinitial.

append lines of lT_CDHDR to lT_CDHDR.

clear lT_CDHDR[]

endif.

clear lv_object.

endloop.

Regards

Shashi