Hi Experts,
Actually I inserted this custom code to sort the table data based on period(MM/YYYY).If i commented this code then everything working fine apart from sorting but when i uncommented this code then we copy an existing record then garbage value coming like below
Below is the custom code i have used in PBO of maintanence screen.
data :lt_result TYPE TABLE OF ZHRPYT_PVFTMAP,
ls_result LIKE LINE OF lt_result,
lt_temp1 TYPE TABLE OF ZHRPYT_PVFTMAP,
ls_temp1 LIKE LINE OF lt_temp1.
if sy-ucomm = 'NEWL' or sy-ucomm = 'KOPE' or sy-pfkey = 'EALX'.
else.
SELECT * FROM ZHRPYT_PVFTMAP INTO TABLE lt_result.
LOOP at lt_result INTO ls_result.
ls_temp1 = ls_result.
APPEND ls_temp1 to lt_temp1.
ENDLOOP.
SORT lt_temp1 by ZPERIOD+3(4).
delete ADJACENT DUPLICATES FROM lt_temp1 COMPARING ZPERIOD+3(4).
Data :lv_lyr(4) TYPE c,lv_hyr(4) type c,lv_line TYPE i.
READ TABLE lt_temp1 INTO ls_temp1 INDEX 1.
lv_lyr = ls_temp1-ZPERIOD+3(4).
clear ls_temp1.
lv_line = lines( lt_temp1 ).
READ TABLE lt_temp1 INTO ls_temp1 INDEX lv_line.
lv_hyr = ls_temp1-ZPERIOD+3(4).
refresh extract[].
refresh total[].
DATA :lv_t(7) TYPE c,lv_count TYPE i VALUE 1,lv_c(2) TYPE c VALUE '00',
lv_mandt(3) TYPE c, ZEMPAID(10) TYPE c,ZEMEARN(10) TYPE c,ZEMTTL(10) TYPE c,ZCOPAID(10) TYPE c,
ZCOEARN(10) TYPE c,ZCOTTL(10) TYPE c,ZGRNDTTL(10) TYPE c,lv_aedtm(8) TYPE C,lv_uname(12) TYPE c,str(128) TYPE c.
LOOP at lt_temp1 INTO ls_temp1.
WHILE lv_count le 12.
lv_c = lv_count.
if lv_count lt 10.
CONCATENATE '0' lv_c '/' ls_temp1-ZPERIOD+3(4) INTO lv_t.
ELSE.
CONCATENATE lv_c '/' ls_temp1-ZPERIOD+3(4) INTO lv_t.
ENDIF.
CLEAR total.
LOOP at lt_result INTO <vim_total_struc> WHERE ZPERIOD = lv_t.
APPEND total.
CLEAR :ls_result,str,ZEMPAID,ZEMEARN,ZEMTTL,ZEMTTL,ZCOPAID,ZCOEARN,ZCOTTL,ZGRNDTTL,lv_aedtm,lv_uname.
CLEAR <vim_total_struc>.
ENDLOOP.
lv_count = lv_count + 1.
ENDWHILE.
CLEAR: lv_count,ls_temp1.
ENDLOOP.
EXTRACT[] = total[].
endif.
Anyone could you please help me in resolving this..thanks in advance