Added length and ancestor functions to SAP