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

Convert text to date

Former Member
0 Likes
975

Hello,

I face some problems...

I want to work with FUNCTION 'SM02_ADD_MESSAGE'....so I need to give it an expiration date... I declared it :

parameters p_expd TYPE temsg-emtext.

This because I want to assign it dynamicaly , like :

REPLACE '$TUE' IN p_expd WITH next_tuesday.

Where next_tuesday is calculated in the report .

As far I could see , the parameter I must declar as a text, but when I call the function , it must be the type temsg-timdel, which is in fact a date .

<b>So I need to convert the text to date , before I call the function.

Any help?</b>

Thank you .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
921

Hi,

here is the example program



data:  emtext like TEMSG-EMTEXT.
data:  exp_time like TEMSG-TIMDEL.

* Messages have the same format as the dialog transaction --
* a maximum of 3 lines each with a maximum of 60 characters.  Only the first line 
* must contain a message.   
emtext = "Bitte abmelden. Backup in 2 minutes.
      
* Enter the expiration time as shown. Use either 12 or 24

* Hour format, as in user master record, under which the program

* is running.
* If only time is specified, today’s date is assumed.

The print program can  . 
* Always specify a time.                                  
exp_time = '230000'.                        



CALL FUNCTION 'SM02_ADD_MESSAGE'

     EXPORTING                                       

         MESSAGE              = emtext     " 1. message line

         MESSAGE2             =            " 3. line

         MESSAGE3             =            " 3. line

         SERVERNAME           =               " Server

         EXPIRATION_DATE      = SY-DATUM      " expiration date with

         EXPIRATION_TIME      = '230000'      " time

         DELETE_DATE          = ' '           " deletion date with

         DELETE_TIME          = '230000'      " time

         CLIENT               = ' '           " client

      IMPORTING

         MESSAGE_ID           =

    EXCEPTIONS

         EMPTY_MESSAGE        = 1                   

         SERVER_NOT_AVAILABLE = 2                   

         CLIENT_NOT_AVAILABLE = 3                   

         NOT_AUTHORIZED       = 4                   

         OTHERS               = 5     

Regards

Sudheer

Hi,

here is the example program



data:  emtext like TEMSG-EMTEXT.
data:  exp_time like TEMSG-TIMDEL.

* Messages have the same format as the dialog transaction --
* a maximum of 3 lines each with a maximum of 60 characters.  Only the first line 
* must contain a message.   
emtext = "Bitte abmelden. Backup in 2 minutes.
      
* Enter the expiration time as shown. Use either 12 or 24

* Hour format, as in user master record, under which the program

* is running.
* If only time is specified, today’s date is assumed.

The print program can  . 
* Always specify a time.                                  
exp_time = '230000'.                        



CALL FUNCTION 'SM02_ADD_MESSAGE'

     EXPORTING                                       

         MESSAGE              = emtext     " 1. message line

         MESSAGE2             =            " 3. line

         MESSAGE3             =            " 3. line

         SERVERNAME           =               " Server

         EXPIRATION_DATE      = SY-DATUM      " expiration date with

         EXPIRATION_TIME      = '230000'      " time

         DELETE_DATE          = ' '           " deletion date with

         DELETE_TIME          = '230000'      " time

         CLIENT               = ' '           " client

      IMPORTING

         MESSAGE_ID           =

    EXCEPTIONS

         EMPTY_MESSAGE        = 1                   

         SERVER_NOT_AVAILABLE = 2                   

         CLIENT_NOT_AVAILABLE = 3                   

         NOT_AUTHORIZED       = 4                   

         OTHERS               = 5     

Regards

Sudheer

4 REPLIES 4
Read only

franois_henrotte
Active Contributor
0 Likes
921

If your text contains the date in proper format you can use FM CONVERT_DATE_TO_INTERNAL

if not, you have to build it from your data to ensure the date has format YYYYMMDD (this is easy with a concatenate statement)

Read only

Former Member
0 Likes
922

Hi,

here is the example program



data:  emtext like TEMSG-EMTEXT.
data:  exp_time like TEMSG-TIMDEL.

* Messages have the same format as the dialog transaction --
* a maximum of 3 lines each with a maximum of 60 characters.  Only the first line 
* must contain a message.   
emtext = "Bitte abmelden. Backup in 2 minutes.
      
* Enter the expiration time as shown. Use either 12 or 24

* Hour format, as in user master record, under which the program

* is running.
* If only time is specified, today’s date is assumed.

The print program can  . 
* Always specify a time.                                  
exp_time = '230000'.                        



CALL FUNCTION 'SM02_ADD_MESSAGE'

     EXPORTING                                       

         MESSAGE              = emtext     " 1. message line

         MESSAGE2             =            " 3. line

         MESSAGE3             =            " 3. line

         SERVERNAME           =               " Server

         EXPIRATION_DATE      = SY-DATUM      " expiration date with

         EXPIRATION_TIME      = '230000'      " time

         DELETE_DATE          = ' '           " deletion date with

         DELETE_TIME          = '230000'      " time

         CLIENT               = ' '           " client

      IMPORTING

         MESSAGE_ID           =

    EXCEPTIONS

         EMPTY_MESSAGE        = 1                   

         SERVER_NOT_AVAILABLE = 2                   

         CLIENT_NOT_AVAILABLE = 3                   

         NOT_AUTHORIZED       = 4                   

         OTHERS               = 5     

Regards

Sudheer

Read only

former_member188827
Active Contributor
0 Likes
921

declare a variable of type date and move the date from text field to this variable.

move p_expd to zdate.

plz reward points if it helps

Read only

Former Member
0 Likes
921

C14W_CHAR_NUMBER_CONVERSION

regards,

srinivas

<b>*reward for useful answers*</b>