Skip to Content
0
Former Member
Jul 17, 2008 at 08:29 AM

fetching Date between Atnew loops

11 Views

Hi Experts,

check the following code and help me to fetch the record with the particular date.

As u see in my code i have used ATNEW endat statement ,its difficult for me to fetch the dates within this atnew statement.

how to fetch the date inside this atnew loop.

SELECT SINGLE * FROM cdhdr WHERE objectclas = 'KRED'

AND objectid = w_lfa1-lifnr

AND udate IN c_date.

IF sy-subrc EQ 0.

SELECT * FROM cdpos INTO TABLE w_cdpos

WHERE objectclas = 'KRED'

AND objectid = w_lfa1-lifnr

AND tabname = 'LFBK'

AND chngind EQ 'I' .

IF sy-dbcnt GT 1 .

SORT w_cdpos BY changenr ASCENDING .

CLEAR w_result .

w_result-lifnr = w_lfa1-lifnr .

w_result-fname = 'BANK' .

w_result-ddtext = text-001 .

LOOP AT w_cdpos.

ws_cdpos = w_cdpos .

AT NEW changenr .

IF w_result-value_old IS INITIAL .

w_result-value_old = ws_cdpos-tabkey+13(57) .

ELSE .

w_result-value_new = ws_cdpos-tabkey+13(57) .

ENDIF .

ENDAT .

AT END OF changenr .

IF w_result-value_old IS NOT INITIAL

AND w_result-value_new IS NOT INITIAL .

  • selecting CDHDR with the key only to find the udate

SELECT SINGLE * FROM cdhdr WHERE objectclas = 'KRED'

AND objectid = w_lfa1-lifnr

AND changenr = ws_cdpos-changenr

AND udate IN c_date.

w_result-udate = cdhdr-udate .

APPEND w_result .

w_result-value_old = w_result-value_new .

CLEAR w_result-value_new .

ENDIF .

ENDAT .

ENDLOOP.

ENDIF .

ENDIF.