2018 Oct 26 8:53 AM
Hello,
I am trying to change a date into the desired format 12.12.2012.
LOOP AT DATATAB INTO LS_DATATAB .
CONCATENATE LS_DATATAB-P0016_EINDT+6(2) LS_DATATAB-P0016_EINDT+4(2) LS_DATATAB-P0016_EINDT(4) INTO DATA(LV_DATE3) SEPARATED BY '.'.
LS_DATATAB-P0016_EINDT = LV_DATE3.
However now the date is short by 2 chars so its only 12.12.20
Can anybody help me?
Thank You in Advance!
2018 Oct 26 9:42 AM
How did you define LS_DATATAB-P0016_EINDT, you might need to change its type.
2018 Oct 26 9:42 AM
How did you define LS_DATATAB-P0016_EINDT, you might need to change its type.
2018 Oct 26 9:43 AM
P0016_EINDT TYPE D
If I declare it char15 for ex or string it dumps and says the field is not the same format
2018 Oct 26 9:49 AM
Maybe also try defining the LV_DATE3 outside the loop at the same type you define EINDT.
2018 Oct 26 9:55 AM
that's the way I declare it 😉 the two type D,then I change it to char it dumps
2018 Oct 26 10:09 AM
I need a way to convert date column to char, a function module or smth
2018 Oct 26 10:36 AM
Strange I did a little test with your type of coding and I got no issues. My simple code is here below.
Types: BEGIN OF ty_itab,
datum type c LENGTH 10,
end of ty_itab.
data: itab TYPE TABLE OF ty_itab,
l_itab TYPE ty_itab.
l_itab-datum = sy-datum.
append l_itab TO itab.
loop at itab INTO l_itab.
CONCATENATE l_itab-datum+6(2) l_itab-datum+4(2) l_itab-datum(4) INTO DATA(LV_DATE2) SEPARATED BY '.'.
l_itab-datum = lv_date2.
write: / l_itab-datum.
modify itab FROM l_itab.
endloop.
2018 Oct 26 10:42 AM
Nope,Its necessary that the LS_DATATAB-P0016_EINDT needs to be type D and during the loop,I need to change it to append it to another table!
2018 Oct 26 11:10 AM
testing this code gave me the correct results. so the question is, is ls_datatab the type of datatab or of your second table?
Types: BEGIN OF ty_itab,
datum type d,
end of ty_itab.
data: itab TYPE TABLE OF ty_itab,
l_itab TYPE ty_itab.
Types: BEGIN OF ty_itab2,
datum type c LENGTH 10,
end of ty_itab2.
data: itab2 TYPE TABLE OF ty_itab2,
l_itab2 TYPE ty_itab2.
l_itab-datum = sy-datum.
append l_itab TO itab.
loop at itab INTO l_itab.
CONCATENATE l_itab-datum+6(2) l_itab-datum+4(2) l_itab-datum(4) INTO DATA(LV_DATE2) SEPARATED BY '.'.
l_itab2-datum = lv_date2.
APPEND l_itab2 to itab2.
endloop.
2018 Oct 26 11:30 AM
okay this works only for one field what about for 2 or three other fields that have nothing to do with it
2018 Oct 26 11:45 AM
Shouldn't be an issue as long as you fill the workarea for the second table inside the loop. Try it out.