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: 

retirval problem for the old-new values from cdhdr,cdpos

Former Member
0 Kudos

hi all.

i want to get the old and new values from cdhdr and cdpos table but not getting the output as the if condition of read statement" if i_cdhdr-objectid = itemp-kunnr." is not getting executed.what could be the mistake and how can i resolve.plz suggest

loop at it_knb1.

itemp-kunnr = it_knb1-kunnr.

itemp-kunnr1 = it_knb1-kunnr.

append itemp.

endloop.

if not itemp[] is initial.

select * from cdhdr

into table i_cdhdr

for all entries in itemp

where OBJECTCLAS = 'DEBI'

and OBJECTID = itemp-kunnr

and tcode = 'VD02'.

select * from cdhdr

appending table i_cdhdr

for all entries in itemp

where OBJECTCLAS = 'DEBI'

and OBJECTID = itemp-kunnr

and tcode = 'XD02'.

endif.

if not i_cdhdr[] is initial.

select * from cdpos into table i_cdpos

for all entries in i_cdhdr

where OBJECTCLAS = i_cdhdr-OBJECTCLAS

and OBJECTID = i_cdhdr-OBJECTID

and TABNAME = 'KNVV'

and ( FNAME = 'ZTERM' ).

endif.

loop at it_knb1 where kunnr = it_kna1-kunnr.

read table itemp with key kunnr1 = it_knb1-kunnr.

if sy-subrc = 0.

loop at i_cdhdr.

if i_cdhdr-objectid = itemp-kunnr.

it_final-username = i_cdhdr-username.

clear i_cdpos.

read table i_cdpos with key OBJECTCLAS = i_cdhdr-OBJECTCLAS

OBJECTID = i_cdhdr-OBJECTID

FNAME = 'ZTERM'.

if sy-subrc = 0.

it_final-zterm_old = i_cdpos-value_old.

it_final-zterm_new = i_cdpos-value_new.

endif.

endif.

endloop.

endif.

endloop.

2 REPLIES 2

GauthamV
Active Contributor
0 Kudos

Hi,

since you are using loop for i_cdhdr you have to use read statement

for itemp table.Then it will work.

tarangini_katta
Active Contributor
0 Kudos

Hi Tanisha,

BEtter to loop everything cdhdr and CDPOS

U can do one thing.

Use CHANGEDOCUMENT_READ_HEDAER to get the data from CDHDR.

SUE FM CHANGEDOCUMENT_READ_POSTIONS.

to get the data from the each change number.

then u can retrieve the data as u want.

This will avoid confusion.

U can get the correct data.

Thanks