cancel
Showing results for 
Search instead for 
Did you mean: 

How to increment string value by 1 (It's very very urgent)

Former Member
0 Kudos

Dear Sap Guru's

i have a problem that i don't able to increment the string value by 1...

plijjj sent me code for this problem immidiatly..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Is in the string variable numeric value? If yes, convert it first to numeric and then add 1 to it.

If is it for example as 'XXXX002' and you want to convert it, use right function for last 3 digits, convert to numeric and add 1. For example

'XXX' + cstr(clng(right('XXXX002', 3)) + 1)

Edited by: Petr Verner on Jun 30, 2008 4:28 PM

Former Member
0 Kudos

if my string is "INV20001A" then what's tha code

former_member201110
Active Contributor
0 Kudos

Hi,

Please don't mark your posts as urgent. It is against the forum rules and your post can be removed. Everyone's questions are considered equal. The people on this forum are always helpful and will try to give an answer within a reasonable time period so there is no need to say that you need an immediate answer. If you do have an urgent issue then you should log it with SAP support.

Kind Regards,

Owen

Former Member
0 Kudos

Hi Sam,

It really depends how the string code is built. In the case of the string "INV20001A" you can get the numeric part first. Example:

Mid$("INV20001A", 4, 5)

Then parse that string to integer add 1 and parse it back to the string and add the string part to the code.

Regards,

Friederike.

Answers (1)

Answers (1)

Former Member
0 Kudos

Here.


Dim s As String = "00000076"
Dim i As Integer
i = Integer.Parse(s) + 1
s = i.ToString("00000000")
Console.Write(i)