CDS String Functions(Concat, Instr, Left / Right, Length, Lpad / Rpad, Ltrim / Rtrim ,Replace)

CDS String functions:
• CONCAT(arg1, arg2)
• LENGTH(arg)
• LPAD/RPAD(arg, len, src)
• REPLACE(arg1, arg2, arg3)
• SUBSTRING(arg, pos, len)

@AbapCatalog.sqlViewName: 'S4HCDS_SEL_VD14'
define view zcds_string_demo as select from sbook
{
  CONCAT( carrid, connid ) as FlightNo,
  CONCAT_WITH_SPACE(  carrid, connid, 10 ) as FlightNo_Spaces, 
  LENGTH( carrid ) as Carrid_Length,
  LPAD( carrid, 10, 'x' ) as Lpad_Carrid, 
  REPLACE( carrid, 'GHI', 'XXX' ) as Replace_Carrid, 
  bookid as BookingID,
  CONCAT( CONCAT( SUBSTRING(order_date,5,2), '-'),SUBSTRING(order_date,1,4) ) as OrderMonth,
  LPAD( connid, 13, '0' ) as New_connid
 }

 

Advertisement

Leave a Comment