cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Routine in Transformation

Former Member
0 Kudos

I have a routine that uses TIMECALC_DIFF to determine the difference between to date/times held in timestamp format.

All it generates is a duration of zero, no matter what the inputs are.

Value for YDATTIM is 20050812121821 and for YDATTIMF is 20050813121821 and the answer given is zero, when it should be 86400.

CONSTANTS: gc_timezone_system TYPE timezone VALUE 'MSTNO'.

DATA: t_first(14) TYPE c,

t_last(14) TYPE c,

/BIC/YDATTIM TYPE timestamp,

/BIC/YDATTIMF TYPE timestamp,

/BIC/YDATDUR TYPE i.

CALL FUNCTION 'TIMECALC_DIFF'

EXPORTING

timestamp1 = /BIC/YDATTIM

timestamp2 = /BIC/YDATTIMF

timezone = gc_timezone_system

IMPORTING

difference = /BIC/YDATDUR.

RESULT = /BIC/YDATDUR.

Thanks

Steve

Accepted Solutions (1)

Accepted Solutions (1)

godbole_yogesh
Explorer
0 Kudos

hi,

can u try storing DIFF and result in two different variables. My guess is the result is overwriting the actual difference with a 0. Unfortunately I dont have a system with me to verify this.

Answers (2)

Answers (2)

0 Kudos

hi,

create a variable and pass the value of difference to it and then to result.

also check the data type of difference...

hope it will help..

regards,

sanjeev Kumar

Former Member
0 Kudos

Thanks for the help... I have put the code into se37 and it works, if on the EXPORT I set RESULT as type I.

*" EXPORTING

*" REFERENCE(RESULT) TYPE I

The Transformation automatically set the type to

  • EXPORTING

  • RESULT type tys_TG_1-/BIC/YDATDUR

and the function doesn't work with this and doesn't seem to let me change this?

Former Member
0 Kudos

Of what type is "result"? When I take your original code and run it as a standalone ABAP, it seems to work as you desire, and prints 86,400 seconds.

PROGRAM zz_temp.

data      result           type i.


*Value for YDATTIM is 20050812121821 and for YDATTIMF is 20050813121821 and the answer given is zero, when it should be 86400.

CONSTANTS: gc_timezone_system TYPE timezone VALUE 'MSTNO'.

DATA: t_first(14)      TYPE c,
      t_last(14)       TYPE c,
      /bic/ydattim     TYPE timestamp    value '20050812121821',
      /bic/ydattimf    TYPE timestamp    value '20050813121821',
      /bic/ydatdur     TYPE i.




CALL FUNCTION 'TIMECALC_DIFF'
  EXPORTING
    timestamp1 = /bic/ydattim
    timestamp2 = /bic/ydattimf
    timezone   = gc_timezone_system
  IMPORTING
    difference = /bic/ydatdur.

result = /bic/ydatdur.

write result.

Former Member
0 Kudos

In the transformation it generates the following code, and this doesn't seem to be editable;

  • IMPORTING

  • request type rsrequest

  • datapackid type rsdatapid

  • SOURCE_FIELDS-/BIC/YDATTIMF TYPE /BIC/OIYDATTIMF

  • SOURCE_FIELDS-/BIC/YDATTIM TYPE /BIC/OIYDATTIM

  • EXPORTING

      • RESULT type tys_TG_1-/BIC/YDATDUR**

DATA:

MONITOR_REC TYPE rsmonitor.

I have put all the code generated below

PROGRAM trans_routine.

----


  • CLASS routine DEFINITION

----


*

----


CLASS lcl_transform DEFINITION.

PUBLIC SECTION.

  • Attributs

DATA:

p_check_master_data_exist

TYPE RSODSOCHECKONLY READ-ONLY,

*- Instance for getting request runtime attributs;

  • Available information: Refer to methods of

  • interface 'if_rsbk_request_admintab_view'

p_r_request

TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.

PRIVATE SECTION.

TYPE-POOLS: rsd, rstr.

  • Rule specific types

TYPES:

