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: 

fetching Date between Atnew loops

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Since you are copying the workarea content to another as below

ws_cdpos = w_cdpos ,

Use WS_CDPOS contents to check with in the AT NEW statement.

Rgds,

Hema

3 REPLIES 3

Former Member
0 Kudos

Hi,

Since you are copying the workarea content to another as below

ws_cdpos = w_cdpos ,

Use WS_CDPOS contents to check with in the AT NEW statement.

Rgds,

Hema

former_member262988
Active Contributor
0 Kudos

hi,

use like this....

delcrae another workarea ws_cdpos1 same as ws_cdpos.

LOOP AT w_cdpos.

ws_cdpos1 = w_cdpos .

AT NEW changenr .

IF w_result-value_old IS INITIAL .

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

ELSE .

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

ENDIF .

ENDAT .

this will solve your problem....

Former Member
0 Kudos

Hello

loop at w_cdpos into ws_cdpos.