2.0 - Creating A Custom GenilBol Object Model
2.0 - Creating A Custom GenilBol Object Model
Referências:
https://wiki.scn.sap.com/wiki/display/CRM/
Extend+BOL+Model+BT+with+custom+table+type+relationship?
original_fqdn=wiki.sdn.sap.com
http://saptechnical.com/Tutorials/CRM/WEBUI/Index.htm
https://archive.sap.com/discussions/thread/3353104
http://blog.acorel.nl/2013/07/adding-custom-assignment-block-on-sap.html
https://wiki.scn.sap.com/wiki/display/CRM/CRM+Web+Client+UI+Framework?
original_fqdn=wiki.sdn.sap.com
4- asas
Step 1 : Go to Transaction SE24 or SE80, Create a new abap Custom Genil Class
ZCL_CUSTOMER_MODEL
Maintain the entries for Component Definition, Component Set Definition and
Component Assignment.
a. a.) Click on Change button and Right Click on Root Objects -> Give Object
Name as Customer
Add Key Structure Name , Attribute structure name and Create structure name .
Keep Attribute Structure Property -in Changeable mode , So that while creating a
object you can see a list of fields in Change mode in Object Browser .
Step 5 : Open a custom genil class ZCL_CUSTOMER_MODEL and redefine all this
metohods as shown below.
Create a new custom class name as ZCL_CUSTOMER_API which will to hold the
API methods to retrieve data from database.
ZATTR_CUST_TAB ( Attribute
Declare GT_CUSTOMER as a global attributes
Structure of Customer ) of ZCL_CUSTOMER_API
IF_GENIL_APPL_INTLAY~CREATE_OBJECTS
METHOD if_genil_appl_intlay~create_objects.
* Creating a Guid.
CALL FUNCTION ‘GUID_CREATE’
IMPORTING
ev_guid_16 = lv_guid.
lv_key–guid = lv_guid.
lv_key–custno = lv_count.
ENDMETHOD.
METHOD CREATE_CUSTOMER.
lv_data–guid = is_cust_key–guid.
lv_data–custno = is_cust_key–custno.
lv_data–new = ‘C’.
rv_success = ‘X’.
ENDMETHOD.
IF_GENIL_APPL_INTLAY~GET_OBJECTS.
METHOD if_genil_appl_intlay~get_objects.
lv_root = iv_root_list->get_first( ).
IF lv_root->check_attr_requested( ) = abap_true.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD get_customer.
IF sy–subrc = 0.
IF <data>–new EQ ‘C’ OR <data>–new EQ ‘M’.
MOVE-CORRESPONDING <data> TO es_cust_attr.
RETURN.
ENDIF.
ENDIF.
ENDMETHOD.
IF_GENIL_APPL_INTLAY~MODIFY_OBJECTS
METHOD if_genil_appl_intlay~modify_objects.
lv_root = iv_root_list->get_first( ).
* Add into Object Table with Object Type and ID.
ENDIF.
ENDMETHOD.
METHOD change_customer.
IF_GENIL_APPL_ALTERNATIVE_DSIL~SAVE_OBJECTS
METHOD if_genil_appl_alternative_dsil~save_objects.
ENDMETHOD.
METHOD SAVE_CUSTOMER.
lv_success = ‘X’.
CHECK sy–subrc = 0.
CASE <customer_attr_n>–new.
WHEN ‘C’ OR ‘M’.
MOVE-CORRESPONDING <customer_attr_n> TO wa_cust.
MODIFY zmast_cust FROM wa_cust.
CLEAR cs_key.
ENDMETHOD. “SAVECUSTOMER
you can add you own custom logic to default set the value of the attributes
Here Guid and Custno is in display mode , while remaining atrributes are in
changeable mode – Enter the values of the Attributes.
and Check the database table ZMAST_CUST.
7.> Add Customer as a Model Node and a BOL entity -> Click on
Next till Complete.
8.> Double click on custom controller , you can see list of attributes
of a context node you added.
9.> Right Click on View and Create Over View Page name as
OverViewPage .
11.> Add Model Node and BOL entity as Customer and Bind it with
Custom Controller.
12.> Select a View Type form View as required and Click on
Complete.
13.> Click on Configuration Tab and Add the Available fields.
14.> Here you can change the field Properties using Hold down
ALT+Field.
15.> Next Step is assignment of View to OverViewPage.
16.> then Assign OverViewPage to Windows
19.> Here the fields are not bounded , to achieve this a custom bol
objects and created a custom genil class,
then first you have to laod that bol object and a component set , you can use this
code in Do_init_context method
so that initially when you run crm_ui , it will initailizes the component set and bol
objects.
* Define Buttons
ls_button–id = ‘Create’.
ls_button–text = ‘Create’.
ls_button–on_click = ‘Create’.
ls_button–enabled = abap_true.
ls_button–type = cl_thtmlb_util=>gc_icon_create.
APPEND ls_button TO gt_buttons.
ls_button–id = ‘Save’.
ls_button–text = ‘Save’.
ls_button–on_click = ‘Save’.
ls_button–enabled = abap_true.
ls_button–type = cl_thtmlb_util=>gc_icon_save.
APPEND ls_button TO gt_buttons.
ENDMETHOD.
23.> Here the fields are not bounded ,to achieve this a custom bol
objects and created a
custom genil class, then first you have to load that bol object and a component
set , you
can also use this code in Do_init_context so that initially when you run crm_ui , it
will initializes
METHOD eh_oncreate.
DATA : lr_core TYPE REF TO cl_crm_bol_core,
lr_fac TYPE REF TO cl_crm_bol_entity_factory,
lt_params TYPE crmt_name_value_pair_tab,
ls_params TYPE crmt_name_value_pair,
lr_ent TYPE REF TO cl_crm_bol_entity.
TRY.
* Add Parameters
me->typed_context->customer->collection_wrapper->add(
iv_entity = lr_ent ).
CHECK lr_ent->lock( ) = abap_true.
ENDIF.
CATCH cx_crm_genil_model_error.
EXIT.
CATCH cx_sy_ref_is_initial.
ENDTRY.
ENDMETHOD.
METHOD eh_onsave.
lr_customer ?= me->typed_context->customer-
>collection_wrapper->get_current( ).
ls_customer–custno = lv_custno.
lr_trans ?= lr_customer->get_transaction( ).
CHECK lr_trans IS BOUND.
CHECK lr_trans->check_save_possible( ) EQ abap_true.
lv_success = lr_trans->save( ).
IF lv_success = ‘X’.
lr_trans->commit( ).
ELSE.
lr_trans->rollback( ).
ENDIF.
ENDMETHOD.
25.> Open UI and Test the component -> Click on Create then Enter
the details