Application Development and Automation 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: 
Read only

remove days from date

Yasin
Active Participant
0 Kudos
1,818

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

1 ACCEPTED SOLUTION
Read only

FredericGirod
Active Contributor
1,429

I don't understand your issu

my_month_year = |{ bla-fkdat+4(2) }.{ bla-fkdat+0(4) }|. 
13 REPLIES 13
Read only

RaymondGiuseppi
Active Contributor
1,429

Why wont you replace day with '01'

a_i_final1_mg-fkdat+6(2) = '01'.
Read only

0 Kudos
1,429

Hi Raymond

i don't want the day to appear at all in my result only Month + Year

Regards

Read only

0 Kudos
1,429

My trick will allow you to collect data as required.

Now if you don't want to display the day, either create another field of type year.period (e.g. data element such as BUPER or JAHRPER) or use a DATS specific domain with a conversion exit that hide the day and reduce the output length.

Read only

ArthurParisius
Contributor
1,429

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).

Read only

0 Kudos
1,429

Hi Arthur

using 3(06) will through an error message:

The sum of offset (3) and length (06) exceeds the field length (8).

Regarsd

Read only

matt
Active Contributor
1,429

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?

Read only

FredericGirod
Active Contributor
1,430

I don't understand your issu

my_month_year = |{ bla-fkdat+4(2) }.{ bla-fkdat+0(4) }|. 
Read only

0 Kudos
1,429

matthew.billingham You see, I don't use Hungarian notation !!! Each time I wrote code here, I thing about your aversion about that 🙂

Read only

matt
Active Contributor
1,429

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 ). 
Read only

0 Kudos
1,429

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)

Read only

0 Kudos
1,429

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.

Read only

matt
Active Contributor
0 Kudos
1,429

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.

Read only

former_member623629
Participant
0 Kudos
1,429

I am not sure about your problem, but you can try creating a new field and copying the month to that.