Application Development and Automation 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: 
Read only

Find pattern ( number ) in a string.

Former Member
0 Likes
523

Hello experts,

In an internal table i have a field with value

'Spool request (number 0000012086) sent to SAP printer con_133'.

now from this, i wnat to get the number '0000012086' into a varaible g_num.

The value of the number in the table-filed will change dynamically.

how to use FIND in this case??

thanks.

Edited by: SAP USER on Aug 12, 2008 8:31 AM

Edited by: SAP USER on Aug 12, 2008 8:32 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
416

Hi,

In such messages location of number is fixed, hence instead of using FIND you can use offset to determine the number

l_message+22(10).

To check if you have captured number only USE TRY ...CATCH...ENDTRY

DATA : l_num type i.

TRY.

l_num = l_message+22(10).

CATCH CX_SY_CONVERSION_NO_NUMBER.

MESSAGE exxx(mess class) with 'cannot assign number'.

ENDTRY.

Regards,

Mohaiyuddin

2 REPLIES 2
Read only

Former Member
0 Likes
416

Hi,

You can get the spool number using system variable sy-spono.

assing sy-spono to g_num

regards

padma

Read only

Former Member
0 Likes
417

Hi,

In such messages location of number is fixed, hence instead of using FIND you can use offset to determine the number

l_message+22(10).

To check if you have captured number only USE TRY ...CATCH...ENDTRY

DATA : l_num type i.

TRY.

l_num = l_message+22(10).

CATCH CX_SY_CONVERSION_NO_NUMBER.

MESSAGE exxx(mess class) with 'cannot assign number'.

ENDTRY.

Regards,

Mohaiyuddin