cancel
Showing results for 
Search instead for 
Did you mean: 

[Date] Conversion Routine removes the standard date check ??

guillaume-hrc
Active Contributor
0 Kudos

Hi,

I have created my own date element so as to be able to use JJ/MM/AAAA (the standard forbids this - there has been various discussions on SDN about this) which is the "French way" to write a date.

I also attached a conversion routine ZDTFR to format the date accordingly.

But, as a result, I do not get the standard 'xxxx is not a date' that appears when using the DATS data element , instead of my own specific one.

I am only able to see that the date is incorrect (00000000) but I lose the text entered by the user (for instance, he/she type 01M12/2008 instead of 01/12/2008)

-> I can't see it the OnEnter event handler neither in the conversion routine (logical since it expects a date as input parameter)

It makes sense because the parameters being dates, the context attribute cannot retained strings.

Thanks in advance for your help.

Best regards,

Guillaume

Accepted Solutions (0)

Answers (1)

Answers (1)

guillaume-hrc
Active Contributor
0 Kudos

Hi,

Simply add a message in the conversion routine.

Nonetheless, a side-effect is that I get the user input in upper-case. I did try to use a domain with small letters but the call failed...

Here is my conversion routine:

FUNCTION conversion_exit_zdtfr_input.
*"----------------------------------------------------------------------
*"*"Interface locale :
*"  IMPORTING
*"     VALUE(INPUT) OPTIONAL
*"  EXPORTING
*"     VALUE(OUTPUT)
*"----------------------------------------------------------------------
** See this thread on SDN : <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="660687"></a>

  DATA: l_input        TYPE c LENGTH 200,
        l_small_input  TYPE text1024,
        l_output       TYPE d,
        l_datfm        TYPE xudatfm.
  DATA: lt_tokens      TYPE TABLE OF string.

** In case of an invalid date, try to save the capital/small letters (even if the WDA framework seems
**  to pass it as capital ??)
  l_small_input =  input.

  l_input       =  input.

  IF input CA '/'.
    SPLIT input AT '/' INTO TABLE lt_tokens.
    IF lines( lt_tokens ) = 3.
      REPLACE ALL OCCURRENCES OF '/' IN l_input WITH '.' IN CHARACTER MODE.
    ENDIF.
  ENDIF.

  TRY.
      CALL METHOD cl_abap_datfm=>conv_date_ext_to_int
      EXPORTING
        im_datext    = l_input
*     im_datfmdes  =
      IMPORTING
        ex_datint    = l_output
        ex_datfmused = l_datfm
        .
    CATCH cx_abap_datfm_no_date.
      MESSAGE e020(zhra_wf) WITH input.
    CATCH cx_abap_datfm_invalid_date.
      MESSAGE e020(zhra_wf) WITH input.
    CATCH cx_abap_datfm_format_unknown.
      MESSAGE e020(zhra_wf) WITH input.
    CATCH cx_abap_datfm_ambiguous.
      MESSAGE e020(zhra_wf) WITH input.
  ENDTRY.

  CASE l_datfm.
    WHEN '2'.

    WHEN OTHERS.
      output = l_output.
  ENDCASE.

ENDFUNCTION.