Skip to Content
Author's profile photo Former Member

CRM_ORDER_READ simple example (for those new to CRM and/or ABAP)

When I first started writing ABAP in CRM I was confronted with CRM_ORDER_READ and CRM_ORDER_MAINTAIN, and learning how to use these took much longer that it should have due to lack of simple examples available. Looking back I don’t know where my confusion lay (it’s really simple!) but I know there was confusion and trouble, so I will try to be provide help to others that I wish I’d had.

The aim of this blog is to create a simple example for CRM_ORDER_READ and then I will write another blog for CRM_ORDER_MAINTAIN.

This blog will show you how to read an order, and read details about it such as and Notes, and Partners associated, the Status and all the other basic information.

include crm_object_names_con.
          lt_header_guids type crmt_object_guid_tab,
          ls_header_guids type crmt_object_guid,
          lt_orderadm_h type crmt_orderadm_h_wrkt,
          lt_opport_h type crmt_opport_h_wrkt,
          lt_status type crmt_status_wrkt,
          lt_text type crmt_text_wrkt,
          lt_partner type crmt_partner_external_wrkt,
          lt_service_os type crmt_srv_osset_wrkt,
          ls_orderadm_h like line of lt_orderadm_h,
          ls_opport_h like line of lt_opport_h,
          ls_status like line of lt_status,
          ls_text like line of lt_text,
          ls_partner like line of lt_partner,
          ls_service_os like line of lt_service_os,
          lt_request_objs type crmt_object_name_tab.
* 1. First you need to choose which tables you want to get back.
* In this example I want to read 6 tables, so I need to add them into the “request_objs” table
  insert gc_object_name-orderadm_h into table lt_request_objs.
  insert gc_object_name-opport_h into table lt_request_objs.
  insert gc_object_name-status into table lt_request_objs.
  insert gc_object_name-texts into table lt_request_objs.
  insert gc_object_name-partner into table lt_request_objs.
  insert gc_object_name-service_os into table lt_request_objs.
* 2. Second you need to make a table “lt_header_guids” with all the guids in that you want to read
* These GUIDs are stored as RAW16 type, in the table,
* so you may need to convert them from CHAR32
data: lv_guid_char type char32.
lv_guid_char = ’#32 char long GUID#’.
ls_header_guids = cl_ibase_service=>cl_convert_guid_32_16( lv_guid_char ).
append ls_header_guids to lt_header_guid.
*3. You’re now read to read! It’s that simple!
call function 'CRM_ORDER_READ'
      it_header_guid       = lt_header_guids
      it_requested_objects = lt_request_objs
      iv_no_auth_check     = 'X'
      et_orderadm_h        = lt_orderadm_h
      et_opport_h             = lt_opport_h
      et_text                     = lt_text
      et_partner                = lt_partner
      et_service_os          = lt_service_os
      et_status                  = lt_status
      document_not_found   = 1
      error_occurred       = 2
      document_locked      = 3
      no_change_authority  = 4
      no_display_authority = 5
      no_change_allowed    = 6.
* sy-subrc = 0 if the read was successful.
* If the read wasn’t it can mean that the GUID you entered isn’t valid/doesn’t exist.

For help with crm_order_maintain see:


Assigned Tags

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

      Very informative. Thanks a lot.

      Author's profile photo Former Member
      Former Member

      Good one . . thanks a lot 🙂

      Author's profile photo Arjun Pawar
      Arjun Pawar

      Good informative article...

      Author's profile photo Former Member
      Former Member


      I would like to add that you don't really need to provide the requested objects because this is automatically populated in the include LCRM_ORDER_APIF12 if you look into the code of the function module CRM_ORDER_READ.

      I would think the main use of the IT_REQUESTED_OBJETCS import parameter is when your are requesting all objects (implicitly) through the export parameters and you want to override the requesting of all Objects.

      Some use cases will be when you are building a framework on top of CRM_ORDER_READ where at design time you say you will read everything but at at runtime be selective on what objects you will read based on user interaction.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      You are correct - the tabel IT_REQUEST_OBJECTS is optional.

      However if you are considering performance, and are only earching for a few specific details in a few tables it is advisable to add in the request objects table to prevent anny unnecesary processing which might slow it down, would you agree?

      Author's profile photo Former Member
      Former Member

      Hi Lindsay

      It is not about being optional, the functional module CRM_OrDER_READ automatically populates this structure based on the export parameters you have requested. Please read into the code of CRM_ORDER_READ. It is in the first few lines.


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Ah yes, you are correct, I see now that it does populate the stucture for you.

      I just always populate it myself, as this does save (however small ammount of) time at runtime. But as Pran correctly says, this is not required!

      I imagine it would become useful when you are using the class for multiple purposes, so have it set up to export ALL tables. Then on a case by case basis you want to restrict this.


      Author's profile photo Former Member
      Former Member

      Very informative.. Thanks. 🙂