on 2005 Sep 28 9:37 AM
I have earlier worked with Java and wonder now if there is any function in ABAP like "substring"?
hi, if you need the similiar functionality like 'substring' in ABAP, you can do like following:
DATA: strsrc type string.
strsrc = 'hello world.'.
DATA: substr type string.
substr = strsrc+0(5).
hope it will be helpful
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
may be CA or CP keyword will be useful to you
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Linn,
What do you want to achieve using substring? Then we can help you better and give the appropriate example.
-
Oops... should have read better. You want to take out month of a date. sasikumar palanichamy has provided a correct answer.
Message was edited by: Bas Jansen
Message was edited by: Bas Jansen
hi,
you can use find option
SEARCH f FOR g
DATA F(50).
MOVE 'Alaska Texas California' TO F.
SEARCH F FOR 'Clfrn' ABBREVIATED.
is it helpful?
sasi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
output = month+4(2).
Hope this helps. Many answered.
In addition to that read this
<u><b>Substring in SAP's ABAP programming</b></u>
Unlike many of the higher level languages there is no stand-alone substring call. We have split, shift, replace, translate and condense but no substring. So if we want to know the first four characters from the start of a field how do we do it?
The WRITE statement is what we use to substring a field. The syntax is as follows:
WRITE fieldname+starting_position(field_length) to variable
The fieldname is the source (or input). The plus sign precedes the starting position of the substring. IMPORTANT The traditional method of counting on computers is followed. The first position in the string is 0. Immediately after (no space) comes the length of the substring you are going to use. You can also substring the variable that you are writing the string to (the target). I have included an example that illustrates substringing on the source and target fields.
A real-life use of the substring functions
I needed to build a character date field for a cross-platform integration project I was working on. First, I defined the date field:
data: datechar(10).
To build the date lets use sy-datum, which has the current system date.
write SY-DATUM+4(2) to datechar+0(2).
write '/' datechar+2(1).
write SY-DATUM+6(2) to datechar+3(2).
write '/' TO datechar+5(1).
write SY-DATUM+0(4) to datechar+6(4).
Value of SY-DATUM 20010616
Here's how the field changes with the execution of each line.
06________
06/_______
06/16_____
06/16/____
06/16/2001
This is just one of the great functionalities of WRITE.
Kindly reward points and close the thread.
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.