Application Development 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: 

Convert BUDAT value (like 01/01/2006) to a YYYYMM (200601) NUMC 6 value?

Former Member
0 Kudos

If some ABAP expert here give a sample code on how to convert a date type of BUDAT value (like 01/01/2006) to a YYYYMM (200601) NUMC 6 value, that would be great <REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 10, 2008 12:14 PM

1 ACCEPTED SOLUTION

former_member583013
Active Contributor
0 Kudos

data: date type sy-datum,
      new_date(6) type c.

date = sy-datum.

concatenate date+0(4) date+4(2)
into new_date.

write:/ new_date.

Greetings,

Blag.

7 REPLIES 7

former_member583013
Active Contributor
0 Kudos

data: date type sy-datum,
      new_date(6) type c.

date = sy-datum.

concatenate date+0(4) date+4(2)
into new_date.

write:/ new_date.

Greetings,

Blag.

Former Member
0 Kudos

Hi!

Try FM DATUMSAUFBEREITUNG; I think it'll meet your needs.

Best!

Jim

0 Kudos

hi jim runkle,

Could you give the example code on how to run the function you suggested?

Thanks alot!

Former Member
0 Kudos

Hi Kevin,

Try this


REPORT  ychatest MESSAGE-ID zz.

DATA : v_date TYPE budat,
       v_numc(6) TYPE n.

v_date = '20060101'.

v_numc = v_date+0(4).

WRITE : / v_date , v_numc.

Former Member
0 Kudos

do something like this

data: ydate(10) type c,

fdate(6) type c.

ydate = pdate.

CONCATENATE ydate6(4) ydate3(2) into fdate.

write: fdate.

Former Member
0 Kudos

Here ya go ....

report sdn.

data: l_tdat6(08) type c.

call function 'DATUMSAUFBEREITUNG'

exporting

idate = sy-datum

importing

tdat6 = l_tdat6

exceptions

datfm_ungueltig = 1

datum_ungueltig = 2

others = 3.

if sy-subrc <> 0.

break-point.

endif."subrc

break-point.

Former Member
0 Kudos

Hello Kevin-

Below is the piece of code.

data:v_m(2) type c, "**Month

v_y(4) type c, "** Year

v_str type string." ** new string.

v_m = sy-datum+4(2).

v_y = sy-datum+0(4).

concatenate v_y v_m into v_str.

Cheers,

~Srini...