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: 

Reverse string and Date function

Former Member
0 Kudos

Hi how to use String_Reverse fn? what is the function used to find the difference between date?Please provide steps to use or give a simple example.

5 REPLIES 5

Former Member
0 Kudos

There is no FM i guess for reversing so u hav to write a logic for dat

For date u can use

FM CALCULATE_DATE

Hope it helps..reward if it does

Message was edited by:

Prashant H Gupta

Former Member
0 Kudos

Hi,

Use the FM SD_DATETIME_DIFFERENCE (Gives the difference in Days and Time for 2 dates )

Hope this helps.

Reward if helpful.

Regards,

Sipra

Former Member
0 Kudos

Hi,

To reverse the string use FM STRING_REVERSE and to get the date difference use the FM HR_SGPBS_YRS_MTHS_DAYS.

See below the Code for string reverse.

data : name(20) type c value 'ABAP'.

data : name_rev(20) type c.

CALL FUNCTION 'STRING_REVERSE'

EXPORTING

string = name

lang = 'E'

IMPORTING

RSTRING = name_rev

EXCEPTIONS

TOO_SMALL = 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 .

write : name_rev.

For difference between two dates.

data : date1 like sy-datum,

date2 like sy-datum,

diff(10 ) type c.

date1 = '20071003'.

date2 = '20071104' .

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

I_DATUM_BIS = date1

I_DATUM_VON = date2

  • I_KZ_EXCL_VON = '0'

  • I_KZ_INCL_BIS = '0'

  • I_KZ_ULT_BIS = ' '

  • I_KZ_ULT_VON = ' '

  • I_STGMETH = '0'

  • I_SZBMETH = '1'

IMPORTING

E_TAGE = diff

EXCEPTIONS

DAYS_METHOD_NOT_DEFINED = 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,

Sriram Ponna.

Clemenss
Active Contributor
0 Kudos

Hi Khanna,

you may use the forum search function. 5 pages for topic String_Reverse are avaliable.

If any questions remain, feel free to ask more specific.

Regards,

Clemens

varma_narayana
Active Contributor
0 Kudos

Hi...

Check the following code for subtract years/months/date from particular date:

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

reward if Helpful.