2020 Oct 26 2:32 PM
Hi,
I want to remove days from date so i can collect my internal table base on month (period)
so i want to convert all date from DD.MM.YYY ==> MM.YYYY
what is the best way to achieve this
i have uses as work around the bellow code:
wa_i_final1_mg-fkdat = wa_i_final1_mg-fkdat+2(06).
but am getting extra dot on final result like .MM.YYYY and an not sure if it is correct way.
Thanks
2020 Oct 27 8:45 AM
I don't understand your issu
my_month_year = |{ bla-fkdat+4(2) }.{ bla-fkdat+0(4) }|.
2020 Oct 26 2:38 PM
2020 Oct 27 6:48 AM
Hi Raymond
i don't want the day to appear at all in my result only Month + Year
Regards
2020 Oct 27 9:06 AM
2020 Oct 26 2:47 PM
Seeing that you're using wa_i_final1_mg-fkdat+2(06) i take it that the value in wa_i_final1_mg-fkdat isalready in the DD.MM.YYYY format. If that is the case that it doesn't surprise me that you get the extra dot, it does surprise that your result is .MM.YYYY instead of .MM.YYY though.
In other words I think wa_i_final1_mg-fkdat+2(06) should be wa_i_final1_mg-fkdat+3(06).
2020 Oct 27 6:46 AM
Hi Arthur
using 3(06) will through an error message:
The sum of offset (3) and length (06) exceeds the field length (8).
Regarsd
2020 Oct 27 8:56 AM
That makes NO SENSE.
Your input string according to you is of the format DD.MM.YYY Your first issue here is that year only has three characters. But even then, that's a string that is 9 characters long. If you are getting the error message that the field length is 8, then I can only assume you are not giving us full information.
string+offset(len) is the syntax. Offset starts at zero. Offset plus len must not be greater than the length of string. This is basic. Which part are you having trouble with?
2020 Oct 27 8:45 AM
I don't understand your issu
my_month_year = |{ bla-fkdat+4(2) }.{ bla-fkdat+0(4) }|.
2020 Oct 27 8:57 AM
matthew.billingham You see, I don't use Hungarian notation !!! Each time I wrote code here, I thing about your aversion about that 🙂
2020 Oct 27 8:58 AM
Or one of these (since the OP clearly doesn't understand the +offset(length) syntax).:
my_month_year = |{ substring( val = bla-fkdat off = 4 len = 2 ) }.{ substring( val = bla-fkdat len = 4 ) }|.
my_month_year = substring( val = bla-fkdat off = 4 len = 2 ) && '.' && substring( val = bla-fkdat len = 4 ).
2020 Oct 27 1:19 PM
matthew.billingham Maybe it's old style, and that I'm old school, but I prefer Frederic code, from far ! 😉
(sometimes, just learn people something "new" and they will be happy to use it)
2020 Oct 27 1:42 PM
I wonder if the good answer was not to find a correct Data element, like there is in FI module.
Because what we propose is just the output of the value, it could not be really used.
2020 Oct 27 2:57 PM
But you must admit that substring is readily more comprehensible to anyone new to ABAP. If the OP had gone for that in the first place, then maybe s/he wouldn't have got confused.
2020 Oct 27 10:34 AM
I am not sure about your problem, but you can try creating a new field and copying the month to that.