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 in Tablecontrol....

Former Member
0 Likes
2,575

Dear Experts,

I have a type '1' program in which a screen is being called. The program displays and updates some personal information (employee info )in a Z table. The screen conatain a table control. And one of the column in the table control is of type DATE (DATUM/DATS/8), which displays the joining date of employee from the Z table.

This program works fine when the user's date format is system default ie YYYMMDD(internal date format). But if a user with a different date format runs the program (say DDMMYYYY) the date field in the table control will be displayed incorrectly ( like YY.YY.DDMM) and then the user cant trigger a PAI. System will give error message "Invalid date format".

When i debug the report, i can find that the corresponding date fields in ABAP are in internal format (YYYYMMDD). What can be the solution?

Do i need to change all the date values according to user parameter in the program, before display? Or is there any option in screen painter, which will automatically convert the date format according to user defaults?

this is an urgent issue here...

Thanking you in Anticipation

Deepak

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,786

Hi,

Please use the following statement :

Write l_date1 to l_date2(8) YYYYMMDD.

This would change the format from the current user setting to the format which is specified ( here it is YYYYMMDD ).

Best regards,

Prashant

Message was edited by: Prashant Patil

12 REPLIES 12
Read only

Former Member
0 Likes
1,787

Hi,

Please use the following statement :

Write l_date1 to l_date2(8) YYYYMMDD.

This would change the format from the current user setting to the format which is specified ( here it is YYYYMMDD ).

Best regards,

Prashant

Message was edited by: Prashant Patil

Read only

0 Likes
1,786

Hi Prashant,

The date field is part of an internal table. Iam filling the table by reading from database table ( Z table ) and depending on the user action, iam savind data back to the database table from this internal table. So, if i change the format in this internal table, will it affect the database table actions?

as Mr. Raja told, the dispay format should be taken care by system, if all the fields are of TYPE D.

In the Z table, the date field is of thye DATUM (DATS/8). And i created the internal table including the structure of my Z table. So there also the type of the field will be of DATUM. Is that ok?

What else can be the reason?

Deepak

Read only

0 Likes
1,786

Dear friends,

the date field in my Z table is YYYYMMDD. my first record in the database table is 19940601.

When a user with a date default date format as DD.MM.YYYY logs in and run the program, the first record is being displayed as 94.19.0106 in the table control field. Iam not able to make out why system shuffles the digits like this.

Can anyone help me please... This is very urgent...

Read only

0 Likes
1,786

Hi,

Change the system->Own profile->defaults->Date format according to your requirement.

Or try using concatenate statement according to the user profile and requirement.

KIndly reward points by clikcing the star on the left of reply,if it helps.

Read only

0 Likes
1,786

Hi,

While moving your date field to T-control dont use MOVE command.

Instead of that use WRITE command.

It will solve your problem.

If you concatenate I think again it will be a problem if the user date format changed.

Thanks.

If this issue is solved reward with points and close the thread.

Read only

Former Member
0 Likes
1,786

Hi Deepak,

Can you please give your code.

Read only

Former Member
0 Likes
1,786

Hi Deepak,

Please try this func <b>CONVERT_DATE_TO_EXTERNAL</b>.

before displaying in the table control.


   CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
       EXPORTING
            DATE_INTERNAL            = tc-date
       IMPORTING
            DATE_EXTERNAL            = external_date
       EXCEPTIONS
            DATE_INTERNAL_IS_INVALID = 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.

Thanks&Regards,

Siri.

Message was edited by: Srilatha T

Read only

Former Member
0 Likes
1,786

Hi,

********

While moving you date field to T-control dont use MOVE command.

Instead of that use WRITE command.

It will solve your problem.

*********

If you are using MOVE command from one itab to another...

Instead of that use WRITE it will solve ur problem.

Thanks.

If this solve ur problem reward with points.

Message was edited by: KDeepak

Read only

athavanraja
Active Contributor
0 Likes
1,786

you dont have to do anything special as long as the date field in your itab is of type D and also the table control column is with reference to a date field.

the system would handle it automatically.

Regards

Raja

Read only

Former Member
0 Likes
1,786

Hi,

Instead of doing all such converiosn, what I prefer is that, better include one more field in the internal table ( As same as table control ) of type character or anything as you require, while binding the internal table with table control just move that field value alone to that new field that you declared in addittion. Make this new field to be visible in table control instead of original field.

I hope this will solve your problem instead of during other conversions. Because what ever you see in the screen is only for user view. So internally when you play around with data (date type) you can use the original field.

I hope this helps.

Regs,

Venkat Ramanan

Read only

Former Member
0 Likes
1,786

Hello Friend,

Normally incase of dates, different users may have different date settings..So the standard procedure is..

1. take the date into a CHAR field

2. declare a variable with type DATE (LIKE required table

field ).

3. assign the CHAR field to DATE field

4. Again assign the DATE field to CHAR field using

WRITE...TO.

For eg.

Please have a look at the below code.. It may help you.

.

.

.

.

perform format_date changing lwa_output-DATAB_new.

.

.

.

.

(* here 'lwa_output-DATAB_new' is an internal table field)

.

.

FORM FORMAT_DATE CHANGING P_DAT_NEW.

data: l_f_datum like rv13a-datab.

data: l_f_date(2) type c,

l_f_mont(2) type c,

l_f_year(4) type c.

data: SEPER TYPE C,

BUF(256).

  • get the date fields seperator

BUF = P_DAT_NEW.

TRANSLATE BUF USING '0 1 2 3 4 5 6 7 8 9 '.

CONDENSE BUF NO-GAPS.

SEPER = BUF(1).

clear: l_f_date, l_f_mont, l_f_year.

SPLIT P_DAT_NEW AT SEPER INTO l_f_date

l_f_mont

l_f_year.

clear p_dat_new.

  • concatenate l_f_date l_f_mont l_f_year into p_dat_new.

concatenate l_f_year l_f_mont l_f_date into p_dat_new.

clear l_f_datum.

l_f_datum = p_dat_new.

clear p_dat_new.

write l_f_datum to p_dat_new.

ENDFORM. " FORMAT_DATE

Plz..Reward me if it works..

Read only

Former Member
0 Likes
1,786

Thanks a lot.