Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
RashmiBR
Employee
Employee

Code snippet to be copy-pasted in the DEFINE method of Extended Model Provider class.

super->DEFINE( ).

DATA:
lo_entity  
type REF TO /IWBEP/IF_MGW_ODATA_ENTITY_TYP,
lo_property
type REF TO /IWBEP/IF_MGW_ODATA_PROPERTY.

lo_entity
= model->GET_ENTITY_TYPE( IV_ENTITY_NAME = 'EmployeePhoto' ).

IF lo_entity is BOUND.

  lo_property = lo_entity->GET_PROPERTY( IV_PROPERTY_NAME = 'ContentType' ).

  lo_property->SET_AS_CONTENT_TYPE( ).
ENDIF.

Code snippet to be copy-pasted in the

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM method of the Extended Data Provider class.

DATA: ls_stream    TYPE         ty_s_media_resource
     
,lo_api    TYPE REF TO  if_mr_api
     
,lv_entity_name TYPE  /IWBEP/MGW_TECH_NAME
     
,er_entity type REF TO DATA
     
,lr_entity TYPE REF TO DATA
     
,employeephotoset_get_entity TYPE ZCL_ZMEDIALNK_SB_MPC=>TS_EMPLOYEEPHOTO
     
,ls_content type table of TBL1024 initial size 0
     
,ls_xstring type xstring
     
,lt_messg type table of BAPIRET2 initial SIZE 0
     
,lv_pernr(8) TYPE n
     
,t_photo type table of TBL1024
     
,l_photo type XSTRING
     
,l_line type string
     
,l_photo1 type string
     
,ls_ret type BAPIRET2
     
,ls_photo type TBL1024
     
,t_msg type table of BAPIRET2.

lv_entity_name
= io_tech_request_context->GET_ENTITY_TYPE_NAME( ).

CASE lv_entity_name.
    

      WHEN 'EmployeeData'.
     
WHEN 'EmployeePhoto'.
     

     employeephotoset_get_entity(
          
EXPORTING iv_entity_name     = iv_entity_name
                     iv_entity_set_name
= iv_entity_set_name
                     iv_source_name    
= iv_source_name
                     it_key_tab        
= it_key_tab
                     it_navigation_path
= it_navigation_path
                     io_tech_request_context
= io_tech_request_context
          
IMPORTING er_entity          = employeephotoset_get_entity
                                
).
     
          
IF employeephotoset_get_entity IS NOT INITIAL.
          
*     Send specific entity data to the caller interface
           copy_data_to_ref
(
                    
EXPORTING
                     is_data
= employeephotoset_get_entity
                    
CHANGING
                     cr_data
= er_entity
                         
).
          
ELSE.
          
*         In case of initial values - unbind the entity reference
           er_entity
= lr_entity.
          
ENDIF.

           lv_pernr
= employeephotoset_get_entity-EmpID.

          
CALL FUNCTION 'PAD_PHOTO_UPDATE_GET_DETAIL'
          
EXPORTING
                IV_EMPLOYEE_NUMBER        
= lv_pernr
      

          
TABLES
                T_PHOTO_ARCHIVE_OUT       
= t_photo
                T_MESSAGES_OUT            
= t_msg
               
.

          
LOOP AT t_photo into ls_photo.
                l_line
= ls_photo-line.
               
concatenate l_photo1 l_line into l_photo1.
          
ENDLOOP.

               ls_stream
-value = l_photo = l_photo1.
               ls_stream
-mime_type = 'image/jpeg'.

               copy_data_to_ref( EXPORTING is_data = ls_stream
                                
CHANGING  cr_data = er_stream ).

     
WHEN OTHERS.

ENDCASE.



1 Comment