10-15-2009 12:14 PM
Dear Experts,
Its regarding addition in character type variable. i hv defined a variable type c which takes the valu at runtime in a pattern D11K901841.Now while processing the rest of the report i need to increment the value by 1 .Like from D11K901841 to D11K901842. How can i acieve these. 1 cannot be added direstly as it is a type char.
Pls help me.
10-15-2009 12:40 PM
Hi ,
You can Achieve this Using The Below Code.
Data: w_cnt type i ,
w_num type i.
* Find the String length of the Character variable
w_cnt = strlen( w_name ) - 1.
w_num = w_name+w_cnt(1) + 1. " Increment the last Numeric Value in variable
w_name+w_cnt(1) = w_num. " Modify the Incremented value in Variable
With Regards
Kesavaperumal
10-15-2009 12:15 PM
Declare the variable of the type NUMC though you can add one even if it is of type CHAR
10-15-2009 12:23 PM
Hi Vikranth,
its not possible declare a variable of type numc in your program
and i think it wont work .
@ cenosure ,
check these links for some of the possible ways
link:[http://learningabap.wordpress.com/2007/10/29/auto-increment-function-with-alpha-numeric-support/]
10-15-2009 12:40 PM
Hi ,
You can Achieve this Using The Below Code.
Data: w_cnt type i ,
w_num type i.
* Find the String length of the Character variable
w_cnt = strlen( w_name ) - 1.
w_num = w_name+w_cnt(1) + 1. " Increment the last Numeric Value in variable
w_name+w_cnt(1) = w_num. " Modify the Incremented value in Variable
With Regards
Kesavaperumal
10-15-2009 1:00 PM
Hi,
I think the last solution should do the trick!
But i would like to advice to use a larger number: not only the last digit, but the entire string after the D11K:
w_cnt = strlen( w_name ) - 6.
w_num = w_name+w_cnt(6) + 1. " Increment the Numeric Value in variable
w_name+w_cnt(6) = w_num. " Modify the Incremented value in Variable
Good luck!
Regards, Miranda
10-25-2010 11:32 AM