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

Time convertion function module

Former Member
0 Likes
937

HI,

Need a function module or a routine which converts the given date & time to the greenwich time.

regards,

Kiran.L

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
853

HI,

Use Function Module <b>BDL_GET_GREENWICH_TIME</b>

Look at the Blog

/people/himanshu.gupta/blog/2006/11/14/abap4-date-time-and-timestamps

Regards

Sudheer

6 REPLIES 6
Read only

Former Member
0 Likes
853

RKE_TIMESTAMP_CONVERT_INPUT?

Rob

Read only

Former Member
0 Likes
853

the below fm converts Convert Submitted Date/Time from Local time zone to PST

Accordingly try for GMT..

FUNCTION Z_SUBMITTED_LOCAL_TO_SYSTEM.

*"----


""Local interface:

*" IMPORTING

*" VALUE(I_T180) LIKE T180 STRUCTURE T180

*" VALUE(I_ONCE) OPTIONAL

*" EXPORTING

*" VALUE(E_ONCE)

*" CHANGING

*" VALUE(C_VBAK) LIKE VBAK STRUCTURE VBAK

*" EXCEPTIONS

*" NOT_ALLOWED

*" USER_PROFILE_NOT_MAINTAINED

*" TIMEZONE_CONVERSION_ERROR

*"----


  • Local Variables

DATA: W_UNAME LIKE SY-UNAME. "User Id

DATA: W_ZONLO LIKE SY-ZONLO. "User Time Zone

DATA: W_TIMLO LIKE SY-TIMLO. "Local Time

DATA: W_DATLO LIKE SY-DATLO. "Local Date

DATA: W_UZEIT LIKE SY-UZEIT. "System Time

DATA: W_DATUM LIKE SY-DATUM. "System Date

DATA: W_MAHDT LIKE VBAK-MAHDT.

DATA: W_BSTZD LIKE VBAK-BSTZD.

data: w_name like usr01-bname,

w_usr03 like usr03.

  • Check for Create/Change Mode

IF I_T180-TRTYP CN 'HV'.

RAISE NOT_ALLOWED.

ENDIF.

  • Exception - Batch Mode

IF NOT SY-BATCH IS INITIAL.

RAISE NOT_ALLOWED.

ENDIF.

  • Exception - BDC Mode

IF NOT SY-BINPT IS INITIAL.

RAISE NOT_ALLOWED.

ENDIF.

  • Exception - Conversion only once (Due to Incompletion log)

IF NOT I_ONCE IS INITIAL.

RAISE NOT_ALLOWED.

ENDIF.

  • Exclude ZQTE Document type only.

IF C_VBAK-AUART = 'ZQTE'.

RAISE NOT_ALLOWED.

ENDIF.

  • Exception - Submitted Date missing

IF C_VBAK-MAHDT IS INITIAL.

CLEAR: C_VBAK-MAHDT, C_VBAK-BSTZD.

  • raise not_allowed.

CHECK 1 = 2.

ENDIF.

  • Exception - Submitted Time missing

IF C_VBAK-BSTZD IS INITIAL.

CLEAR: C_VBAK-MAHDT, C_VBAK-BSTZD.

  • raise not_allowed.

CHECK 1 = 2.

ENDIF.

  • Exception - CPIC User

CASE SY-UNAME.

WHEN 'ECOMUSER'. W_UNAME = C_VBAK-ERNAM.

WHEN OTHERS. W_UNAME = SY-UNAME.

ENDCASE.

  • Exception - User Profile not maintained

  • SELECT SINGLE * FROM USR03 WHERE BNAME = W_UNAME.

select single * from usr02 where bname = w_uname.

IF SY-SUBRC NE 0.

CLEAR: C_VBAK-MAHDT, C_VBAK-BSTZD.

MESSAGE I008(ZZ).

  • raise not_allowed.

CHECK 1 = 2.

else.

usr03-tzone = usr02-tzone.

ENDIF.

  • Exception - User Profile not maintained for 'User Time Zone'.

IF USR03-TZONE IS INITIAL.

CLEAR: C_VBAK-MAHDT, C_VBAK-BSTZD.

MESSAGE I008(ZZ).

  • raise not_allowed.

CHECK 1 = 2.

ENDIF.

  • Convert Once Only

CLEAR: W_MAHDT, W_BSTZD.

SELECT SINGLE MAHDT BSTZD

FROM VBAK

INTO (W_MAHDT, W_BSTZD)

WHERE VBELN = C_VBAK-VBELN.

IF ( NOT W_MAHDT IS INITIAL ) AND ( NOT W_BSTZD IS INITIAL ).

  • Reset Back the value => Change Not Allowed.

C_VBAK-MAHDT = W_MAHDT.

C_VBAK-BSTZD = W_BSTZD.

RAISE NOT_ALLOWED.

ENDIF.

  • Set Local Date/Time.

W_ZONLO = USR03-TZONE.

W_DATLO = C_VBAK-MAHDT.

W_TIMLO+0(04) = C_VBAK-BSTZD.

W_TIMLO+4(02) = '00'.

  • Convert Local Time to System Time

CALL FUNCTION 'TZ_LOCAL_TO_SYSTEM'

EXPORTING

DATE_LOCAL = W_DATLO

TIMEZONE = W_ZONLO

TIME_LOCAL = W_TIMLO

IMPORTING

DATE_SYSTEM = W_DATUM

TIME_SYSTEM = W_UZEIT

EXCEPTIONS

NO_PARAMETERS = 1

TOO_MANY_PARAMETERS = 2

CONVERSION_ERROR = 3

OTHERS = 4.

  • If Error - Reset Submitted Date/Time

IF SY-SUBRC NE 0.

CLEAR: C_VBAK-MAHDT, C_VBAK-BSTZD.

RAISE TIMEZONE_CONVERSION_ERROR.

ENDIF.

  • Save Local Submitted Date/Time as System Date/Time

C_VBAK-BSTZD = W_UZEIT.

C_VBAK-MAHDT = W_DATUM.

E_ONCE = 'X'.

ENDFUNCTION.

Read only

Former Member
0 Likes
853

Please check

CIF_GEN_CONVERT_DATETIME

Read only

Former Member
0 Likes
854

HI,

Use Function Module <b>BDL_GET_GREENWICH_TIME</b>

Look at the Blog

/people/himanshu.gupta/blog/2006/11/14/abap4-date-time-and-timestamps

Regards

Sudheer

Read only

Former Member
0 Likes
853

DATA: v_timestmp LIKE cest1-timestmp.

GET TIME.

CALL FUNCTION 'RKE_TIMESTAMP_CONVERT_INPUT'

EXPORTING

i_date = sy-datum

i_dayst = sy-dayst

i_time = sy-uzeit

i_tzone = sy-tzone

IMPORTING

e_timestmp = v_timestmp.

WRITE / v_timestmp.

Regards

Kathirvel

Read only

0 Likes
853

Hi,

I have CST time in one table.

I have GMT time in another table.

both the table are updating at the same time i.e. with GMT.

I have to syncronise both while fetching.

regards,

Kiran.L