Wednesday, March 14, 2012
Steps to achieve
Create Web Dynpro Application and save it as local object.
- Create Web Dynpro Component and Save as local object.
- No need to embed View into Window when you specify view and window.
- Go to Component Controller ->Context tab-> Create two nodes EMP_DET - Cardinality 0..n and FILE with attribute FILE_CONTENTS of type XSTRING.
- Go to View UPLOAD_V ->Context tab->Map Component Controller context to View Context as shown below.
- Go to Layout tab
- Set ROOTUIELEMENTCONTAINER layout type -MatrixLayout
- Create Group UI element - Layout data - MatrixHeadData
- Create File Upload UI element inside Group and bind with context node FILE.
- Create button inside Group - Create OnAction event - UPLOAD_FILE
- Create one Table UI element and bind with Context node EMP_DET.
method ONACTIONUPLOAD_FILE .
DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->upload_file( ).
endmethod.
- Go to Component Controller -> Method tab -> Write the below code in UPLOAD_FILE.
METHOD upload_file .
DATA:
lo_nd_file TYPE REF TO if_wd_context_node,
lo_nd_emp_det TYPE REF TO if_wd_context_node,
lt_emp_det TYPE wd_this->elements_emp_det,
lo_el_file TYPE REF TO if_wd_context_element.
DATA:
ls_file TYPE wd_this->element_file,
ls_emp_det TYPE wd_this->element_emp_det,
lt_bin TYPE TABLE OF sdokcntbin,
lt_txt TYPE TABLE OF sdokcntasc,
ls_txt LIKE LINE OF lt_txt,
lv_outlen TYPE i.
* navigate from <context> to <file> via lead selection
lo_nd_file = wd_context->get_child_node( name = wd_this->wdctx_file ).
* get element via lead selection
lo_el_file = lo_nd_file->get_element( ).
* get all declared attributes
lo_el_file->get_static_attributes(
IMPORTING
static_attributes = ls_file ).
"XSTRING to BINARY
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = ls_file-file_contents
IMPORTING
output_length = lv_outlen
TABLES
binary_tab = lt_bin.
"Binary to Text file
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = lv_outlen
TABLES
binary_tab = lt_bin
text_tab = lt_txt.
LOOP AT lt_txt INTO ls_txt.
SPLIT ls_txt AT cl_abap_char_utilities=>horizontal_tab INTO
ls_emp_det-pernr
ls_emp_det-nachn
ls_emp_det-vorna
ls_emp_det-gbdat.
APPEND ls_emp_det TO lt_emp_det.
CLEAR ls_emp_det.
ENDLOOP.
* navigate from to via lead selection
lo_nd_emp_det = wd_context->get_child_node( name = wd_this->wdctx_emp_det ).
lo_nd_emp_det->bind_table( new_items = lt_emp_det set_initial_elements = abap_true ).
ENDMETHOD.
- Run the application.
Followers
Popular Posts
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- SAP ABAP-PDF display in Custom Container
- Web Dynpro ABAP ALV - ON_CLICK event













Use full . Thank you
ReplyDeletei tried this but it is not working and the data i am getting like special characters
ReplyDelete