BW contains many standard formulas which can be used in TRFN’s and RSPC’s. The main issue is that sometimes you need to know default values/data types.

All available formulas can be checked in class CL_RSAR_FUNCTION. Bellow, you can find a table with explained importing and returning parameters.

Formula / Method NameDescriptionImporting
Types
(Example)
Returning
Types
(Example
result)
ABORT_PACKAGEReturns exception
cx_rfso_abort_package to stop
processing
N/AN/A
ADD_TO_DATEAdd days to the specified dateDATS,INT
(20201201,1)
DATS
20201202
ALPHAAdd leading zeros base on
the provided length
STRING,INT
(123,5)
STRING
00123
CALMONTH_FISCPERConvert calendar month
to the fiscal period
CONDENSETrim text (left site)STRING
( 43)
STRING
‘43’
CONDENSE_NO_GAPSTrim text + remove spaces insideSTRING
( 43 55 33)
STRING
‘435533’
DATECONVChange date format to internalCHAR10,CHAR10,CHAR1
(12/07/1992,
MM/DD/YYYY,/)
DATS
19921207
DATE_DIFFCalculate differences between datesDATS,DATS
(20211212,20211215)
INT
3
DATE_FISCPER
DATE_FISCPER3
DATE_FISCYEAR
DATE_HALFYEARCheck if the date is in the first
or second part of the year
DATS
(20210212)
NUMC
1
DATE_MONTHGet the calendar month from the given dateDATS
(20201201)
NUMC
202012
DATE_MONTH2Get the month number from the given dateDATS
(20201201)
NUMC
12
DATE_QUATERGet the quarter from the given dateDATS
(20210909)
NUMC
20213
DATE_QUATER1Get the quarter number from the given dateDATS
(20210909)
NUMC
3
DATE_WEEKGet the week from the given dateDATS
(20210731)
NUMC
202130
DATE_WEEKDAYGet the day from the given dateDATS
(20211220)
STRING
Monday
DATE_WEEKDAY1Get the day number from given dateDATS
(20211220)
NUMC
1
more
DATE_YEARGet the year from the given dateDATS
(20210101)
NUMC
4
FIRST_WORKINGDAY_MONTHGet the first working day from the given date
and calendar
DATS,CHAR
(20210425,01)
DATS
20210401
FIRST_WORKINGDAY_YEARGet the first working day of the year
and calendar
DATS,CHAR
(20210525,01)
DATS
20210104
FISCPER_CALMONTH
FISCPER_FISCPER3
FISCPER_FISCYEAR
IFCheck condition -
If I_Arg1 = X then Arg2 else Arg3
BOOLEAN,ANY,ANY
(X,1,10)
ANY
1
IS_INITIALCheck if the string is initialANY
(’')
BOOLEAN
X
IS_INTEGERCheck if the string contains
only integers
STRING
(9)
BOOLEAN
X
LAST_WORKINGDAY_MONTHGet the last working day from the given dateDATS,CHAR
(20210101,01)
DATS
20210129
LAST_WORKINGDAY_YEARGet the last working day of the year from
the date given
DATS,CHAR
(20210101,01)
DATS
20211231
LEFTGet the first X characters from the stringINT,STRING
(4,123456)
STRING
1234
LTRIMTrim text (left site),
by given regexp
STRING,STRING
( ABCD,\s)
STRING
‘ABCD’
L_TRIMTrim text (left site)STRING
( ABCD)
STRING
‘ABCD’
MAPPINGLooks like deprecated
- almost all code inside commented out
Result = Arg4
MONTH2_HALFYEARCheck if the month is in the first or second half of the yearANY
(202112) or (11)
NUMC
2
MONTH2_QUARTER1Check the quarter of the monthANY
(202208) or (08)
NUMC
3
MONTH_HALFYEARCheck if the month is in the first
or second half of the year.
ANY
(202112)
NUMC
2
MONTH2_QUARTER1Get the quarter based on the given dateANY
(202106) or (06)
NUMC
2
MONTH_HALFYEARCheck is given month in first or
second half of the year
ANY
(20211)
NUMC
2
MONTH_QUARTERCheck the quarter of the given monthANY
(202208)
NUMC
202003
MONTH_QUARTER1Check the quarter of the given monthANY
(202208)
NUMC
3
MONTH_YEARCheck the month of the given dateANY
(202111) or (20211125)
NUMC
2021
NEGATIVEReturn number with negative singF
(1)
F
-1
QUARTER1_HALFYEARCheck if given quarter is in first or
second half of the year
ANY
(202101)
NUMC
1
QUARTER_HALFYEARCheck if given quarter is in first or
second half of the year
ANY
(20214)
NUMC
2
QUARTER_QUARTER1Get the quarter from the given quarterANY
(20214)
NUMC
4
QUARTER_YEARGet the year from the given quarterANY
(20211)
NUMC
2021
REPLACE_ALLReplace selected charter
to different one
C,C,STRING
(4,9,A4B4C4)
STRING
A9B9C9
REPLACE_FIRSTReplace first occurrences of the
charters to different one
C,C,STRING
(4,9,A4B4C4)
STRING
A9B4C4
RIGHTGet first few numbers from rightI,STRING
(4,123456)
STRING
3456
RTRIMTrim white charters from right
based on provided regexp
STRING,STRING
(ABC,\s)
STRING
‘ABC’
R_TRIM?C
(D)
STRING
D
SHIFT_LEFTRemove first few
charters from the left site
of the string more
I,STRING
(2,abcdef)
STRING
cdef
SHIFT_RIGHTAdd few
charters from the left site
of the string more
I,STRING
(2,abcdef)
STRING
’ abcdef'
SKIP_RECORDRaise CX_RSFO_SKIP_RECORD
exception to skip
processing of current record
N/AN/A
SKIP_RECORD_AS_ERRORRaise CX_RSFO_SKIP_RECORD
_AS_ERROR exception to
skip current record
processing with error
N/AN/A
STR_LENReturns the length of the stringSTRING
abcdef
INT
6
UNIT_CONVERSIONConvert unitsUNIT,UNIT,ANY
(TO,KG,100)
F
100000
UTC_LONG_TO_
LOCAL_DATE
Convert timestamp based on
selected timezone
to get the date
DEC,CHAR
(20161030053000,EST)
DATS
20161030
UTC_LONG_TO_
LOCAL_TIME
Convert timestamp based on
selected timezone
to get the hour
DEC,CHAR
(20161030053000,EST)
F
5.40
UTC_SHORT_TO_
LOCAL_DATE
Convert timestamp based on
selected timezone
to get the date
(same code like for long
version)
DEC,CHAR
(20161030053000,EST)
DATS
20161030
UTC_SHORT_TO_
LOCAL_TIME
Convert timestamp based on
selected timezone
to get the hour
DEC,CHAR
(20161030053000,EST)
TIMS
013000
WEEK_FIRST_DAYGet the first day of the weekNUMC
(202104)
DATS
20210125
WORKINGDAY_MONTHGet the number of working
days based on
month
DATS,CHAR,CHAR
(20211220,01,+)
INT
14
WORKINGDAY_YEARGet the number of working day
base on
year
DATS,CHAR,CHAR
(20211220,01,+)
INT
243

Explanations:

DATE_WEEKDAY1():
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
7 - Sunday

If the result of functions with names ending at ‘2’ is the same, then probably the version with 2 at the end can handle both inputs (with a year or without). MONTH2_QUARTER1 in the example is checking both month and a year + month :

 
 IF strlen( i_month ) EQ 6.
    l_month = i_month+4(2).
  ELSEIF strlen( i_month ) EQ 2.
    l_month = i_month.
  ELSE.
    RAISE EXCEPTION TYPE cx_foev_error_in_function.
  ENDIF.

MONTH_QUARTER1 is checking only the year + month like 202106

 
    l_check = i_month+4(2).
  IF l_check < '01' OR l_check > '12'.

    RAISE EXCEPTION TYPE cx_foev_error_in_function.
  ELSE.