Get order attachments with bol programming

Method:

methods GET_ORDER_ATTACHMENTS
    importing
      !IV_GUID type CRMT_OBJECT_GUID
    returning
      value(RT_ATTACHMENT) type ZCRM_UI_S108_T .

 

Return type:

 

Source code: Basically we are gettng doc_key of attachments on the order to reach their content urls.

METHOD get_order_attachments.

    DATA: lr_entity       TYPE REF TO cl_crm_bol_entity,
          lr_entity_col   TYPE REF TO if_bol_entity_col,
          lr_qs           TYPE REF TO cl_crm_bol_query_service,
          lr_bol_core     TYPE REF TO cl_crm_bol_core,

          ls_cmbo_prop    TYPE crmt_cmic_rfolder_attr,
          ls_attr         TYPE crmt_cmic_doc_attr,
          ls_attachment   TYPE zcrm_ui_s108,

          lv_object_type  TYPE sibftypeid,
          lv_guid         TYPE crmt_object_guid,
          lv_content_type TYPE string,
          lv_key          TYPE string,
          lv_content_url  TYPE string,
          lv_host         TYPE string.

    lr_bol_core = cl_crm_bol_core=>get_instance( ).
    lr_bol_core->load_component_set( 'ONEORDER' ).

    lv_object_type = get_order_object_type( iv_guid )."BUS2000116

    lr_qs = cl_crm_bol_query_service=>get_instance( cl_crm_cm_genil_comp=>gc_query_bo_link ).

    ls_cmbo_prop-instid = iv_guid.
    ls_cmbo_prop-typeid = lv_object_type.
    ls_cmbo_prop-catid  = 'BO'.
                                                            "#EC NOTEXT
*   fill and fire query
    lr_qs->set_properties( ls_cmbo_prop ).
    lr_entity_col = lr_qs->get_query_result( ).

*   get attachements collection
    lr_entity ?= lr_entity_col->get_current( ).
    lr_entity_col ?= lr_entity->get_related_entities( iv_relation_name = 'CMBODocumentRefRel' ).

    lr_entity ?= lr_entity_col->get_first( ).

    CASE sy-sysid.
      WHEN 'XXX'.
        lv_host = 'http://xxx.com.tr'.
      WHEN 'YYY'.
        lv_host = 'http://yyy.com.tr'.
      WHEN 'ZZZ'.
        lv_host = 'http://zzz.com.tr'.
    ENDCASE.

    WHILE lr_entity IS BOUND.
      CLEAR ls_attr.

      lr_entity->get_properties( IMPORTING es_attributes = ls_attr ).

      CLEAR ls_attachment.
      ls_attachment-doc_key         = ls_attr-doc_key.
      ls_attachment-kw_relative_url = ls_attr-kw_relative_url.
      ls_attachment-content_type    = ls_attr-content_type.
      ls_attachment-filename        = ls_attr-filename.

      CALL METHOD cl_crm_cm_genil_comp=>gr_cm_control->get_content_url
        EXPORTING
          iv_key = ls_attachment-doc_key
        IMPORTING
          ev_url = ls_attachment-url_to_display.

      CONCATENATE lv_host ls_attachment-url_to_display INTO ls_attachment-url_to_display.

      APPEND ls_attachment TO rt_attachment.

      lr_entity ?= lr_entity_col->get_next( ).

    ENDWHILE.

  ENDMETHOD.

Result compared to bol browser

 

 

 

 

 

ABOUT Uğur Kaya

http://linkedin.com/in/kayau

RELATED POSTS

COMMENTS

comments powered by Disqus