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

Formatting Date and Time in Smartforms.

Former Member
0 Likes
5,011

Hello,

I'm a newbie and I'm working with smartforms.

My requirement is to get the following format of date and time in a text within a template.

'MMM DD HH:MM'

Like : Jan 01 12:45

I have tried SAPScript Commands like 'SET DATE MASK' but that doesn't appear to work.

Do I have to use a Function Module?

Please help out. A sample code will be appreciated!

Regards & Thanks,

Arun G Nair

1 ACCEPTED SOLUTION
Read only

former_member187748
Active Contributor
0 Likes
3,670

Hi,

please see this code

DATA: V_DATE1 TYPE STRING

.

SELECT SINGLE LTX FROM T247

   INTO MONTH_NAME

   WHERE SPRAS = SY-LANGU

   AND MNR = SY-DATUM+4(2).

CONCATENATE MONTH_NAME  SY-DATUM+6(2DATE1(4)

    INTO V_DATE1 SEPARATED BY SPACE.

Hello,

I'm a newbie and I'm working with smartforms.

My requirement is to get the following format of date and time in a text within a template.

'MMM DD HH:MM'

Like : Jan 01 12:45

I have tried SAPScript Commands like 'SET DATE MASK' but that doesn't appear to work.

Do I have to use a Function Module?

Please help out. A sample code will be appreciated!

Regards & Thanks,

Arun G Nair

9 REPLIES 9
Read only

Former Member
0 Likes
3,670

Hi,

You need to create a code

data: l_yy(4), l_dd(2).

l_yy= sy-datum+0(4).

l_dd = sy-datum+6(2).

and then use them in them in the text. The time you can get it easy.

Regards

Miguel

Read only

0 Likes
3,670

Hi,

You can get month description in respective language from T247 table.

Concatenate it with sy-datum+0(4) sy-uzeit+0(2) sy-uzeit+3(2).

Regards,

Jaideep,

Read only

former_member187748
Active Contributor
0 Likes
3,671

Hi,

please see this code

DATA: V_DATE1 TYPE STRING

.

SELECT SINGLE LTX FROM T247

   INTO MONTH_NAME

   WHERE SPRAS = SY-LANGU

   AND MNR = SY-DATUM+4(2).

CONCATENATE MONTH_NAME  SY-DATUM+6(2DATE1(4)

    INTO V_DATE1 SEPARATED BY SPACE.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,670

If your required format does not exist in standard output option (Check Output Options for Field Contents) else convert to a character field in a small form either with one of the many availabale FM or a small code.

Regards,

Raymond

Read only

Former Member
0 Likes
3,670

Hey Guys,

Thanks for your replies. But where do I try these codes?

Is it in the 'Initialization' section in Global Definitions?

In that case what all should i declare in the 'Global Data' tab?

Read only

0 Likes
3,670

Hi declare all variables in global declaration of smartform, then create a program lines in your smartforms, then define it in input and output parameters (variables).

Then you can show it in output as v_date1, please add sy-uzeit for time

use &v_date1&, where you wants to show this date format.

Read only

0 Likes
3,670

Where do I declare MONTH_NAME? I tried under Global Data tab in Global Definitions and then in Form Interface. Please help...

Thanks.

Read only

0 Likes
3,670

Define the text field in Global Settings/Global Definitions tab Global Data. Then if the date is unique during the form executuion, initialize this text in Initialization tab, else create a form in tab form routines and call this form in a program lines node before the text nodes that use its value. Also don't forget the import/export parameters of every node.

Regards,

Raymond

Read only

0 Likes
3,670

Goto gobal definition then gobal data..

Variable name    type assignment      associated type

v_month_name   TYPE                       T247-KTX