Skip to Content
Author's profile photo Abhishek Periwal

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:

Declaration.PNG

Code.PNG

Also make sure to declare ls_duration with the type as defined above. If custom types are declared the method will return incorrect values.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      I just did the same way you explained.

      In the image below. Above is the code, then the debugger then on the right hand side the values from Table.

      Am I doing anything wrong? I will appreciate if you point out what am I doing wrong.

      Untitled.png

      Author's profile photo Former Member
      Former Member

      Hi Mansoor,

      Have you resolved this issue with the duration data? I have exactly the same problem when trying to extract duration data.

      Regards,

      John

      Author's profile photo Former Member
      Former Member

      Hi Abhishek,

      I am also having the same requirement, I debugged CRM_DATES_READ_SINGLE_OW and finally found the code where standard is getting duration from txt_pub_id.

      I know it is very late response ;-), still this may save time for others who are facing this issue.

      Please find the below code for the same.
      data:
      ls_duration_rule TYPE crmt_date_duration_as_rule.

      field-symbols:
      <xvalue> type x,
      <xvalue_temp> type x,
      <xcontainer> type x.

      if iv_txt_pub_id CS 'DUR'.
      assign ls_duration_rule to <xvalue> casting.
      assign iv_txt_pub_id to <xcontainer> casting.
      <xvalue> = <xcontainer>.
      endif.

      "now will have duration in ls_duration_rule"

      Thanks and regards,
      Pramod Kumar Mandal.