cancel
Showing results for 
Search instead for 
Did you mean: 

BRF+ - Number to timepoint conversion

Former Member
0 Kudos

Hi all,

I need to calculate the difference in days between two timestamps.

These timestamps are from table GRFNMWRTINST and are appearing as 'Number' data elements instead of 'Timepoint' data elements in BRF+.

So, when I try to use the function DT_DURATION_DIFF_INT_DAYS, I get the following error message:

"Incorrect parameter type Number supplied for function DT_DURATION_DIFF_INT_DAYS, expected type timepoint.

Is there a function to convert number to timepoint ? (I couldn't find a suitable one.) If not, what is the simplest way to calculate the difference in days between the two timestamps.

Accepted Solutions (1)

Accepted Solutions (1)

christianlechne
Active Contributor
0 Kudos

Hi,

there is not function to transfer a number to a timepoint. You have several options to overcome that issue:

  • If you have the parameter in the signature of the BRFplus function you can do the movement in ABAP and use a BRFplus timepoint data element (my preferred option)
  • You can transfer a string to a timepoint by using the formula function STRING_TO_TIMEPOINT
    So you would have to import the timestamp as a string in the correct format (see documentation to the formula function)
  • You can tranfer the single elements of a timestamp using the DT_SET_PART_* formula function. For this you have to split the number first into the corresponding parts of a timestamp

Unfortunatly no direct way to achieve your goal (at least none I know).

BR

Christian

Former Member
0 Kudos

Hi Christian,

thanks for reply.

When i choose "Show" Documentation for STRING_TO_TIMEPOINT in BRF+ workbench I get the error : 

"SAPScript documentation is not available for this object"

  No documentation to display"

And having trouble with DT_SET_PART_* as it requires input in timepoint format and it doesn't seem to be accepting a manually keyed in timepoint to begin with even if it is in the format specified in the documenation. So can't proceed to picking out the corresponding part from the number..

anindyaSAP
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Ranjith,

Please use STRING_TO_TIMEPOINT along with DT_SET_PART_DAYS to pass TP in correct format.

Example, DT_SET_PART_DAYS ( STRING_TO_TIMEPOINT ( '2010-06-25T12:34:56' ) , 15 )

Hope this works for you.

BR,

Anindya


christianlechne
Active Contributor
0 Kudos

Hi,

concnerning the error when opening the help -> you have to get in touch with your SAP basis team, as this indicates that something is not installed that should be installed or you are missing a note

I attached the help as a screenshot

Concerning the usage of the formula functions you have to do it as Anindya states, nevertheless you have to import a string and not a number.

As mentioned in my first answer: Is the option to transform the data before calling BRFplus not feasible for you?

BR

Christian

Former Member
0 Kudos

Hi Christian & Anindya,

Thanks for the inputs. Used a combination of:

DT_DURATION_DIFF_INT_DAYS

STRING_TO_TIMEPOINT

SUBSTRING

to get the required result  Final formula and output below:

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Well done... but you might want to consider bundling that up into a custom formula function if you need to do it more than once.  They are quick to create and would make the formula much more readable.

Rgds,

Jocelyn

Former Member
0 Kudos

Footnote update for the benefit of future readers with similar requirement:

I was not aware of this function STRING_TO_TIMEPOINT as it was not appearing in my list of functions in the BRF+ workbench.

Had to get an OSS note installed for this to be available.

Note 1965274: BRF+ : Downport of formula functionals

Symptom

Within the formula expression the functiona string_to_amount, string_to_quantity and string_to_timepoint are missing.

Answers (0)