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

substring function of SAP standard code not compiling

Former Member
0 Likes
1,103

The following code was copied from here:-

http://help.sap.com/abapdocu_702/en/abenstring_function_shift_abexa.htm
When I try to complile it gives syntax error:-
FIELD "STRLEN(" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

Could anyone please advice what is wrong....  We are on SAP ECC 6.0 with the following details:-

SAP_BASIS 701 0003 SAPKB70103 SAP Basis Component

SAP_ABA 701 0003 SAPKA70103 Cross-Application Component

PI_BASIS 701 0003 SAPK-70103INPIBASIS Basis Plug-In

ST-PI 2008_1_700 0005 SAPKITLRD5 SAP Solution Tools Plug-In

SAP_BS_FND 701 0003 SAPK-70103INSAPBSFND SAP Business Suite Foundation

SAP_BW 701 0003 SAPKW70103 SAP Business Warehouse

GRCPINW V1000_700 0007 SAPK-10307INGRCPINW SAP GRC NW Plug-in

SAP_AP 700 0015 SAPKNA7015 SAP Application Platform

*****************EXAMPLE CODE********************************

CLASS demo IMPLEMENTATION.

METHOD main.

DATA result TYPE string VALUE 'oo'.

WRITE result.

DO strlen( result ) / 2 - 1 TIMES.

result =

shift_left( val = substring( val = result

len = strlen( result ) / 2 )

circular = 1 ) &&

shift_right( val = substring( val = result

off = strlen( result ) / 2 )

circular = 1 ).

WRITE / result.

ENDDO.

DO strlen( result ) / 2 - 1 TIMES.

result =

shift_right( val = substring( val = result

len = strlen( result ) / 2 )

circular = 1 ) &&

shift_left( val = substring( val = result

off = strlen( result ) / 2 )

circular = 1 ).

WRITE / result.

ENDDO.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

demo=>main( ).

4 REPLIES 4
Read only

ThomasZloch
Active Contributor
0 Likes
815

Thanks for providing all relevant information (a huge exception, unfortunately).

You are on AS ABAP 701, however the example you are quoting is for 702. 702 introduced many new features, enhanced logic for expression positions being just one:

http://help.sap.com/abapdocu_702/en/abennews-71-expressions.htm

In your release, you will have to split your statements into several pieces, e.g.

DO strlen( result ) / 2 - 1 TIMES.

into something like

i = strlen( result ) / 2 - 1.

DO i TIMES.

and so on.

Thomas

Read only

0 Likes
815

Thank you for replying. Please can you advice how i can split this according to my version. The expression in bold is also giving similar error..or shall i say there is no substring function at all on 701? thanks alot in advance......

DATA  result TYPE string.
...
result = substring( val = 'ABCDEFGH' off = 2 len = 2 ).

Read only

0 Likes
815

Correct, only available from 702. Please read about the release specfic changes in the ABAP documentation (link aready known).

I guess above is the same as

val = 'ABCDEFGH'.

result = val+2(2).

Please try solving the other ones yourself.

Thomas

Read only

Former Member
0 Likes
815