SAP CRM — PPR Factsheet

This post is from my friend Juan Pedro Vargas Fernández. He did some sample for factsheet in his project and he is very kind to let me post his documentation about the factsheet on this blog. So I thank him for that.

You can follow him at @ :  http://twitter.com/juanpedrov

  • 10) Implement the event ON_NEW_FOCUS

ppr_factsheet_image033

ppr_factsheet_image028

Set attributes

ppr_factsheet_image002

Set import parameter

ppr_factsheet_image004

Write the code necessary to retrieval data, for this example:

 

method ON_NEW_FOCUS.

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
lv_bp_guid type BU_PARTNER_GUID,

lr_col type ref to if_bol_bo_col, ” collection to fill node zppr_item_s
lr_valuenode type ref to cl_bsp_wd_value_node, ” value nodes to fill a collection
lr_tabline type ref to zppr_item_s, ” table line reference to fill value node
lt_ppr type zppr_t, ” local table with data from PPR zppr_t
ls_ppr type zppr_item_s. ” local structure of table above

* get partner entity and partner number
try.
lr_entity ?= focus_bo.
catch cx_sy_move_cast_error.
return.
endtry.
lv_bp_nr = lr_entity->get_property_as_string( ‘BP_NUMBER’ ).
if lv_bp_nr is initial. ” no partner…
return. “…return without selection
endif.

* get partner product rage for particular business partner
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT = lv_bp_nr
IMPORTING
OUTPUT = lv_partner.

SELECT SINGLE PARTNER_GUID INTO lv_bp_guid
FROM BUT000
WHERE PARTNER = lv_partner.

SELECT DISTINCT
mh~GUID “PPR guid
mi~PRP_I_ID “PPR id
mi~PRP_I_TYPE “PPR type
mi~PRP_I_EXCLUSION
mi~PRP_REFERENCE
mi~PARENT_GUID
si~TIMESTAMP_LOW “valid from
si~TIMESTAMP_HIGH “valid to
ct~PRODUCT_GUID “Product guid
INTO CORRESPONDING FIELDS OF TABLE lt_ppr
FROM ( ( ( ( ( CRMM_PRPADM_H AS mh
INNER JOIN CRMM_PRPADM_I AS mi ON
mi~parent_guid = mh~guid )
INNER JOIN CRMM_PRP_BUPA_I AS ai ON
ai~parent_guid = mi~guid )
INNER JOIN CRMM_PRP_PROD_I AS di ON
di~parent_guid = mi~guid )
INNER JOIN COMM_PRODUCT AS ct ON
ct~product_guid = di~product_ref_guid )
INNER JOIN CRMM_PRP_TS_I AS si ON
si~parent_guid = mi~guid )
WHERE ( mh~prp_status = ‘1’ OR mh~prp_status = ‘2’ ) AND
ai~bupa_ref_guid = lv_bp_guid.

* get product text
LOOP AT lt_ppr INTO ls_ppr.

ls_ppr-valid_from = ls_ppr-timestamp_low.
ls_ppr-valid_to = ls_ppr-timestamp_high.

SELECT SINGLE SHORT_TEXT INTO ls_ppr-short_text
FROM COMM_PRSHTEXT
WHERE product_guid = ls_ppr-product_guid AND
langu = sy-langu.

MODIFY lt_ppr FROM ls_ppr.
ENDLOOP.

* create collection object to transfer data
create object lr_col
type
cl_crm_bol_bo_col.

clear ls_ppr.
loop at lt_ppr into ls_ppr.
“…create line object
create data lr_tabline.
“…create value object with current line for colleciton
create object lr_valuenode
exporting
iv_data_ref = lr_tabline.
“…set current line data
lr_valuenode->set_properties( ls_ppr ).
“…add current line to collection
lr_col->add( lr_valuenode ).
endloop.

* set collection
me->set_collection( lr_col ).
endmethod.

 

 

  • 11) Call the event ON_NEW_FOCUS from the Inbound Plug DEFAULT
  • ppr_factsheet_image006

    method IP_DEFAULT.

    DATA:
    lv_entity TYPE REF TO cl_crm_bol_entity,
    lv_partner type bu_partner,
    coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper.

    * get main entity and place it in the collection wrapper
    lv_entity ?= iv_collection->get_first( ).
    CHECK lv_entity IS BOUND AND lv_entity->alive( ) = abap_true.
    me->typed_context->builheader->collection_wrapper->clear_collection( ).
    me->typed_context->builheader->collection_wrapper->add( iv_entity = lv_entity
    iv_set_focus = abap_true ).
    * lv_partner = lv_entity->get_property_as_string( ‘BP_NUMBER’ ).

    coll_wrapper = me->typed_context->builheader->get_collection_wrapper( ).
    TRY.
    lv_entity ?= coll_wrapper->get_current( ).
    CATCH cx_sy_move_cast_error.
    ENDTRY.
    IF lv_entity IS BOUND.
    * zpprt->on_new_focus( focus_bo = lv_entity ).
    me->typed_context->zpprt->on_new_focus( focus_bo = lv_entity ).

    ENDIF.
    endmethod.

    Advertisements

    2 thoughts on “SAP CRM — PPR Factsheet

      • i need to create a custom fact sheet with a assignment block and link for that has to be given in a navigation bar . once if you click that navigation bar the custom fact sheet has to be displayed. am relatively very new to crm. kindly help me in this aspect.

    Leave a Reply to Raj Cancel reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Google photo

    You are commenting using your Google account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )

    Connecting to %s