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

Extracting partial string from a string - is it substring ?

Former Member
0 Likes
3,686

Hi ... I am trying to extract partial string from a variable.

Some how, I am not able to find substring function per what describe here :

http://help.sap.com/abapdocu/en/ABENSUBSTRING_FUNCTIONS.htm

wa_date = '20090304120346'.

V_DATE = SUBSTRING( val = WA_DATE off = 0 len = 4 ).

V_MONTH = SUBSTRING( val = WA_DATE off = 5 len = 2 ).

V_DATE = SUBSTRING( val = WA_DATE off = 7 len = 2 ).

I got compile error ...

Am I doing the right thing ? Thanks.

7 REPLIES 7
Read only

Former Member
0 Likes
958

Hello,

wa_date = '20090304120346'.

V_DATE = SUBSTRING( val = WA_DATE off = 0 len = 4 ).

V_MONTH = SUBSTRING( val = WA_DATE off = 5 len = 2 ).

V_DATE = SUBSTRING( val = WA_DATE off = 7 len = 2 ).

Try this


v_date = wa_date+00(04)
v_month = wa_date+04(02)
v_date = wa_date+06(02)

Hope its clear

Regards,

Mansi.

Read only

Former Member
0 Likes
958

Hi Davidku,

I am not sure about the function that you have mentioned below.

But, you need to use the Offset concept to extract the substring you want.

Seach SDN with the keyword Offset. You will get what you wanted.

Thanks,

Babu Kilari

Read only

uwe_schieferstein
Active Contributor
0 Likes
958

Hello David

As you can see in the upper right corner of the Webpage you mention this function is available in

NW AS ABAP Release 711

Are you already working on (basis) release >= 7.10?

Regards

Uwe

Read only

Former Member
0 Likes
958

Syntax is correct.

What error you are getting?

Read only

Former Member
0 Likes
958

Hi...

Try



V_DATE = WA_DATE+0(4).
V_MONTH = WA_DATE+5(2).
V_DATE = WA_DATE+7(2).

Hope this helps...

Regdrs,

Chintan.

Edited by: Chintan_SAP on Apr 28, 2009 9:03 AM

Read only

Former Member
0 Likes
958

Perfect ... it works. Thanks.

I am still confined to SQL server and Oracle type of programming.

Trying to find the function but it exist in another form.

V_DATE = wa_date+00(04).

V_MONTH = wa_date+04(02).

V_DATE = wa_date+06(02).

This method is known as offset ?

Read only

0 Likes
958

Yes. That is the Offset Concept

Thanks,

Babu Kilari