Friday, July 17, 2015

Passing Data Between Context Nodes.

Passing Data between SAME CONTEXT NODES:-



I want the content of attribute CF_REJECTED into ZAC1_ATTR.

 TRY.
*        dref = current->get_property( 'zac1_attr' )."#EC NOTEXT
        dref = current->get_property( 'CF_REJECTED' )."#EC NOTEXT


      
CATCH cx_sy_ref_is_initial.
        
RETURN.
    
ENDTRY.

    
IF dref IS NOT BOUND.

      
value = 'Testing in progress'."#EC NOTEXT

      
RETURN.
    
ENDIF.
    
TRY.
        
value = if_bsp_model_util~convert_to_string( data_ref = dref
                                    attribute_path = attribute_path ).
      
CATCH cx_bsp_conv_illegal_ref.
        
FIELD-SYMBOLS: <l_data> type DATA.
        
assign dref->* to <l_data>.
*       please implement here some BO specific handler coding

*----------------------------------------------------------------------------------------
ethod SET_ZAC1_ATTR.
    
DATA:
      current 
TYPE REF TO if_bol_bo_property_access,
      dref    
TYPE REF TO data,
      
copy    TYPE REF TO data.

    
FIELD-SYMBOLS:
      <nval> 
TYPE ANY,
      <oval> 
TYPE ANY.

*   get current entity
    
if iterator is bound.
      current = iterator->get_current( ).
    
else.
      current = collection_wrapper->get_current( ).
    
endif.

*   get old value and dataref to appropriate type

    
TRY.
    dref = current->get_property( 
'zac1_attr' )."#EC NOTEXT
      
CATCH cx_sy_ref_is_initial.
        
RETURN.
    
ENDTRY.


*   assure that attribue exists
    
CHECK dref IS BOUND.

*   set <oval> to old value
    
ASSIGN dref->* TO <oval>.
*   create a copy for new value
    
CREATE DATA copy LIKE <oval>.
*   set <nval> to new value
    
ASSIGN copy->* TO <nval>.

*   fill new value using the right conversion
    
TRY.
*        TRY.
        
CALL METHOD if_bsp_model_util~convert_from_string
          
EXPORTING
            data_ref       = 
copy
            
value          = value
            attribute_path = attribute_path.
