Application Development 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: 

Converstion Exit for TIME

Former Member
0 Kudos

Hello,

I am reading txt file format (open dataset) for date and time data. After getting the data I have to run through the FM - SD_CALC_DURATION_FROM_DATETIME and when done I am again pusing the data to flat file. In the process I found that when I upload/download the time field is loosing its format and also there is loss of some information. e.g. if the time is 08:42:15 then the program is loosing the seconds data and the field becomes 08:42:. I want to know why this is happeneing and why its not loosing the data from last ':' rather than only last 2 digits. I checked SDN and searched through google but I could not find the solution also I tried using conversion exits CONVERSION_EXIT_TIMEA_OUTPUT and CONVERSION_EXIT_TIMEA_INPUT. But these are not working properly. Any inputs are appriciated.

Thanks in advance

9 REPLIES 9

Former Member
0 Kudos

Hello Sam,

Time internal format is of 8 digits and output is of 10. You might be cutting the data somewhere in your code.

0 Kudos

Hi Edgar,

But I am referenceing it to tbtco-STRTTIME. How should I define the variable / field?

former_member156446
Active Contributor
0 Kudos

Hi there.. I chekc this exits.. and I dont thing those are the conversion exits....these just validate the entries in table TTSEGTIME... most of the time its getting sy-subrc 4.

I guess you cannot rely on this convertions..

Check decleration of the varaibles you are using... I guess you are declaring some varaible 2 characters less...

DATA: lv_time TYPE sytime.
DATA: lv_temp TYPE t.

lv_time = sy-uzeit.
WRITE:/ 'Input:', lv_time.

CALL FUNCTION 'CONVERSION_EXIT_TIMEA_OUTPUT'
  EXPORTING
    input  = lv_time
  IMPORTING
    output = lv_time.

WRITE:/ 'Output:' , lv_time.

CALL FUNCTION 'CONVERSION_EXIT_TIMEA_INPUT'
  EXPORTING
    input  = lv_time
  IMPORTING
    output = lv_time.

WRITE:/ 'Iutput:' , lv_time.

[Syntax|http://www.sapdb.org/7.4/htmhelp/48/0d8018b4f211d2a97100a0c9449261/content.htm]

[data type T|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3138358411d1829f0000e829fbfe/content.htm] = 6 cHARACTERS..

DATA TYPE TSEGTIMTYP = Char 10..

Edited by: J@Y on Jan 26, 2009 3:01 PM

0 Kudos

Hi J@Y ,

These exits are not doing anything???

0 Kudos

>

> I guess you cannot rely on this convertions..

Check the decelrations ... one is of type cahr 6 and another 10.. that is causing the problem

0 Kudos

Here is my code

data : begin of i_tbtco occurs 0,

JOBNAME like tbtco-JOBNAME,

JOBCOUNT like tbtco-JOBCOUNT,

STRTDATE like tbtco-STRTDATE,

ENDDATE like tbtco-ENDDATE,

STRTTIME(10)," like tbtco-STRTTIME,

ENDTIME(10)," like tbtco-ENDTIME,

end of i_tbtco.

open dataset dname for input in tet mode.

read dataset dname into rec_tbtco.

split rec_tbtco at '~' into

i_tbtco-JOBNAME

i_tbtco-JOBCOUNT

i_tbtco-STRTDATE

i_tbtco-ENDDATE

i_tbtco-STRTTIME

i_tbtco-ENDTIME

.

the time field in dataset is in the format e.g. 08:12:09

if the strttime and endtime in i_tbtco are like tbtco-strttime and endtime then it splits the record like

i_tbtco-strttime = 08:12:

the last 2 digits are gone for a toss. So I changed the fields in itab to char format, but I can not pass this to

FM - SD_CALC_DURATION_FROM_DATETIME, as this requires time format. So if I pass the time field value to a variable with type sy-uzeit or again like tbtco-strttime then again it assigns value by truncating it to 08:12:

So what is that I am missing???

0 Kudos

Hi Sam,

Sorry, I meant to say the internal format is 6 digits and external is 8.

The time format is quite more predictable than data format so this is my solution for you...

The charaters ":" are added for output presentation and shoul be removed when writing to a time field. You can achive it like this:


  DATA: p_in(8).
  DATA: p_out(8).
  DATA: l_time TYPE tbtco-strttime.

  p_in = '23:59:58'.
  write p_in.
  CONCATENATE p_in(2) p_in+3(2) p_in+6(2) INTO p_out.
  l_time = p_out.
  WRITE l_time.

you cannot concatenate directly into the date field as you'll get your error.

I apologize for my messy code, I would go to some detail about exactly what you've done wrong but I'm out of time by now

regards,

Edgar

sujeet2918
Active Contributor
0 Kudos

Hello Sam,

Check your table declaration for flat file.and see the data type of the same field where you are passing your final E_TDIFF.

Better you See your FM SD_CALC_DURATION_FROM_DATETIME. double click and see the declaration.

for the same field you change your final output table's declaration like below :

xyz LIKE TVRO-FAHZTD.

and pass your final value in this.

Have a Nice Day,

Sujeet.

Former Member
0 Kudos

I got some clues out of this , thank you.