Create a new assignment block
I am new in the topic SAP CRM Web Client and I have to create a new assignment block for the accounts site.
In this assignment block you should see the last ten orders of the account. I already have the code to get the data from the tables. But I have no idea how to show this in a new assignment block. Can anybody help me, please? Or do you know a good document, where the process is described?
I have the book SAP CRM Web Client Customizing and Development. So I've understood the basics. But it was not really helpful for my project.
So help me, please.
Thanks and regards,
Assignment block is nothing but a view. So you need to create one view with view type as Table view. Columns of the table would be the value attributes of the view. Write the population logic in ON_NEW_FOCUS method of the CNxx class associated with the view you created.
You can refer following code to get the TABLE View populated -->
data: lr_wrapper type ref to cl_bsp_wd_collection_wrapper, " BP collection wrapper
lr_entity type ref to if_bol_bo_property_access, " wrapper entity
lv_bp_nr type string, " BP (business partner) number as string
lv_partner type bu_partner, " BP number in correct format (for RFC call)
ls_smof_erpsh type smof_erpsh, " structure of the RFC destination
lr_col type ref to if_bol_bo_col, " collection to fill node ZBP_FAVS
lr_valuenode type ref to cl_bsp_wd_value_node, " value nodes to fill a collection
lr_tabline type ref to zbp_favs_s, " table line reference to fill value node
lt_favs type zbp_favs_tab, " local table with data from ERP-table ZBP_FAVS
ls_favs type zbp_favs_s. " local structure of table above
get partner entity and partner number
lr_entity ?= focus_bo.
lv_bp_nr = lr_entity->get_property_as_string( 'BP_NUMBER' ).
if lv_bp_nr is initial. " no partner...
return. "...return without selection
get RFC destination of ERP system, if needed
if ZL_ZBP_FAVS_ZBPFAVORITES_IMPL=>gv_destination is initial.
call function 'CRM_GET_ERP_SYSTEM'
es_smof_erpsh = ls_smof_erpsh.
if sy-subrc = 0 and ls_smof_erpsh-rfcdest is not initial.
ZL_ZBP_CUCL_ZCURRENCYCLAU_IMPL=>gv_destination = ls_smof_erpsh-rfcdest.
get favorite things for partner
lv_partner = lv_bp_nr. " call RFC function in ERP system
call function 'Z_CRM_GET_FAVS_FOR_BP'
iv_partner = lv_partner
et_favs = lt_favs
others = 4.
if sy-subrc <> 0.
" should never happen
create collection object to transfer data
create object lr_col
loop through all found data...
loop at lt_favs into ls_favs.
"...create line object
create data lr_tabline.
"...create value object with current line for colleciton
create object lr_valuenode
iv_data_ref = lr_tabline.
"...set current line data
lr_valuenode->set_properties( ls_favs ).
"...add current line to collection
lr_col->add( lr_valuenode ).
me->set_collection( lr_col ).