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: 

how to retrieve the Date field from the string

Former Member
0 Kudos

Hi,

i'm having problem in retrieving the date from a string where string always Contains pattern of some data followed by previously stored by mm/dd/yyyy like below:

<b>$5,000 w/o PO, $5,000 w/PO. $5,000 Purchase Req: $500

Previously stored text 4/19/2006 Yallas1

Testing for second version

Previously stored text 04/19/2006 EARNENK1</b>

this is to keep track of the changes, when it is changed and user who made the changes. so from this string i need to take the date and compare it with the date given in the select option date, if it matches, then display the data, for the above example

$5,000 w/o PO, $5,000 w/PO. $5,000 Purchase Req: $500

Testing for second version.

so can you sen me the sample code.

waiting for your reply,

priya

2 REPLIES 2

Former Member
0 Kudos

Hi, cek this sample code.

REPORT Z_JRQ015R NO STANDARD PAGE HEADING .

*----


  • D.A.T.A.

*----


DATA: STR TYPE STRING,

LDATE(10) TYPE C,

POS TYPE I,

LEN TYPE I.

*----


  • S.E.L.L.E.C.T.I.O.N. .S.C.R.E.E.N.

*----


PARAMETERS P_DATE TYPE SY-DATUM.

*----


  • I.N.I.T.I.A.L.I.Z.A.T.I.O.N.

*----


INITIALIZATION.

CONCATENATE

'$5,000 w/o PO, $5,000 w/PO. $5,000 Purchase Req: $500'

'Previously stored text 04/19/2006 Yallas1 '

'Testing for second version'

'Previously stored text 04/19/2006 EARNENK1'

INTO STR SEPARATED BY SPACE.

*----


  • M.A.I.N. .P.R.O.G.R.A.M.

*----


START-OF-SELECTION.

CONCATENATE P_DATE4(2) P_DATE6(2) P_DATE(4)

INTO LDATE SEPARATED BY '/'.

CONCATENATE 'Previously stored text' LDATE

INTO LDATE SEPARATED BY SPACE.

FIND LDATE IN STR MATCH OFFSET POS MATCH LENGTH LEN.

IF SY-SUBRC = 0.

WRITE STR(POS).

ENDIF.

0 Kudos

Hi Rob,

thanks for the quick reply, the Date format will be as per sy-datum, i have to get remaining test into another field (excluding the previously stored by xx.xx.xxxx every time, that is for internal purpose, no need to display) so that if the date(date is selection screen, that is little bit problematic, we have take care of the ranges, unlike parameter) matches, i've to display that text. all the data i'm getting is given by FM 'READ_TEXT'. for a given object number we can get any amount of data, we have to take the data which only fits in that date criteria. hope i am clear this time.

thanks,

Priya