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

Date format

Former Member
0 Likes
949

Hai,

Is there any function module which checks the datatype sy-datum.

I have the value 20070418 in a variable . I want to check it is of the datatype

sy-datum.

urgent.

Regards,

Rakesh.

8 REPLIES 8
Read only

Former Member
0 Likes
910

hi rakesh,

can you please explain in more detail about your requirement.

If you just want to check if the variable has the same date as today then you can use

if variable_name = sy-datum.

***do something.

endif.

Regards,

Atish

Read only

Former Member
0 Likes
910

Hi,

Look at the function module

<b>DATE_CHECK_PLAUSIBILITY</b>, Check to see if a date is in a valid format for SAP or not

Regards

Sudheer

Read only

Former Member
0 Likes
910

hi,

Adding to sudheer, try this.

DATA: v_date TYPE sydatum.
 
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = v_date
EXCEPTIONS
plausibility_check_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'INvalid date'.
ELSE.
WRITE: / 'Correct date'.
ENDIF.

Regards

Reshma

Read only

Former Member
0 Likes
910

you can try with this function module . just give your field dataelement as input in ROLL_NAME , so that you will gives all data like Domain , lenth , all texts ,etc

<u><b>DD_DTEL_GET</b></u>

Girish

Read only

Former Member
0 Likes
910

hi Rakesh,

DATE_CHECK_PLAUSIBILITY - Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.

PARAMETER P_DATE TYPE SYDATUM.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = P_DATE
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.
 
v_subrc = sy-subrc.
 
if v_subrc = '1'.
 
write : 'PLAUSIBILITY_CHECK_FAILED'.
elseif  v_subrc = '2'.
write : 'OTHERS'.

Read only

Former Member
0 Likes
910

Hi Rakesh,

You can use SAP's standard function module in SE37 transaction '<b><i>DD_DTEL_GET'</i></b>.

Just pass the name of dataelement of the variable you are using in your program.The function module, will give you the details about its type as SY-DATUM in your case.

DATA: LS_DD04L_WA_A TYPE DD04L,
      LS_DD04L_WA_N TYPE DD04L, 
      LS_DD01L_WA TYPE DD01L.

CALL FUNCTION 'DD_DTEL_GET'
 EXPORTING
   GET_STATE           = 'MXX'
   LANGU               = '*'
   PRID                = 0
   WITHTEXT            = 'X'
   ROLL_NAME           = 'Z_DATA_ELEMENT'
 IMPORTING
   DD04L_WA_A          = LS_DD04L_WA_A
   DD04L_WA_N          = LS_DD04L_WA_N
   DD01L_WA            = LS_DD01L_WA
 EXCEPTIONS
   ILLEGAL_VALUE       = 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.

In the export parameter DD04L_WA_A-DATATYPE you will get the name of datatype. Also in the same struture you can get the name of domain/dataelements etc.

This sort out your query.

PS If the answer solves your query, plz close the thread by rewarding each reply.

Regards

Sapna Modi

Read only

gopi_narendra
Active Contributor
0 Likes
910

just declare it as type DATUM.

parameter : p_date type DATUM.

no need to do anything else.

Regards

Gopi

Read only

Former Member
0 Likes
910

Hi,

Use the following FM:

<b>DATE_CHECK_PLAUSIBILITY</b> Check to see if a date is in a valid format for SAP. Works well when validating dates being passed in from other systems.

Hope this helps.

Reward if helpful.

Regards,

Sipra