*        CATCH cx_bsp_conv_illegal_ref.
*          FIELD-SYMBOLS: <l_data> type DATA.
*          assign copy->* to <l_data>.
*         please implement here some BO specific handler coding
*         conversion of currency/quantity field failed caused by missing
*         unit relation
*         Coding sample:
*         provide currency for currency fields or decimals for quantity (select from T006).
*          cl_bsp_utility=>instantiate_simple_data(





DIFFERENT CONTEXT NODES:-
Both nodes have same value.
ZAC1_ATTR = OLBERT
And also Created By = OLBERT.






My first zattribute is in BTSTATUSHSUM (ZAC_ATTR) node and second one in BTADMINH (USER_NAME) node.
To do this we won’t use getter setter method. We will use do_prepare_output of the class.
Impl_class.


method DO_PREPARE_OUTPUT.
**CALL METHOD SUPER->DO_PREPARE_OUTPUT
***  EXPORTING
***    IV_FIRST_TIME = ABAP_FALSE
***    .
  
data: lr_entity_o type ref to if_bol_bo_property_access.
  
data: lr_entity_n type ref to if_bol_bo_property_access.
**
data: lv_uname type sy-uname.

*----------------------------------------------------------------
  lr_entity_o = me->ztyped_context->btadminh->collection_wrapper->get_current( ).


lv_uname = 
lr_entity_o->get_property_as_string( IV_ATTR_NAME = 'CREATED_BY' ).


*----------------------------------------------------------------
 lr_entity_n ?=
 me->ztyped_context->BTSTATUSHSUM->collection_wrapper->get_current( ) .
     
lr_entity_n->set_property (
                      iv_attr_name = 
'zac1_attr' "#EC NOTEXT
                      iv_value     = lv_uname).
*-----------------------------------------------------------------

endmethod.

Thursday, October 2, 2014

Passing Data Between Context Nodes.

Passing Data between SAME CONTEXT NODES:-



I want the content of attribute CF_REJECTED into ZAC1_ATTR.

 TRY.
*        dref = current->get_property( 'zac1_attr' )."#EC NOTEXT
        dref = current->get_property( 'CF_REJECTED' )."#EC NOTEXT


      
CATCH cx_sy_ref_is_initial.
        
RETURN.
    
ENDTRY.

    
IF dref IS NOT BOUND.

      
value = 'Testing in progress'."#EC NOTEXT

      
RETURN.
    
ENDIF.
    
TRY.
        
value = if_bsp_model_util~convert_to_string( data_ref = dref
                                    attribute_path = attribute_path ).
      
CATCH cx_bsp_conv_illegal_ref.
        
FIELD-SYMBOLS: <l_data> type DATA.
        
assign dref->* to <l_data>.
*       please implement here some BO specific handler coding

*----------------------------------------------------------------------------------------
ethod SET_ZAC1_ATTR.
    
DATA:
      current 
TYPE REF TO if_bol_bo_property_access,
      dref    
TYPE REF TO data,
      
copy    TYPE REF TO data.

    
FIELD-SYMBOLS:
      <nval> 
TYPE ANY,
      <oval> 
TYPE ANY.

*   get current entity
    
if iterator is bound.
      current = iterator->get_current( ).
    
else.
      current = collection_wrapper->get_current( ).
    
endif.

*   get old value and dataref to appropriate type

    
TRY.
    dref = current->get_property( 
'zac1_attr' )."#EC NOTEXT
      
CATCH cx_sy_ref_is_initial.
        
RETURN.
    
ENDTRY.


*   assure that attribue exists
    
CHECK dref IS BOUND.

*   set <oval> to old value
    
ASSIGN dref->* TO <oval>.
*   create a copy for new value
    
CREATE DATA copy LIKE <oval>.
*   set <nval> to new value
    
ASSIGN copy->* TO <nval>.

*   fill new value using the right conversion
    
TRY.
*        TRY.
        
CALL METHOD if_bsp_model_util~convert_from_string
          
EXPORTING
            data_ref       = 
copy
            
value          = value
            attribute_path = attribute_path.
*        CATCH cx_bsp_conv_illegal_ref.
*          FIELD-SYMBOLS: <l_data> type DATA.
*          assign copy->* to <l_data>.
*         please implement here some BO specific handler coding
*         conversion of currency/quantity field failed caused by missing
*         unit relation
*         Coding sample:
*         provide currency for currency fields or decimals for quantity (select from T006).
*          cl_bsp_utility=>instantiate_simple_data(





DIFFERENT CONTEXT NODES:-
Both nodes have same value.
ZAC1_ATTR = OLBERT
And also Created By = OLBERT.






My first zattribute is in BTSTATUSHSUM (ZAC_ATTR) node and second one in BTADMINH (USER_NAME) node.
To do this we won’t use getter setter method. We will use do_prepare_output of the class.
Impl_class.


method DO_PREPARE_OUTPUT.
**CALL METHOD SUPER->DO_PREPARE_OUTPUT
***  EXPORTING
***    IV_FIRST_TIME = ABAP_FALSE
***    .
  
data: lr_entity_o type ref to if_bol_bo_property_access.
  
data: lr_entity_n type ref to if_bol_bo_property_access.
**
data: lv_uname type sy-uname.

*----------------------------------------------------------------
  lr_entity_o = me->ztyped_context->btadminh->collection_wrapper->get_current( ).


lv_uname = 
lr_entity_o->get_property_as_string( IV_ATTR_NAME = 'CREATED_BY' ).


*----------------------------------------------------------------
 lr_entity_n ?=
 me->ztyped_context->BTSTATUSHSUM->collection_wrapper->get_current( ) .
     
lr_entity_n->set_property (
                      iv_attr_name = 
'zac1_attr' "#EC NOTEXT
                      iv_value     = lv_uname).
*-----------------------------------------------------------------

endmethod.