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

Problem in converting legacy date format

Former Member
0 Likes
990

Hello all,

I am having a legacy file in which the date format is yyddd ( e.g 07129 ).

Can any of you experts suggest me how can i convert these date format in SAP date format i.e YYYYMMDD.

Please suggest.

Arun

6 REPLIES 6
Read only

Former Member
0 Likes
888

you would need to add the century to the legacy date somehow sto make it yyyyddd format atleast. then you can call SAP Fm to convert Julian date to YYYY-MM-DD format.

or check OIUH_PWFROMJULIANDT functioan module and write code yourself,

Read only

faisalatsap
Active Contributor
0 Likes
888

Hi, Arun

May be the following code will help you in this way,

data: date like sy-datum,
      year(4),
      month(2),
      day(2).

year = '2006'.
month = '12'.
day = '01'.

date+0(4) = year.
date+4(2) = month.
date+6(2) = day.

Replay if any problem,

Kind Regards,

Faisal

Edited by: Faisal Altaf on Jan 6, 2009 11:00 PM

Read only

former_member156446
Active Contributor
0 Likes
888

Hi Arun date in that format is called Julian date format. check the link below:

[Need Func Mod that provides Julian Date|http://www.sapfans.com/forums/viewtopic.php?f=13&t=10077]

Read only

Former Member
0 Likes
888

Hi,

Check this code..


REPORT  ZTEST_NP.
 
PARAMETERS: P_JDATE(5) TYPE N DEFAULT '07129'.
 
DATA: P_DATE TYPE D,
      L_YEAR TYPE N,
      L_DATE TYPE D.
 
START-OF-SELECTION.
  P_DATE+0(2) = '20'.
  L_YEAR = P_JDATE+0(2) - 1.
  P_DATE+2(2) = L_YEAR.
  P_DATE+4(4) = '0000'.
 
  L_DATE = P_DATE.
  L_DATE+4(4) = '1231'.
 
  P_DATE = L_DATE + P_JDATE+2(3).
 
  WRITE: P_JDATE,
        / P_DATE.         

Regards,

Omkaram.

Read only

Former Member
0 Likes
888

Hi,

You can use RP_CALC_DATE_IN_INTERVAL function Module

Say for year 2007.....you need to give the start date as the first date of that year

i.e. 01/01/2007 (20070101 in sap format). And then add the days that you have in DDD field.

You can go in the loop as this function module only takes 99 days max that you can add at one go.

Hope this helps.

Regards,

Bharati

Read only

Former Member
0 Likes
888

Thanks