The following code snippet shows how to use the CRM Reporting Framework in order to search for 1Order documents for a Business Partner.

Code Snippet(s)


* Name of the search result structure, see table crmc_q1o_obj.
  lc_result_structure_name TYPE struname,

* Structure description (RTTS) of the result structure.
  lr_struc_type_descr      TYPE REF TO cl_abap_structdescr,
* Table description (RTTS) of the result table.
  lr_table_type_descr      TYPE REF TO cl_abap_tabledescr,
  lr_data_ref              TYPE REF TO data,

* Use for specifying a kind of search term.
  lt_search_tab            TYPE  crmt_name_value_pair_tab,
* (see above)
  ls_search_entry          TYPE  crmt_name_value_pair,
* The GUIDs of the objects found corresponding to the
* seatch term(s).
  lt_guidlist_search       TYPE  crmt_bsp_objectkey_tab,
  lt_return                TYPE bapiret2_tab,
  lv_partner_message       TYPE crmt_boolean.

FIELD-SYMBOLS: <fs_result> TYPE any,
               <fs_result_tab> TYPE STANDARD TABLE.

PARAMETERS: p_partno TYPE but000-partner.

lc_result_structure_name = 'CRMST_QUERY_R_1ORDER_BTIL' ##NO_TEXT.

* Get a description of the result structure.
lr_struc_type_descr ?= cl_abap_structdescr=>describe_by_name( lc_result_structure_name ). "#EC NOTEXT
CREATE DATA lr_data_ref TYPE HANDLE lr_struc_type_descr.
ASSIGN lr_data_ref->* TO <fs_result>.
lr_table_type_descr = cl_abap_tabledescr=>create( lr_struc_type_descr ).
CREATE DATA lr_data_ref TYPE HANDLE lr_table_type_descr.
ASSIGN lr_data_ref->* TO <fs_result_tab>.

ls_search_entry-name = 'BU_PARTNER' ##NO_TEXT.
ls_search_entry-value = p_partno.
INSERT ls_search_entry INTO TABLE lt_search_tab.

* Search for all objects.
    it_search_tab      = lt_search_tab
    et_guidlist        = lt_guidlist_search
    et_return          = lt_return
    ev_partner_message = lv_partner_message
    date_not_correct   = 1
    no_card_type       = 2
    no_card_no         = 3
    no_program_id      = 4
    OTHERS             = 5.

IF sy-subrc <> 0.

* Read the found results.
    it_object_key            = lt_guidlist_search
    iv_screen_structure_name = lc_result_structure_name
    iv_refresh_headeredition = abap_false
    iv_call_authority_badi   = abap_false
    iv_avoid_authorization   = abap_true
    et_screen_structure      = <fs_result_tab>.


Looking at table CRMC_Q1O_OBJ you will find out that there are several entries for ‘BTQ1ORDER’ which refers to 1Order. Without going into detail this tables provides the information what structure type will be used for the search result when querying for documents using ‘BTQ1ORDER’. This structure name is ‘CRMST_QUERY_R_1ORDER_BTIL’. If you don’t like to hard-code this you could thus, also provide a dynamic determination code.

Using this structure name we determine a structure as well as a table definition in order to get a field symbol for both. The actual query or search term is specified within itab ‘lt_search_tab’. It is just a key-value table. Function module CRM_BSP_OIC_1O_SEARCH_FROM_RF searches for all corresponding documents and returns their GUIDs. Function module CRM_BSP_OIC_1O_READ_FROM_RF is used to get information for each of the found search results. Here structure ‘CRMST_QUERY_R_1ORDER_BTIL’ comes again in play as the information gathered has exactly this structure.

Take a look into table CRMC_Q1O_OBJ. There are other objects to query for too.


Key Value
Software Component BBPCRM                                                                  
Requires Client-Side Software Library No
Code Snippet is OS dependent No
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply