CRM and CX Blogs by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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.
data:
          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'
    exporting
      it_header_guid       = lt_header_guids
      it_requested_objects = lt_request_objs
      iv_no_auth_check     = 'X'
    importing
      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
    exceptions
      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: http://scn.sap.com/community/crm/blog/2013/02/07/crmordermaintain-simple-example-to-create-an-order-...

and

http://scn.sap.com/community/crm/blog/2013/02/07/crmordermaintain-simple-example-to-update-an-order-...

8 Comments