‎2010 Jul 08 6:27 AM
hi, this is a sample i am trying out..
my java code is:
int i=100;
String mystring = "abcd";
String newstring = mystring + i + "xyz";
System.out.println(newstring); //this will print "abcd100xyz"
i++; //increament value of i by 1.
System.out.println(mystring + i); //this will print "abcd101"
for achieving this in abap,
i am using concatenate, but it does not allow the int type to be used in concatenate statement, and it is becoming more work to create intermediate string variables.
what could be an efficient and smallest chunk of code equivalent to above java code.
thanks in advance.
Madhu.
‎2010 Jul 08 6:50 AM
Try this:
DATA : ls_s TYPE string.
DATA : ls_n(3) TYPE n.
DATA: ls_s_new TYPE string.
DATA: ls_s_new_1 TYPE string.
ls_n = 100.
ls_s = 'abcd'.
CONCATENATE ls_s ls_n 'xyxz' INTO ls_s_new.
WRITE : ls_s_new.
ls_n = ls_n + 1.
CONCATENATE ls_s ls_n INTO ls_s_new_1.
WRITE : ls_s_new_1.
‎2010 Jul 08 6:40 AM
move your type I to string...and condense it..b4 Concatination
‎2010 Jul 08 6:50 AM
Try this:
DATA : ls_s TYPE string.
DATA : ls_n(3) TYPE n.
DATA: ls_s_new TYPE string.
DATA: ls_s_new_1 TYPE string.
ls_n = 100.
ls_s = 'abcd'.
CONCATENATE ls_s ls_n 'xyxz' INTO ls_s_new.
WRITE : ls_s_new.
ls_n = ls_n + 1.
CONCATENATE ls_s ls_n INTO ls_s_new_1.
WRITE : ls_s_new_1.
‎2010 Jul 08 7:41 AM
DATA : i(3) TYPE n VALUE 100,
mystring TYPE string VALUE 'abcd',
newstring TYPE string.
CONCATENATE mystring i 'xyz' INTO newstring. "this will print "abcd100xyz"
WRITE newstring.
i = i + 1.
CONCATENATE mystring i INTO mystring. "this will print "abcd101"
WRITE / mystring.