Duration value from SCAPPTSEG table
We are supporting an environment that primarily leverages Service Contracts and Orders and there is a requirement to download the details of first and last serviced customer for an entire list of Sold-To parties passed to the program in an flat file. This conversion program was facing major performance issues due to large volume of customers and use of function module CRM_ORDER_READ. We wanted to reduce the execution time of the program and replacing this FM with SELECT queries on each table helped tremondously. The performance of the program improved significantly and execution time went down to one third of original program.
One of the challenges we faced was to retrieve the duration value for Appointment Types of each Service Contract/Order. The FM CRM_ORDER_READ gets this data directly but using it was not an option due to performance reasons. We had to get this data from the table SCAPPTSEG that stores the dates as well as duration for each appointment type for transactions in SAP CRM. There is no specific field that gives this duration value right away. However the field SCAPPTSEG-TXT_PUB_ID can be used to retrieve the duration. It normally stores text in a particular format, e.g., DUR###氀MONTH BX#####. This data needs to be converted to get proper Duration values. We were able to successfully decode it by using the below code:
Also make sure to declare ls_duration with the type as defined above. If custom types are declared the method will return incorrect values.