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: 
yashoratna
Active Participant
0 Kudos
731
Summary: In my previous blog, I explained how to enable the GOS toolbar on the CRM billing document in SAP  GUI screen. In this blog, I'll capture the need to display the GOS toolbar's data and PDF attachments in the CRM Web-UI screen for improved user experience.


 

First step is the enhancement of standard BSP component BEABDH_BILLDOC, there we need to add new view let’s say ZGOSATTACH with value node (let’s say ZGOSVAL) and attributes as follows. (This is similar how we add custom view in standard component).


 

Which would be similar like below in CRM Web-UI screen


 
The next step is to fill the view with data, which is done in the method DO_INIT_CONTEXT of the Implementation class. 


The code snippet that would read data from specific billing document's GOS toolbar and fill every field in the  display at BOL layer is shown below.


* Structure to populate assignment view
TYPES: BEGIN OF x_gos_data,
brelguid TYPE os_guid, "Relationship Guid
instid_b TYPE sibfboriid, "Instance Ident. in BOR Compat. Persistent Object Referce
title TYPE iw_title, "Attachment Title
description TYPE bitm_descr, "Description (Like, Attachment, Note, URL)
value TYPE crm_rt_value, "Notes Content
created_by TYPE sgs_crname, "Attribute as Created By
creadate TYPE sgs_crdate, "Attribute as Created Date
creatime TYPE sgs_crtime, "Attribute as Created Time
END OF x_gos_data.

CONSTANTS : lc_appl_crmb TYPE bef_appl VALUE 'CRMB',
lc_catid_bo TYPE sibfcatid VALUE 'BO',
lc_rel_note TYPE oblreltype VALUE 'NOTE',
lc_rel_atta TYPE oblreltype VALUE 'ATTA',
lc_headno_ext TYPE name_komp VALUE 'HEADNO_EXT',
lc_objtype TYPE name_komp VALUE 'OBJTYPE',
lc_i TYPE char1 VALUE 'I',
lc_eq TYPE char2 VALUE 'EQ'.

DATA : lv_doc_data TYPE sofolenti1,
lo_ref_cuco TYPE REF TO cl_beabdh_b_cucobill_impl,
lo_ref_entity TYPE REF TO cl_crm_bol_entity,
lo_ref_struct TYPE REF TO x_gos_data,
li_obj_content TYPE STANDARD TABLE OF solisti1.

CALL METHOD super->do_init_context.

* Clear all the values from view initially
me->typed_context->zgosattach->collection_wrapper->clear( ).

DATA(lo_ref_core) = cl_crm_bol_core=>get_instance( ).
IF lo_ref_core IS BOUND.
TRY.
* Get Custom Controller to extract Billing Header details
lo_ref_cuco ?= get_custom_controller( 'BEABDH_BILLDOC/CuCoBill' ).
IF lo_ref_cuco IS BOUND.

* Extract current data from custom controller
lo_ref_entity ?= lo_ref_cuco->typed_context->bdheader->collection_wrapper->get_current( ).
IF lo_ref_entity IS BOUND.

* Get Billing Document and Object type
DATA(lv_billdocno) = lo_ref_entity->get_property_as_string( iv_attr_name = lc_headno_ext ).
DATA(lv_billobjtype) = lo_ref_entity->get_property_as_string( iv_attr_name = lc_objtype ).

IF lv_billdocno IS NOT INITIAL AND lv_billobjtype IS NOT INITIAL.
lv_billdocno = CONV bea_headno_ext( |{ lv_billdocno ALPHA = IN }| ).

* Populate
DATA(ls_object) = VALUE sibflporb( instid = lv_billdocno && lc_appl_crmb
typeid = lv_billobjtype
catid = lc_catid_bo ).

DATA(lt_relation_op) = VALUE obl_t_relt( ( sign = lc_i option = lc_eq low = lc_rel_note )
( sign = lc_i option = lc_eq low = lc_rel_atta ) ).
* Read the links against Billing Document to fetch all the GOS attachments
TRY.
CALL METHOD cl_binary_relation=>read_links
EXPORTING
is_object = ls_object
it_relation_options = lt_relation_op
IMPORTING
et_links = DATA(lt_links).

LOOP AT lt_links ASSIGNING FIELD-SYMBOL(<fs_links>).
CLEAR :lv_doc_data,
li_obj_content.

* Read the GOS attachments content and attributes to show in WebUI
DATA(lv_doc_id) = CONV so_entryid( <fs_links>-instid_b ).
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_doc_id
IMPORTING
document_data = lv_doc_data
TABLES
object_content = li_obj_content
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
IF sy-subrc EQ 0.
* Populate work area to show all the details
DATA(ls_gos_data) = VALUE x_gos_data( brelguid = <fs_links>-brelguid
instid_b = <fs_links>-instid_b
title = lv_doc_data-obj_descr
description = <fs_links>-reltype
value = CONV crm_rt_value( li_obj_content[ 1 ] )
created_by = lv_doc_data-creat_fnam
creadate = lv_doc_data-creat_date
creatime = lv_doc_data-creat_time ).
IF <fs_links>-reltype = lc_rel_atta.
CLEAR ls_gos_data-value.
ENDIF.
TRY.
* Create the value node and add the the same in collection wrapper
CREATE DATA lo_ref_struct.
IF lo_ref_struct IS BOUND.
DATA(lo_ref_value_node) = NEW cl_bsp_wd_value_node( iv_data_ref = lo_ref_struct ).
IF lo_ref_value_node IS BOUND AND ls_gos_data IS NOT INITIAL.
lo_ref_value_node->set_properties( ls_gos_data ).
me->typed_context->zgosattach->collection_wrapper->add( lo_ref_value_node ).
ENDIF.
ENDIF.
CATCH cx_sy_create_data_error.
CLEAR ls_gos_data.
CONTINUE.
ENDTRY.
CLEAR ls_gos_data.
ENDIF.
ENDLOOP.

*Modify BOL layer to get reflected the details in WebUI
lo_ref_core->modify( ).
CATCH cx_obl_parameter_error
cx_obl_internal_error
cx_obl_model_error
cx_sy_create_data_error .
RETURN.
ENDTRY.
ENDIF.
ENDIF.
ENDIF.

CATCH cx_sy_move_cast_error.
RETURN.
ENDTRY.
ENDIF.



As result, all the data from the GOS toolbar will be filled in and displayed in the WebUI screen as seen below.





My next blog post will discuss making a hyperlink to a specific PDF file and showing the PDF document in a popup window on the WebUI screen. Please keep reading along and leave us a comment if you have any suggestions or comments to share.



Thanks again for reading the document. I really appreciate your time.

Labels in this area
Top kudoed authors