PDA

Ver la Versión Completa : Calcular diferencia de fechas


flipeloflipa
18/10/06, 07:53:50
Hola,
mi problema es el siguiente, necesito conseguir las horas de difrencia entre la decha actual con la hora, por ejemplo 2006/10/18 10:00:00 con una feha anterior, por ejemplo 2006/10/17 12:00:00. Seguro que existe alguna funcion que lo haga, pero soy algo novato y la desconozco.

Muchas gracias, espero vuestra ayuda

tomasm
18/10/06, 08:46:42
SE37

Puedes utilizar la función:

SD_DATETIME_DIFFERENCE



:p

flipeloflipa
18/10/06, 09:10:21
Me da el siguiente error DUMP al llamar a la funcion:



Errores tiempo ejecucióCALL_FUNCTION_CONFLICT_GEN_TYP
Excepción CX_SY_DYN_CALL_ILLEGAL_TYPE
ocurrido el 18.10.2006 a 11:47:18


Type conflict when calling function module "SD_DATETIME_DIFFERENCE".


¿Qué ha sucedido?


Error in ABAP application program.

The current ABAP program "ZSD_ALMA_L_ALMACENES_AVL " had to be terminated
because one of the
statements could not be executed.

This is probably due to an error in the ABAP program.


¿Qué puede hacer?


Print out the error message (using the "Print" function)
and make a note of the actions and input that caused the
error.

To resolve the problem, contact your SAP system administrator.
You can use transaction ST22 (ABAP Dump Analysis) to view and administer
termination messages, especially those beyond their normal deletion
date.

La llamada a la funcion es la siguiente:


CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = l_fecha
TIME1 = l_hora
DATE2 = SY-DATUM
TIME2 = SY-UZEIT
IMPORTING
DATEDIFF = l_t_dias
TIMEDIFF = l_t_horas
EARLIEST = l_t_EARLIEST

EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Que me ocurre? l_t_dias l_t_horas l_t_EARLIEST las tengo declaradas del tipo I

tomasm
18/10/06, 09:16:01
FUNCTION SD_DATETIME_DIFFERENCE.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(DATE1) TYPE D
*" VALUE(TIME1) TYPE T
*" VALUE(DATE2) TYPE D
*" VALUE(TIME2) TYPE T
*" EXPORTING
*" VALUE(DATEDIFF) TYPE P
*" VALUE(TIMEDIFF) TYPE P
*" VALUE(EARLIEST) TYPE C
*" EXCEPTIONS
*" INVALID_DATETIME
*"----------------------------------------------------------------------
Saludos !!! :)

flipeloflipa
18/10/06, 09:26:13
Ya esta!!!

Muchisimas gracias tomasm, me has servido de gran ayuda!!!