CRM and CX Blogs by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos


UPLOAD A FILE IN SAP WEB UI

1.Add component usage ‘GS_FILE_UPLOAD’.



 



 


 


 

2.create a TABLE view with  button upload.

 



 



 

 




 

3.call component usage as popup on clicking that button.

 

 



 

 

 

 

 

 

create event handler onpopup_closed.

 

METHOD eh_onpopup_closed.
“structure corresponds to view attributes
TYPES :BEGIN OF ls_struct,
emp_id TYPE char10,
name TYPE char30,
END OF ls_struct.
FIELD-SYMBOLS <fs_wa_data> TYPE ls_struct.
DATA : lr_value_node   TYPE REF TO cl_bsp_wd_value_node,
lr_bo_col       TYPE REF TO if_bol_bo_col,
lr_struct       TYPE REF TO ls_struct,
lr_output_node  TYPE REF TO cl_bsp_wd_context_node,
lr_property     TYPE REF TO if_bol_bo_property_access,
lv_file_content TYPE string,
lt_file_content TYPE stringtab,
lv_dummy        TYPE string.

"CLEAR EXISTING VALUES
me->typed_context->filecontent->collection_wrapper->clear( ).
"GET UPLOADED VALUES
lr_property  = gr_popup->get_context_node( iv_cnode_name = 'FILE' )->get_collection_wrapper( )->get_current( ).
lr_property->get_property_as_value(
EXPORTING
iv_attr_name = 'FILE_CONTENT_STRING'    " Component Name
IMPORTING
ev_result    = lv_file_content
).
IF lv_file_content IS NOT INITIAL.
CREATE DATA lr_struct.
ASSIGN lr_struct->* TO <fs_wa_data>.
"SPLIT EACH LINE TO TABLE
SPLIT lv_file_content AT cl_abap_char_utilities=>cr_lf INTO TABLE lt_file_content.
CLEAR lv_file_content.
IF lr_bo_col IS NOT BOUND.
CREATE OBJECT lr_bo_col TYPE cl_crm_bol_bo_col.
ENDIF.
LOOP AT lt_file_content INTO lv_file_content .


“ignore the title
IF sy-tabix <> 1.
"SPLIT VALUES FROM STRING
SPLIT lv_file_content AT ',' INTO <fs_wa_data>-emp_id <fs_wa_data>-name lv_dummy.
"CREATE VALUE NODE OBJECT
CREATE OBJECT lr_value_node
EXPORTING
iv_data_ref = lr_struct.
"ADD TO COLLECTION
lr_bo_col->add(
EXPORTING
iv_entity    = lr_value_node     " Access Interface for BO Attributes
*      iv_set_focus = ABAP_FALSE    " Indicator: Set Focus on New Element
).
ENDIF.
ENDLOOP.
me->typed_context->filecontent->collection_wrapper->add_collection( iv_collection = lr_bo_col  ).
ENDIF.
ENDMETHOD.


 

 

Output

 



 

 

 

 

 

 

Upload the file