BEGIN OF tys_SC_1,

  • InfoObject: YDATTIMF Finish date/time.

/BIC/YDATTIMF TYPE /BIC/OIYDATTIMF,

  • InfoObject: YDATTIM Start date/time.

/BIC/YDATTIM TYPE /BIC/OIYDATTIM,

  • Field: RECORD.

RECORD TYPE RSARECORD,

END OF tys_SC_1.

TYPES:

BEGIN OF tys_TG_1,

  • InfoObject: YDATDUR Duration.

/BIC/YDATDUR TYPE /BIC/OIYDATDUR,

END OF tys_TG_1.

$$ begin of global - insert your declaration only below this line -

*

$$ end of global - insert your declaration only before this line -

METHODS

compute_YDATDUR

IMPORTING

request type rsrequest

datapackid type rsdatapid

SOURCE_FIELDS type tys_SC_1

EXPORTING

RESULT type tys_TG_1-/BIC/YDATDUR

monitor type rstr_ty_t_monitor

RAISING

cx_rsrout_abort

cx_rsrout_skip_record

cx_rsrout_skip_val.

METHODS

invert_YDATDUR

IMPORTING

i_th_fields_outbound TYPE rstran_t_field_inv

i_r_selset_outbound TYPE REF TO cl_rsmds_set

i_is_main_selection TYPE rs_bool

i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set

i_r_universe_inbound TYPE REF TO cl_rsmds_universe

CHANGING

c_th_fields_inbound TYPE rstran_t_field_inv

c_r_selset_inbound TYPE REF TO cl_rsmds_set

c_exact TYPE rs_bool.

ENDCLASS. "routine DEFINITION

$$ begin of 2nd part global - insert your code only below this line *

*

$$ end of 2nd part global - insert your code only before this line *

----


  • CLASS routine IMPLEMENTATION

----


*

----


CLASS lcl_transform IMPLEMENTATION.

METHOD compute_YDATDUR.

  • IMPORTING

  • request type rsrequest

  • datapackid type rsdatapid

  • SOURCE_FIELDS-/BIC/YDATTIMF TYPE /BIC/OIYDATTIMF

  • SOURCE_FIELDS-/BIC/YDATTIM TYPE /BIC/OIYDATTIM

  • EXPORTING

  • RESULT type tys_TG_1-/BIC/YDATDUR

DATA:

MONITOR_REC TYPE rsmonitor.

$$ begin of routine - insert your code only below this line -

CONSTANTS: gc_timezone_system TYPE timezone VALUE 'GMTUK'.

DATA: t_first(14) TYPE c,

t_last(14) TYPE c,

/BIC/YDATTIM TYPE timestamp,

/BIC/YDATTIMF TYPE timestamp,

/BIC/YDATDUR TYPE i.

CALL FUNCTION 'ZZTIMEDIFF'

EXPORTING

/BIC/YDATTIM = /BIC/YDATTIM

/BIC/YDATTIMF = /BIC/YDATTIMF

timezone = gc_timezone_system

IMPORTING

difference = /BIC/YDATDUR.

RESULT = /BIC/YDATDUR.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "compute_YDATDUR

----


  • Method invert_YDATDUR

----


*

  • This subroutine needs to be implemented only for direct access

  • (for better performance) and for the Report/Report Interface

  • (drill through).

  • The inverse routine should transform a projection and

  • a selection for the target to a projection and a selection

  • for the source, respectively.

  • If the implementation remains empty all fields are filled and

  • all values are selected.

*

----


*

----


METHOD invert_YDATDUR.

$$ begin of inverse routine - insert your code only below this line-

... "insert your code here

$$ end of inverse routine - insert your code only before this line -

ENDMETHOD. "invert_YDATDUR

ENDCLASS. "routine IMPLEMENTATION

Thanks

Steve

Former Member
0 Kudos

Solved this by putting the code from the TIMEDIFF function directly into the transformation.

Former Member
0 Kudos

Hi, PLZ use tcode se37,and with the same parameters the function will works ok?

Edited by: Bruce Wang on Dec 1, 2008 3:42 AM