07-05-2006 8:13 PM
Hello Friends ,
I have a report where the created date ERDAT is displayed in the output as DD/MM/YYYY format . I need to change it to DD/MON/YYYY format. I almost got done with it but for eg ....if my created date is 05/07/2006 in the output. The output should be 05/JUL/2006 in the output.
I am getting the output as 05/JUL/200 .
Please see the snippet code below and give your valuable feedback .
Begin of itab.
erdat(10),
erdat(11),
end of itab.
.....
.....
Loop at itab1.
move-corresponding itab1 to itab.
case itab-erdat+6(2).
WHEN '07'
itab-erdat1+6(3) = 'JUL'.
concatenate itab-erdat4(2) itab-erdat16(3)
t_output-erdat(4)
into t_output-erdat separated by '/'.
......
......
perform build_fieldcat_ddic using:
'ERDAT' 'itab' 'ERDAT' s_tab 'S' ' ' ' ' ' ' ' ' ' '.
Thanks,
Message was edited by: Hari Gopalakrishna
07-05-2006 8:25 PM
Please see the sample program.
report zrich_0001.
data: begin of itab occurs 0,
erdat type sy-datum,
erdat_f(11) type c,
end of itab.
data: month(3) type c.
itab-erdat = '20060615'. append itab.
itab-erdat = '20060715'. append itab.
itab-erdat = '20060815'. append itab.
loop at itab.
case itab-erdat+4(2).
when '06'.
month = 'JUN'.
when '07'.
month = 'JUL'.
when '08'.
month = 'AUG'.
endcase.
concatenate itab-erdat+6(2) month itab-erdat+0(4)
into itab-erdat_f separated by '/'.
modify itab.
endloop.
loop at itab.
write:/ itab-erdat, itab-erdat_f.
endloop.
Regards,
Rich Heilman
07-05-2006 8:16 PM
For this you cannot refer to standard data type which is of length 10.
change the length to char11 and try out
Sorry...think you are already using, then change the field catalog to <b>char</b>
Regds
Manohar
Message was edited by: Manohar Reddy
07-05-2006 8:19 PM
You are referring to the ERDAT field in the field catalog whose output length is 10. Refer to some field which has a greater output length.
-Kiran
07-05-2006 8:25 PM
Please see the sample program.
report zrich_0001.
data: begin of itab occurs 0,
erdat type sy-datum,
erdat_f(11) type c,
end of itab.
data: month(3) type c.
itab-erdat = '20060615'. append itab.
itab-erdat = '20060715'. append itab.
itab-erdat = '20060815'. append itab.
loop at itab.
case itab-erdat+4(2).
when '06'.
month = 'JUN'.
when '07'.
month = 'JUL'.
when '08'.
month = 'AUG'.
endcase.
concatenate itab-erdat+6(2) month itab-erdat+0(4)
into itab-erdat_f separated by '/'.
modify itab.
endloop.
loop at itab.
write:/ itab-erdat, itab-erdat_f.
endloop.
Regards,
Rich Heilman
07-05-2006 8:27 PM
07-05-2006 8:26 PM
Try this:
Begin of itab.
erdat(10),
erdat1(11),
end of itab,
v_txt_month LIKE t015m-monam.
LOOP AT itab.
SELECT SINGLE monam INTO v_txt_month
FROM t015m
WHERE spras EQ sy-langu AND
monum EQ itab-erdat+4(2).
CONCATENATE itab-erdat+6(2) v_txt_month
t_output-erdat(4)
into itab-erdat1 separated by '/'.
MODIFY itab.
ENDLOOP.
And take care when you fill field catalog for that field, use char11 type.
Regards.
07-05-2006 8:43 PM
This may be useful if you don't want to hardcode.
DATA: v_date LIKE sy-datum,
v_out_date(11),
v_mon(3).
DATA: BEGIN OF month_names OCCURS 0.
INCLUDE STRUCTURE t247.
DATA: END OF month_names.
v_date = sy-datum.
CALL FUNCTION 'MONTH_NAMES_GET'
* EXPORTING
* LANGUAGE = SY-LANGU
* IMPORTING
* RETURN_CODE =
TABLES
month_names = month_names
* EXCEPTIONS
* MONTH_NAMES_NOT_FOUND = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR month_names.
READ TABLE month_names WITH KEY mnr = v_date+4(2).
CHECK sy-subrc = 0.
v_mon = month_names-ktx.
CONCATENATE v_date+6(2)
v_mon
v_date+0(4)
INTO v_out_date SEPARATED BY '/'.
WRITE:/ 'V_DATE = ', v_date,
/ 'V_OUT_DATE = ', v_out_date.