Skip to Content
author's profile photo Former Member
Former Member

How to validate when date format is diff Internally and externally

Hello,

How can I validate the Date format if Internal format and external format is different.

Ex : 

 *  SELECT SINGLE CRTSP
**                FROM /SAPSLL/PR
**                INTO L_CRTSP
**                WHERE CRTSP IN S_CRTSP .
*

CRTSP (YYYY/DD/MM HHMMSEC) Internal Format 

S_CRTSP (YYYY/DD/MM) External format - selection option

I had done following to convert the internal format to external format. 

DATA : LV_DT TYPE STRING.

DATA :  L_CRTSP TYPE /SAPSLL/CRTSP.

SELECT SINGLE CRTSP
                FROM /SAPSLL/PR
                INTO L_CRTSP.

MOVE : L_CRTSP TO LV_DT. "(YYYY/DD/MM HHMMSEC)

 L_LEN = STRLEN( LV_DT ).
 L_DATE = LV_DT+0(8).

I have the date format that i need in L_DATE."  (YYYY/DD/MM)

Now how should I validate? 


*  SELECT SINGLE CRTSP
**                FROM /SAPSLL/PR
**                INTO L_CRTSP
**                WHERE CRTSP IN S_CRTSP .

Please let me know how can I validate or how can I write the select query to validate this field. 

There should be some way using Wildcard or some function module...which I am not sure...

Any suggestions will be appreciated!

Regards,

Kittu

Edited by: Kittu on Jan 6, 2009 12:58 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

10 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 03:10 PM

    Hello,

    This is actual select query for data selection.

    SELECT GUID_PR   "Primary Key as GUID in "RAW" Format
             CRTSP     "PRODUCT CREATED ON
             CHTSP     "PRODUCT CHANGED ON
             FROM /SAPSLL/PR
             INTO TABLE T_PR
              FOR ALL ENTRIES IN T_PRGEN    
             WHERE GUID_PR EQ T_PRGEN-GUID_PR 
                    AND CRTSP IN *S_CRTSP*     
                  AND CHTSP IN S_CHTSP.
    
    
    Now I had changed the date format and it is in v_dat variable. 
    
    How should i select the data based on this criteria. 
    
    I mean should I write this select query like this : 
    
    SELECT GUID_PR   "Primary Key as GUID in "RAW" Format
             CRTSP     "PRODUCT CREATED ON
             CHTSP     "PRODUCT CHANGED ON
             FROM /SAPSLL/PR
             INTO TABLE T_PR
              FOR ALL ENTRIES IN T_PRGEN    
             WHERE GUID_PR EQ T_PRGEN-GUID_PR 
                    AND CRTSP IN *v_dat*     
                  AND CHTSP IN S_CHTSP.

    If I am doing so then it is throwing an error message.

    Please suggest....

    Regards,

    Kittu

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      i dont think its necessary to pass the time zone..nyways here is d syntax example for the same...

      DATA: time_stamp TYPE timestamp,

      dat TYPE d,

      dat TYPE d,

      tz TYPE ttzz-tzone,

      dst TYPE c LENGTH 1.

      tz = 'BRAZIL'.

      time_stamp = 20030309033000.

      CONVERT TIME STAMP time_stamp TIME ZONE tz

      INTO DATE dat .

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:16 PM

    Hello,

    Thank you for your quick response!

    I had already converted into desired format...

    My issue is how can I write screen validation?

    I have the desired fromat date in L_DATE.

    I had converted (YYYY/DD/MM HHMMSEC) Internal Format to

    external format (YYYY/DD/MM).

    How can I write validation for it...

    TT, you got it right...i need to validate this field just like any other screen validation.

    So what do you suggest if the condition satisfies?

    Any suggestions will be appreciated and can you please eloborate your sugesstions!

    Regards,

    Kittu

    Edited by: Kittu on Jan 6, 2009 1:17 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:05 PM

    Hi Kittu,

    Take date in string ..split at '/' adn comare the range like

    yyyy shd be betwwen 1900-2008

    dd btw 1-31 and

    mm btw 1-12.

    regards

    vivek

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:06 PM

    Hi,

    Use this FM to convert internal format

    CONVERT_DATE_TO_INTERNAL

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:07 PM

    Hi,

    Use conversion exit for date in your required format.

    Thanks

    Sanket sethi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:09 PM

    hi,

    do like dis...

    DATA: time_stamp TYPE timestamp,

    dat TYPE d,

    SELECT SINGLE CRTSP

    FROM /SAPSLL/PR

    INTO time_stamp .

    CONVERT TIME STAMP time_stamp INTO DATE dat .

    IF dat IN s_CRTSP. "filter

    " do the append or watever...

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:42 PM

    Hi,

    Would you want to try something like below...

    CONCATENATE s_crtsp-low '%' INTO wa_crtsp.

    SELECT SINGLE CRTSP

    FROM /SAPSLL/PR

    INTO L_CRTSP

    WHERE CRTSP LIKE wa_crtsp .

    But this would give you data for only a single date.

    You could very well keep looping through for all dates from s_crtsp-low to s_crtsp-high.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:03 PM

    Hi,

    Use the function module FORMAT_DATE_4_OUTPUT

    DATA : DATE TYPE CHAR10.

    CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'

    EXPORTING

    DATIN = '20081013'

    FORMAT = 'DD.MM.YYYY'

    IMPORTING

    DATEX = DATE.

    IF DATE IS INITIAL.

    give error message

    ELSE:

    WRITE : / DATE.

    ENDIF. .

    it solves your problem

    Thanks!!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2009 at 12:52 PM

    Hi,

    Convert screen input is same as internal format (Using FM wat I mentioned above) and then validate with internal field in AT SELECTION SCREEN.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 14, 2009 at 06:18 AM

    Hello TT & Everybody!

    Thank you for all your suggestions and solutions...

    TT- Thank you for your solution... 😊

    They were really helpful and I apprecaiate it!

    Regards,

    Kittu

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.