Tuesday, April 30, 2013

Abap substring

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 20130501
 
Here's how the field changes with the execution of each line.

05________
05/_______
05/01_____
05/01/____
05/01/2013