Industries Training & Education Partnership Developer Center Lines of Business University Alliances Events & Webinars Innovation Login Regi ster Welcome, Guest Search the Community Activity Communications Actions Browse Web Dynpro ABAP 116 Posts 1 2 3 4 8 Previous Next In NET311 the topic component usage clone is discussed there. One example is also given there: The user of a Web Dynpro application can mark multiple lines of a table to display details for each selected data set. The details of one data set is displayed by one usage of a certain component. Thus, the number of component usages equals the number of marked lines, which is not known at design time. The prerequisite for cloning any component usage is, that a single usage of this component has been defined at design time. Any controller having added the name of the static component usage to the list of used controllers / components can then create additional usages of the same component. Each component usage must have a unique name. I will reuse the component created in the blog Step by Step to create UI elements and context node attribute in the runtime . After I maintain the content number and click create button, the label and text view together with their bound context node attribute will be generated in the runtime. The value of text view "Echo from Usage clone:<number>" is returned by the cloned component usage. 1. Create a simple component ZDYNAMICUSAGE which will be consumed as component usage later. Implement the echo method in component controller. Step by step to use Component usage clone Posted by Jerry Wang Dec 13, 2013 2. In order to use component usage, there must be at least one static component usage.Also define usage of the interface controller in the consumer view controller. 3.In method CREATE_CONTEXT, just enhance one line. ( In the original example, I just set the value of newly- generated context attribute to its attribute name) method CREATE_CONTEXT . CONSTANTS: cv_value type string value 'VALUE'. data(lo_node) = wd_context->get_child_node( 'DYNAMIC' ). data(lo_node_info) = lo_node->get_node_info( ). data(lt_attributes) = lo_node_info->get_attributes( ). DO iv_count TIMES. DATA(lv_attribute_name) = cv_value && sy-index. READ TABLE lt_attributes WITH KEY name = lv_attribute_name TRANSPORTING NO FIELDS. IF sy-subrc <> 0. data(ls_attribute_prop) = VALUE wdr_context_attribute_info( NAME = lv_attribute_name TYPE_NAME = 'STRING' ). lo_node_info->add_attribute( attribute_info = ls_attribute_prop ). DATA(lv_value) = wd_this->get_value_by_index( sy-index ). lo_node->set_attribute( name = lv_attribute_name value = lv_value ). ENDIF. ENDDO. endmethod. 4. Define one attribute in view controller, which is an internal table to store all references of component usage instance. In view controller WDDOINT, insert the static component usage to the internal table. The internal table would have the first line as static component usage instance and all remaining ones for cloned component usage from the static one.
5. Implement the method get_value_by_index which is called in step3. I will read the internal table gt_cmp_usages by index. Index 1 means this is a static component usage so I directly use the one return from wd_this->wd_cpuse_zclone_example( ). Or else the left one will be cloned from the static one. Since the usage name should be unique, so I use a prefix and an index to fulfill the uniqueness.
In the debugger I would observe that every component usage in gt_cmp_usages are unique: 274 Views 0 Comments Tags: abap, webdynpro, dynamic, webdynpro_abap, webdynproabap, component_usage, static, webdynpro_f or_abap, clone 01. method GET_VALUE_BY_INDEX . 02. DATA(lo_static_com_usage) = wd_this->wd_cpuse_zclone_example( ). 03. DATA: lo_generic_usage TYPE REF TO if_wd_component_usage, 04. lo_interface_control TYPE REF TO ZIWCI_DYNAMICUSAGE. 05. READ TABLE wd_this->gt_cmp_usages ASSIGNING FIELD-SYMBOL(<usage>) INDEX iv_index. 06. CASE iv_index. 07. WHEN 1. 08. IF lo_static_com_usage->has_active_component( ) IS INITIAL. 09. lo_static_com_usage->create_component( ). 10. ENDIF. 11. lo_generic_usage = lo_static_com_usage. 12. WHEN OTHERS. 13. READ TABLE wd_this->gt_cmp_usages ASSIGNING FIELD-SYMBOL(<dyn_usage>) INDEX iv_index. 14. IF sy-subrc <> 0. 15. DATA(lv_usage_name) = 'DYNAMIC_USAGE' && sy-index. 16. data(lo_dyn_usage) = lo_static_com_usage->create_comp_usage_of_same_type( name = lv_usage_name ). 17. APPEND lo_dyn_usage TO wd_this->gt_cmp_usages. 18. ENDIF. 19. IF lo_dyn_usage->has_active_component( ) IS INITIAL. 20. lo_dyn_usage->create_component( ). 21. ENDIF. 22. lo_generic_usage = lo_dyn_usage. 23. ENDCASE. 24. lo_interface_control ?= lo_generic_usage->get_interface_controller( ). 25. rv_output = lo_interface_control->get_field_value( iv_index ). 26. endmethod. Step by Step to create UI elements and context node attribute in the runtime Posted by Jerry Wang Dec 13, 2013 I will use an example to demonstrate.The dynamically created elements are put into the red area below. Input the number of rows you want to dynamically generated and just create button to generate. Currently the content of text view is just filled with VALUE1,2,3,4... In next blog they will be filled with another approach by component usage cloning logic. 1. Create an empty group which acts as a container to hold all dynamically created ui elements.Specify layout as RowLayout. 2. Create an empty context node which also acts as a container for all dynamically created context node attributes. 3. In method WDDOMODIFYVIEW, just store the reference of view, which will be used later to manipulate UI elements after create button is clicked. method WDDOMODIFYVIEW . CHECK first_time = 'X'.
wd_this->mr_view = view. endmethod.
4. create a new method in view controller. In line 3 we get reference of place holder context node DYNAMIC. Then we get the node attributes by its node information object. It is not necessary to create new attributes every time the create button is clicked unless the attribute has not really been created. 5. Implement the create button handler. Make sure to delete all children of the UI place holder to avoid the repeated insertion of the ui elements with the same id, which will lead to runtime error. Then create new instance for label and text view, and specify their layout accordingly, so that each label will be put into a new line.
425 Views 2 Comments Tags: abap, dynamic, runtime, modif y, ui_element, abap_wd, wddomodif yview 01. method ONACTIONCREATE . 02. CONSTANTS: cv_label TYPE string VALUE 'LABEL', 03. cv_field TYPE string VALUE 'FIELD', 04. cv_bind_text TYPE string VALUE 'DYNAMIC.VALUE'. 05. DATA: lv_count type i, 06. lo_container type ref to cl_Wd_uielement_container. 07. wd_context->get_attribute( EXPORTING name = 'NUMBER' IMPORTING value = lv_count ). 08. CHECK lv_count > 0. 09. create_context( lv_count ). 10. DATA(lo_root) = wd_this->mr_view->get_element( 'DYNAMICUI' ). 11. lo_container ?= lo_root. 12. lo_container->remove_all_children( ). 13. DO lv_count TIMES. 14. data(lv_field_id) = cv_field && sy-index. 15. data(lv_label_id) = cv_label && sy-index. 16. data(lv_bind_path) = cv_bind_text && sy-index. 17. DATA(lo_text_view) = cl_wd_text_view=>new_text_view( id = lv_field_id bind_text = lv_bind_path ). 18. DATA(lo_label) = cl_wd_label=>new_label( id = lv_label_id label_for = lo_text_view->id text = lv_label_id ). 19. CL_WD_ROW_HEAD_DATA=>new_row_head_data( element = lo_label ). 20. cl_wd_row_data=>new_row_data( element = lo_text_view ). 21. lo_container->add_child( the_child = lo_label ). 22. lo_container->add_child( the_child = lo_text_view ). 23. ENDDO. 24. endmethod. For input attribute totally five input help mode could be selected. In most of time we would always like to leverage the existing dictionary search help defined in DDIC. However if existing one could not fulfill our requirement, we have to develop our own value help by ourselves. I have used a simple example to demonstrate how to use "Freely Programmed" input help mode. I have one consumer component ZCONSUMER, and one component ZUSER_HELP. ZCONSUMER just have one input field for post ID and post description. When click value help of Post ID, the view of ZUSER_HELP will be opened and there is a SQL select to fetch the description according to post ID from database table.
1. in ZUSER_HELP, create the context node with attribute ID for post id, and description for post description. Since I use external mapping for data transfer from consumer component to value help provider component, so I mark the flag "Input Element(Ext.)". Define the node as interface node.
Step by step about how to develop user defined value help Posted by Jerry Wang Dec 12, 2013 2. Implement the standard component interface IWD_VALUE_HELP. Redefine the method SET_VALUE_HELP_LISTENER. Also include your own value help view into the interface view WD_VALUE_HELP. In the method SET_VALUE_HELP_LISTENER, I select the post description from database table and store it to attribute DESCRIPTION. The listener reference is also stored into member variable of component controller for later usage. 3. Draw a button in value help view to close the value help popup window once clicked. Just use the reference stored in step2 to close window. method ONACTIONCLOSE . wd_comp_controller->mr_listener->close_window( ). endmethod. 01. method SET_VALUE_HELP_LISTENER . 02. data: lv_id type socialdata-internal_id, 03. lv_text type socialdata-socialposttext. 04. wd_this->mr_listener = listener. 05. data(lo_node) = wd_context->get_child_node( IF_COMPONENTCONTROLLER=>wdctx_post ). 06. CHECK lo_node IS NOT INITIAL. 07. lo_node->get_attribute( EXPORTING name = 'ID' IMPORTING value = lv_id ). 08. SELECT SINGLE socialposttext INTO lv_text from socialdata where internal_id = lv_id. 09. CHECK sy-subrc = 0. 10. lo_node->set_attribute( name = 'DESCRIPTION' value = lv_text ). 11. endmethod.
4. in consumer component ZCONSUMER, create component usage to ZUSER_HELP, and create context node POST. Choose Input help mode Freely Programmed and choose component usage ZUSER_DEFINE_HELP from value help. Create an interface controller usage on component usage ZUSER_DEFINE_HELP and finish the context node mapping, or else you will meet with runtime error "External mapping of Node ZUSER_HELP#COMPONENTCONTROLLER.CONTEXT.POST is Not Completed yet".
Now once clicked the value help icon of input field Post ID, the value help window provided by component ZUSER_HELP will pop up automatically. And once close button is clicked, the description field of consumer component will be filled. 294 Views 0 Comments Tags: abap, webdynpro, value_help, user_def ined, external_mapping Hi,
I have come across many scn threads which refer to "How to read / get data from a dynamic node" .
Here I would like to demonstrate, the steps to read the data from a node ( either static / dynamic node ) in Webdynpro ABAP.
I have divided the task into 3 methods 1. GET_NODE_INFO( ) - Get node information from node name 2. GET_NODE_DATA_TYPE( ) - Get node data type & attribute list by using node reference ( if_wd_context_node ) 3. GET_DATA( ) - Get data of any given node reference
All you need to do is ... just create these 3 methods as is and start using for reading data from a given node ( either static node / dynamic node )
Now, let us look into the code of each method as below
GET_NODE_INFO( )
Parameters:
Parameter Type Ref To Optional Associated Type Description ID_NODE_NAME Importing STRING Node Name IO_PARENT_NODE Importing Checked Yes IF_WD_CONTEXT_NODE Parent Node Reference EO_NODE_INFO Exporting Checked IF_WD_CONTEXT_NODE_INFO Node info reference ED_ERROR_MESSAGE Exporting STRING error message EO_NODE Exporting Checked IF_WD_CONTEXT_NODE Node reference
Logic:
GET_NODE_INFO METHOD get_node_info . DATA: lo_node_info TYPE REF TO if_wd_context_node_info, lo_parent_node TYPE REF TO if_wd_context_node, lv_node_name TYPE string, lx_root TYPE REF TO cx_root. TRY. "============================================= " check if node name is supplied, " if so nothing do , return the control How to get data from a dynamic node in Webdynpro ABAP ? Posted by Ramakrishnappa Gangappa Dec 12, 2013 "============================================= IF id_node_name IS INITIAL. RETURN. ELSE. lv_node_name = id_node_name. TRANSLATE lv_node_name TO UPPER CASE. ENDIF. "============================================= " Check if io_parent_node is not bound, if so " Assume parent node is WD_CONTEXT "============================================= IF io_parent_node IS NOT BOUND. lo_parent_node = wd_context. ELSE. lo_parent_node = io_parent_node. ENDIF. "============================================= "get node info "============================================= eo_node = lo_parent_node->get_child_node( name = lv_node_name ). eo_node_info = eo_node->get_node_info( ). CATCH cx_root INTO lx_root. ed_error_message = lx_root->get_text( ). ENDTRY. ENDMETHOD.
Parameters: Parameter Type Ref To Optional Associated Type Description IO_NODE_INFO Importing Checked IF_WD_CONTEXT_NODE_INFO Node info Reference ED_ERROR_MESSAGE Exporting STRING Error message EO_DATA Exporting Checked DATA Node data type ref ET_FCAT Exporting LVC_T_FCAT Attributes/fields list
Logic: GET_NODE_DATA_TYPE METHOD GET_NODE_DATA_TYPE . CLEAR: eo_data, et_fcat, ed_error_message. TRY . DATA: lo_table TYPE REF TO data, ls_fcat TYPE lvc_s_fcat, lt_attr TYPE wdr_context_attr_info_map, ls_attr LIKE LINE OF lt_attr, lx_root TYPE REF TO cx_root. IF io_node_info IS NOT BOUND. ed_error_message = 'Node info is invalid'. RETURN. ENDIF. "============================================= " get attributes "============================================= lt_attr = io_node_info->get_attributes( ). LOOP AT lt_attr INTO ls_attr. CLEAR ls_fcat. ls_fcat-fieldname = ls_attr-name. ls_fcat-datatype = ls_attr-type_name. APPEND ls_fcat TO Et_fcat. ENDLOOP. cl_alv_table_create=>create_dynamic_table( EXPORTING it_fieldcatalog = Et_fcat i_length_in_byte = abap_true IMPORTING ep_table = lo_table EXCEPTIONS generate_subpool_dir_full = 1 OTHERS = 2 ). IF sy-subrc <> 0. * MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno * WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. " if node is multiple ( 0..n / 1..n ) return table type IF io_node_info->is_multiple( ) EQ abap_true. eo_data = lo_table. ELSE. FIELD-SYMBOLS: <lt_table> TYPE STANDARD TABLE. ASSIGN lo_table->* TO <lt_table>. IF <lt_table> IS ASSIGNED. CREATE DATA eo_data LIKE LINE OF <lt_table>. ENDIF. " else, return the ENDIF. CATCH cx_root INTO lx_root. ed_error_message = lx_root->get_text( ). ENDTRY. ENDMETHOD.
Parameters: Parameter Type Ref To Optional Associated Type Description IO_NODE Importing Checked IF_WD_CONTEXT_NODE Node reference ED_ERROR_MESSAGE Exporting STRING Error message EO_DATA Exporting Checked DATA Data ET_FCAT Exporting LVC_T_FCAT Fields
Logic: GET_DATA METHOD GET_DATA . DATA lv_count TYPE i. DATA ls_fcat TYPE lvc_s_fcat. DATA lv_index TYPE i. DATA lv_attr_name TYPE string. DATA lx_root TYPE REF TO cx_root. FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE, <ls_data> TYPE any, <lv_value> TYPE any. TRY. IF io_node IS NOT BOUND. ed_error_message = 'Node reference cannot be empty'. RETURN. ENDIF. " Get node data type and attribute list wd_this->get_node_data_type( EXPORTING io_node_info = io_node->get_node_info( ) IMPORTING eo_data = eo_data et_fcat = et_fcat ed_error_message = ed_error_message ).
" Return if any error or data type is not bound IF ed_error_message IS NOT INITIAL OR eo_data IS NOT BOUND. RETURN. ENDIF. ASSIGN eo_data->* TO <lt_data>. " get the no. of elements available in context node lv_count = io_node->get_element_count( ). " do for each element DO lv_count TIMES. " collect index value lv_index = sy-index. " Create a blank line and get the ref into <ls_dat> APPEND INITIAL LINE TO <lt_data> ASSIGNING <ls_data>. " return if line type is not assigned IF <ls_data> IS NOT ASSIGNED. RETURN. ENDIF. " Loop over each field/attribute and get the data LOOP AT et_fcat INTO ls_fcat. ASSIGN COMPONENT ls_fcat-fieldname OF STRUCTURE <ls_data> TO <lv_value>. IF <lv_value> IS ASSIGNED. lv_attr_name = ls_fcat-fieldname. io_node->get_attribute( EXPORTING index = lv_index name = lv_attr_name IMPORTING value = <lv_value> ). ENDIF. ENDLOOP. ENDDO. CATCH cx_root INTO lx_root. ed_error_message = lx_root->get_text( ). ENDTRY. ENDMETHOD. ----------------------------------------------------
Example: Scenario: Let us say we need to read data from a node "NODE_DYN".
Example -------------------------- " Data declarations DATA: lo_data TYPE REF TO data. DATA lo_node TYPE REF TO if_wd_context_node.
ASSIGN lo_data->* to <lt_data>. --------------------------
The internal table <lt_data> contains the data of our node "NODE_DYN" Hope this helps for those looking for reading the data of any given node ( dynamic node / static node ) I appreciate if any comments/suggestions from you 510 Views 0 Comments Tags: get_data_f rom_dynamic_node_webdynpro_abap, get_data_f rom_any_node_webdynpro_abap Hello everyone,
in my first post I would like to present a way to check if required fields are filled. Below you will find data declaration, that will be used:
DATA: l_node TYPE REF TO if_wd_context_node, l_attr_list TYPE cl_wd_dynamic_tool=>t_check_mandattr_tab, l_attr TYPE cl_wd_dynamic_tool=>t_check_mandattr_struct, l_has_errors TYPE wdy_boolean.
Reference to node (l_node) which attributes will be checked, list of attributes (l_attr_list) and a flag (l_has_errors) to indicate if check was with errors.
The next step is to fill list with attribute name(s):
Best regards, Paul 165 Views 2 Comments How to check if fields are required in ABAP Posted by Paul Smuda Dec 10, 2013 Enable filter line on ALV table on POWL application. Posted by Venky D Dec 10, 2013 Summary: Enable filter Line on table by default on POWL application.
Requirement: In the standard behavior POWL will show filter on table after you click on filter link on the right hand top side of the table. With the same link we can show or hide the filter option on table.
But if we have a requirement to show the filter option on table by default, here is the solution for POWL or other webdynpro supported applications.
Solution: Steps to implement the solution: This functionality exists in POWL_TABLE_COMP webdynpro component.
Go to POWL_TABLE_COMP Navigate to view Method : DO_HOUSEKEEPING Now implement overwrite exist enhancement to this method as follows.
Click on respective button under overwrite column.
And click on Enhancement button. Now create enhancement as below. Every time you do modification always recommended to use the same enhancement for the one functionality chance.
Now go to overwrite page and copy of all code from the original method. And go to overwrite method and copy all the code.
Now trace/debug for exact location to implement your functionality. In this case copy the below code after line no: 42. lr_alv_model->if_salv_wd_std_functions~set_filter_filterline_allowed( abap_true ). lr_alv_model->if_salv_wd_std_functions~set_filter_complex_allowed( abap_true ). IF first_time IS NOT INITIAL.
cl_salv_wd_model_table_util=>if_salv_wd_table_util_funcs~set_functions_visible( r_model = lr_alv_model VALUE = cl_wd_uielement=>e_visible-none ). ELSE.
cl_salv_wd_model_table_util=>if_salv_wd_table_util_funcs~set_functions_visible( r_model = lr_alv_model VALUE = cl_wd_uielement=>e_visible-visible ). ENDIF.
Now execute the POWL and we can see the filter line on the table for all queries. KEEP SHARING Venky 480 Views 1 Comments Tags: f ilter, abap, alv, powl, enable., webdynpor, compoent, powl_table_comp Summary: This article illustrates the possibility of doing mass processing in POWL
In one of my projects there was a requirement wherein the user should be able to process up to 5 different work orders/operations at the same time. These work orders will be selected from a power list(POWL) in portal.
The standard POWL behavior throws an error message on certain actions if more than one rows are selected. This behavior can be overridden by creating an implicit enhancement in the respective feeder class.
Feeder class
The feeder class is the central and the most important place while developing and modifying Power Lists. The feeder class includes the handling of actions initiated by the user while pressing a button.
How to find the feeder class used for your POWL. (reference http://scn.sap.com/thread/1983141 )
Method 1 : T-code POWL_TYPE contains the Feeder class name assigned to the POWL type . One can check the POWL type with description and find the feeder class associated with it and then put a break point in method IF_POWL_FEEDER~GET_OBJECT_DEFINITION of the feeder class and ensure that feeder class is correct. mass processing in POWL Posted by Veena Vinchurkar Nov 20, 2013
Or Method 2: Go to POWL_UI_COMP webdynpro component, navigate to MASTER_CONTENT view method tab . In the ONACTIONREFRESH_CURRENT event in the method tab set a break point in the lr_model->refresh_current( ). Click the "Refresh" button from the POWL table of which you want to find the feeder class , you will get the POWL type inside the method ( variable name- ms_current_query-type ). Now go to POWL_TYPE t-code and find the feeder class which is assigned to this POWL TYPE
Mass selection
Create an implicit enhancement at the end of the method IF_POWL_FEEDER~HANDLE_ACTION of your feeder class. Code snippet given below.
i_actionid is the action for which you need to select more than one rows in POWL. In this example i_actionid='CONF' for the 'Enter Confirmation' button from the screenshot above.
The selected orders/operations are stored in a transaction table ZTI_PMCONF for the current logged in user.
ENHANCEMENT 1 ZPMZCONF_POWL_CL. "active version * DATA ls_order_op type ZTI_PMCONF. DATA ltt_powl_msg TYPE POWL_MSG_TTY. IF lv_selected GT 5 AND i_action_index IS INITIAL AND mv_bp_version NE '10' AND i_actionid = 'CONF'.
** display error message "Select upto 5 rows only" if more than 5 work orders are selected in POWL delete lt_powl_msg index 1. e_messages[] = lt_powl_msg[]. ls_powl_msg-msgtype = cl_rplm_qimt_co=>sc_error. ls_powl_msg-msgid = 'ZZPM'. ls_powl_msg-msgnumber = '144'. APPEND ls_powl_msg TO lt_powl_msg. e_messages[] = lt_powl_msg[]. ELSEIF lv_selected <> 1 AND i_action_index IS INITIAL AND mv_bp_version NE '10' AND i_actionid = 'CONF'. ** suppress standard error message "Select one line only" to allow multiple line selections for this action
delete lt_powl_msg index 1. e_messages[] = lt_powl_msg[]. ** delete all the previous user selections stored in the transaction table if any, this is also deleted immediately after the values are set in the application DELETE FROM ZTI_PMCONF WHERE UNAME eq sy-uname. COMMIT WORK. DATA lv_tab TYPE sy-tabix. lv_tab = 0.
** Loop through the number of selected lines DO lv_selected TIMES. lv_tabix = lv_tab + 1. READ TABLE c_selected INTO ls_index INDEX lv_tabix. READ TABLE c_result_tab INTO ls_result INDEX ls_index-tabix. ** Check if order is locked CALL METHOD me->check_order_lock EXPORTING iv_aufnr = ls_result-aufnr IMPORTING e_messages = ltt_powl_msg. IF ltt_powl_msg IS NOT INITIAL. LOOP AT ltt_powl_msg INTO ls_powl_msg. APPEND ls_powl_msg TO lt_powl_msg. ENDLOOP. ENDIF.
** if there are no errors or no work orders are locked, save the selected work orders and operation in the database table ZTI_PMCONF IF lt_powl_msg IS INITIAL. ls_order_op-AUFNR = ls_result-aufnr. ls_order_op-VORNR = ls_result-vornr. ls_order_op-UNAME = sy-uname. INSERT INTO ZTI_PMCONF VALUES ls_order_op. clear ls_order_op. ENDIF. lv_tab = lv_tab + 1. ENDDO. IF lt_powl_msg IS INITIAL.
** Get role id IF i_applid = cl_rplm_qimt_co=>sc_applid_mt. lv_role_id = cl_rplm_qimt_co=>sc_roleid_mt_compl_conf. ELSE. lv_role_id = cl_rplm_qimt_co=>sc_roleid_others. ENDIF. ** Get POWL api cl_powl_runtime_services=>get_powl_object_info_handle( RECEIVING ro_powl_object_info_handle = lo_obj_info EXCEPTIONS no_wdr_component = 1 OTHERS = 2 ). IF sy-subrc = 0 AND lo_obj_info IS NOT INITIAL. lv_environment = lo_obj_info->mv_client_environment. ENDIF. ** The custom form developed for this requirement(not in scope of this article) can be accessed via second level navigation or from the POWL worklist. It behaves differently in both cases, so to identify if it is called via second level navigation or via POWL, a parameter is passed which is read in the HANDLEDEFAULT method of the window
** set parameter POWL_FLAG to check if the application is being called via POWL or second level navigation ls_name_value-key = 'POWL_FLAG'. ls_name_value-value = 'X'. INSERT ls_name_value INTO TABLE lt_name_value. ls_powl_follow_up-bo_system = cl_rplm_qimt_co=>sc_system_erp. IF lv_environment NE if_wd_application=>co_client_environment-nwbc. ls_powl_follow_up-bo_name = 'maintenance_order_confirmation'. ELSE. "PFCG usage in NWBC ls_powl_follow_up-bo_name = 'maintenance_ord_conf'. ENDIF. ls_powl_follow_up-bo_op_name = 'create'. ls_powl_follow_up-parameters = lt_name_value. ENDIF. e_portal_actions = ls_powl_follow_up. *----------------------------------------------------------------------* *- Return the message table *----------------------------------------------------------------------* e_messages[] = lt_powl_msg[]. ENDIF. ENDENHANCEMENT.
Note: I tried using a singleton class for this approach instead of using a transaction table. However, the session is not retained across POWL and the custom application. 385 Views 0 Comments Tags: multiple, row, powl, selections Recently I am working on a customer project and one customer requirement is they do not want to the word document be editable in the word control. That means all buttons and menus in toolbar should be disabled. The first idea comes to my mind is the flag "enableReadWrite". As documented in sap helpit can fulfill my help but unfortunately it is deprecated. Regardless of this warning I have a try and found it does not work indeed. Then I am speculating that if the document uploaded is read only, it is for sure that the toolbar will be disabled. So the issue turns to that how could I mark the document to be read only on the fly during uploading. Since word 2007 the format of MS office follows the so called "Open office" protocal whose specification could be found here. if you change the file type extension from .docx to .zip and open it with WinRAR, you will find the document is actually a bundle of several single files ( called document part in SAP internal ). The editability is controlled within the file settings.xml. How to disable the document edit in Word control Posted by Jerry Wang Nov 14, 2013
if you don't know the exact syntax, just google it. I use the explaination from this one in google: Now the task is quite easy, just add the necessary xml tag into the document source code. You do not need to manually parse the document source code since SAP has already done this job. You can just reuse standard class CL_DOCX_DOCUMENT. Since I need to insert the document protection node in "settings" node, a simple transformation is written for this. The magic is between line 18 and 21. and find a proper place to call the transformation:
after that the tag will be there in settings.xml: 01. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 02. xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" 03. xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" 04. <xsl:output encoding="UTF-8" indent="no" method="xml" omit-xml-declaration="no" version="1.0"/> 05. <!-- Match everything all nodes and attributes --> 06. <xsl:template match="@*|node()"> 07. <xsl:copy> 08. <xsl:apply-templates select="@*|node()"/> 09. </xsl:copy> 10. </xsl:template> 11. <xsl:template match="w:settings"> 12. <xsl:element name="w:settings"> 13. <xsl:for-each select="@*"> 14. <xsl:copy/> 15. </xsl:for-each> 16. <xsl:element name="w:documentProtection"> 17. <xsl:attribute name="w:edit">readOnly</xsl:attribute> 18. <xsl:attribute name="w:enforcement">1</xsl:attribute> 19. </xsl:element> 20. <xsl:copy-of select="./*"/> 21. </xsl:element> 22. </xsl:template> 23. </xsl:stylesheet> 01. DATA: lr_element TYPE REF TO if_wd_context_element, 02. lv_file_data TYPE xstring, 03. lv_ret TYPE i, 04. lx_temp TYPE xstring, 05. lv_msg TYPE string, 06. lt_parms TYPE /ipro/tt_key_value_pair, 07. ls_parm LIKE LINE OF lt_parms. 08. lr_element = me->wd_context->get_element( ). 09. CHECK lr_element IS NOT INITIAL. 10. lr_element->get_attribute( EXPORTING name = 'BINARY' IMPORTING value = lv_file_data ). 11. DATA(lo_docx) = cl_docx_document=>load_document( lv_file_data ). 12. DATA(lo_main_part) = lo_docx->get_maindocumentpart( ). 13. DATA(lo_docx_settings) = lo_main_part->get_documentsettingspart( ). 14. DATA(lx_settings) = lo_docx_settings->get_data( ). 15. /ipro/cl_docx_utilities=>transform( EXPORTING iv_input_xstring = lx_settings 16. iv_transform_name = '/IPRO/DOCXCC_PROTECT' 17. it_parameters = lt_parms 18. IMPORTING ev_result = lx_temp 19. ev_ret = lv_ret 20. ev_message = lv_msg ). 21. lo_docx_settings->feed_data( lx_temp ). 22. DATA(lx_docx_package) = lo_docx->get_package_data( ). 23. lr_element->set_attribute( EXPORTING name = 'BINARY' value = lx_docx_package ). The word control before upload document looks like below, buttons and menus available: After upload, menu and button are disabled. If you try to edit the document, there will be notifications in the right pane to give you a hint that is not possible. Of course this solution does not work for lower version of MS word like word2003. Fortunately my customer has enough money and they are already using Office 2013 so I do not need to worry about it 342 Views 0 Comments Tags: abap_webdynpro, word, of f ice_integration, disable, protect, read_only, docb, document_builder Hi everyone,
Often when we need to print a Web Dynpro View, we can just use the browser's built-in printing method (Ctrl+P). Issue will arise if the contents in our Web Dynpro View are not fully displayed in the printed page. For example, an Text Edit that required us to scroll through to view all the contents.
To solve this problem, we may want to change the Text Edit dynamically to show all the text Dynamically changing Text Area to display all input texts Posted by Nguyen Van Thao Oct 18, 2013 without scrolling. And yes, we will need to use Dynamic Programming to achieve this.
Before attempt to change the Text Edit size dynamically, we need to figure out how to derive the required size of the Text Edit such that all the text inside will be shown in Printing Mode.
So for example, our original content is like below screenshot:
Notice that there is a scroll bar and we won't be able to see all of the text when we print the page. Now let say we click on Resize button and we want the page to look like this.
With this, we are able to print the page with all content displayed.
Look at Text Edit's properties, it seems that the unit of the cols is by "Number of Letter" and the unit of rows is literally "Number of Rows". From this we can derive how to calculate the rows needed to display text without scrolling:
Rows Needed = Length(Value in Text Edit) / Number of Columns + 1
We add 1 to make sure that there is no scrollable contents. And with this, our problem is solved.
Now we come to the coding part.
Dynamically changing UI elements in Web Dynpro can be done in the hook method WDDOMODIFYVIEW (before the View get rendered). So let say when we click on the Resize button, an Action will be triggered, in the Action, we set a flag states that we want to resize the UI. This chain of events will eventually reach WDDOMODIFYVIEW. And here is our code in WDDOMODIFYVIEW:
METHOD wddomodifyview . DATA: lr_container TYPE REF TO cl_wd_uielement_container, lt_ui_children TYPE cl_wd_uielement=>tt_uielement, lr_text_edit TYPE REF TO cl_wd_text_edit, lv_value TYPE string, lv_rows TYPE i, lv_val_len TYPE i, lv_cols TYPE i. FIELD-SYMBOLS: <ls_ui> TYPE REF TO cl_wd_uielement. IF first_time EQ abap_false AND wd_this->print_mode = abap_true. "Get all UI elements in the root container lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ). lt_ui_children = lr_container->get_children( ). "Filter the ones that need to be tweaked in size IF lt_ui_children IS NOT INITIAL. LOOP AT lt_ui_children ASSIGNING <ls_ui>.
The above code is just for demonstration in blog purposes, few thoughts for it: - The code is generic enough to cover for all Text Edits in our Web Dynpro view - We can also extend the logic to cover for resizing other UI elements - We may want to set a default rows value and bind the rows properties of our Text Edit to it - We should also cater for case when user want to return to original view - There's no "INSTANCE OF" in ABAP
That's end of the blog. Please comment and share if you know of other efficient method to print the Web Dynpro view.
Thanks much for reading. Cheers! 500 Views 2 Comments Tags: abap, web_dynpro, web_dynpro_abap, dynamic_programming, abap_wd, print_version Hi,
I thought to have a ready code and share with all, this will help anyone who is dealing with ALV in Web dynpro ABAP. Please find the below working and tested code. The code will allow you to change the description of the columns, Hide/display standard functions buttons, use standard function like adding etc. Have a look at the code below. Let me know in case of any further queries. ****ALV standard declarations DATA: LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE, LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE, LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE. DATA: LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS, LR_COLUMN TYPE REF TO CL_SALV_WD_COLUMN, LR_COLUMN_HEADER TYPE REF TO CL_SALV_WD_COLUMN_HEADER. DATA: LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF, LS_COLUMNS TYPE SALV_WD_S_COLUMN_REF. DATA: LR_STANDARD_FUNCTIONS TYPE REF TO IF_SALV_WD_STD_FUNCTIONS. DATA: LR_ALV_HEADER TYPE REF TO CL_SALV_WD_COLUMN_HEADER, LR_ALV_CONFIG TYPE REF TO CL_SALV_WD_CONFIG_TABLE. DATA: LR_FIELD_AMNT TYPE REF TO CL_SALV_WD_FIELD. DATA: LR_FIELD TYPE REF TO CL_SALV_WD_FIELD. DATA: LV_AGGR_RULE TYPE REF TO CL_SALV_WD_AGGR_RULE. DATA: LR_SORT_RULE TYPE REF TO CL_SALV_WD_SORT_RULE. ****create ALV component LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_COMP( ). IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL. LO_CMP_USAGE->CREATE_COMPONENT( ). ENDIF. ****set data LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_COMP( ). ****ref to if_wd_context_node LO_INTERFACECONTROLLER->SET_DATA( R_NODE_DATA = LO_ND_CTX_VN_PLAN_OUPUT ). LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL( ). ****implement standard functions and initializaton LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_MULTI_COLUMN_SORT( VALUE = ABAP_TRUE ). LR_STANDARD_FUNCTIONS ?= LV_VALUE. LR_STANDARD_FUNCTIONS->SET_EXPORT_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_PDF_ALLOWED( ABAP_FALSE ). Coding for ALV in Web Dynpro ABAP Posted by shitanshu sahai Oct 17, 2013 LR_STANDARD_FUNCTIONS->SET_EDIT_CHECK_AVAILABLE( ABAP_FALSE ). LR_STANDARD_FUNCTIONS->SET_EDIT_INSERT_ROW_ALLOWED( ABAP_FALSE ). LR_STANDARD_FUNCTIONS->SET_EDIT_DELETE_ROW_ALLOWED( ABAP_FALSE ). LR_STANDARD_FUNCTIONS->SET_EDIT_APPEND_ROW_ALLOWED( ABAP_FALSE ). LR_STANDARD_FUNCTIONS->SET_VIEW_LIST_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_FILTER_FILTERLINE_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_DIALOG_SETTINGS_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_COLUMN_SELECTION_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_AGGREGATION_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_GROUP_AGGREGATION_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_COUNT_RECORDS_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_HIERARCHY_ALLOWED( ABAP_TRUE ). LR_STANDARD_FUNCTIONS->SET_SORT_HEADERCLICK_ALLOWED( ABAP_FALSE ). LR_STANDARD_FUNCTIONS->SET_SORT_COMPLEX_ALLOWED( ABAP_TRUE ). ****configure columns & column funtions LR_COLUMN_SETTINGS ?= LV_VALUE. LT_COLUMNS = LR_COLUMN_SETTINGS->GET_COLUMNS( ). ****setting column header for all display feilds LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'AUFNR' ). LR_ALV_HEADER = LR_COLUMN->GET_HEADER( ). LR_ALV_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ). LR_ALV_HEADER->SET_TEXT( 'PO No'). LR_ALV_HEADER->SET_HEADER_TEXT_WRAPPING( ABAP_TRUE ). LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ATWRT_LEN' ). LR_ALV_HEADER = LR_COLUMN->GET_HEADER( ). LR_ALV_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ). LR_ALV_HEADER->SET_TEXT( 'Order Length(Mtr)'). LR_ALV_HEADER->SET_HEADER_TEXT_WRAPPING( ABAP_TRUE ). LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ATWRT_PLAN_QTY' ). LR_ALV_HEADER = LR_COLUMN->GET_HEADER( ). LR_ALV_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_DDIC_BINDING=>DDIC_BIND_NONE ). LR_ALV_HEADER->SET_TEXT( 'Plan Qty'). LR_ALV_HEADER->SET_HEADER_TEXT_WRAPPING( ABAP_TRUE ). LOOP AT LT_COLUMNS INTO LS_COLUMNS. ****hide fields such as CUOBJ, MATNR, AUFPL from display CASE LS_COLUMNS-ID. WHEN 'CUOBJ'. LS_COLUMNS-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ). WHEN 'MATNR'. LS_COLUMNS-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ). WHEN 'AUFPL'. LS_COLUMNS-R_COLUMN->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_NONE ). ENDCASE. ENDLOOP. ****set row count at initial display as 30 rows ****hide all empty rows LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_VISIBLE_ROW_COUNT( '30' ). LV_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_DISPLAY_EMPTY_ROWS( VALUE = ABAP_FALSE ). ENDIF. 602 Views 2 Comments Tags: web, abap, web_dynpro, alv, dynpro, shitanshu, sahai Welcome back.
Continuing from my blog - Eureka - FPM ( Floor Plan Manager ) is so simple, today was the second session in the FPM.
Today the topic of discussion was the role and implementation of feeder classes in FPM.
The concepts addressed today were as follows:
The User Interface Building Block ( UIBB ), in the FPM - FLUID editor for the component configuration can be provided with view - freestyle view using Web Dynpro component ( briefly introduced in the steps 5 in my previous blog) OR through feeder classes implementing relevant GUIBB ( Generic UIBB ) classes.
FPM provides generic WD components for FORM, LIST, TABBED etc. Ex: FPM_FORM_UIBB.
Steps to design the view using the feeder classes, are as follows:
1. Open the suitable, generic WD Component - FPM_FORM_UIBB - SE80 2. Create a Component configuration in the component and give a custom name.
3. The FLUID designer will prompt for a feeder class
3.1 Create a custom class SE24
3.2 Implement the feeder interface for form - IF_FPM_GUIBB_FORM. Eureka - FPM ( Floor Plan Manager ) is so simple - Part 2 ( Not Anymore ) Posted by Sharath M G Sep 28, 2013 3.3. Implement the following methods: GET_DEFINITION - To descibe the structure i.e. fields and buttons and events, to be made available in the screen / UIBB GET_DATA - Populate the data to the fields in the screen PROCESS_EVENT - Handle the events defined in the definition using the event ID.
4. Fill the name of the feeder class with the newly created custom feeder class.
5. The FLUID ( Flexible UI Designer ) editor will open a Excel type of designer screen.
6. Open the properties panel which lists the elements defined int he GET_DEFINITION method in the feeder class
7. Drag and drop the relevant elements and button onto screen.
Note: The properties - visual only can be modified in this editor and will override the property defined in the method Also, there is no restriction of Layout(matrix,grid etc.) in the screen design.
8. Save the configurations
9. Provide the FORM name and newly created configuration name in the FUILD editor of the component configuration created in the step 3 of my previous blog.
You can modify the view layout i.e. order of the appearance of UIBBs in the preview. Also, add more UIBBs, if necessary.
The execution of the main configuration, shows the screen with the UIBB defined.
Note, the execution of the methods in the feeder classes follows the FPM Phase Model concept( This is something of an amalgamation of WD Phase model and FPM eventing - Right now, I have little info regarding it.)
Tip: If a view contains more than 1 UIBB, then on event the PROCESS_EVENT method of all the UIBBs are invoked by the framework. Hence it is performance intensive and developer has to be very careful in the handling of events.
The FPM Apis can be used, in case the view navigation is to handled at the FPM level ex: if one UIBB event should trigger a view navigation from view 1 to view 2.
To summarize, the structuring of the components in FPM is done with a noble intention to promote better development practice. However, it is quite restrictive on the developer. It seems like SAP - FPM has decided what is the best option. Hence, discouraging any scope of manipulation. Also, the process of designing the fields using the FLUID screen designer seemed clumsy and property control at multiple points ( at feeder class level, at fluid editor level, at fpm config level etc. ) makes it difficult to track the changes.
But, Its also a good practice to think of the variables and handle them in definition thus reducing the code and promoting re-usability.
Looking forward for the next class or may be an opportunity to work on FPM.
Thank you one and all.
Regards, Sharath 662 Views 0 Comments Tags: beginner, web_dynpro, webdynpro_abap, webdynproabap, webdynpro_f or_abap, f loorplan_manager_f or_webdynpro_abap;, f loor_plan_manager_f pm To begin,
I am neither Archimedes nor do I speak ancient Greek.
My first encounter with WDA was two years ago. I had been working on Web Dynpro Java and then entered to WDA. Back then, FPM was a new concept. Since then, I have not been able to work on WDA. But, FPM has been a thorn in my brain.
Divine Intervention: Today, I was on phone near the training room and a friend of mine called me in the training. No prizes to guess the training topic. It was FPM.
HuHooo. I was thrilled. I quickly grabbed my books and went into the training. By the end of the training I feel relieved, relieved of FPM.
Cut the BS: Now, to what I understood of FPM.
Concept Understanding Scenario or Usage Eureka - FPM ( Floor Plan Manager ) is so simple Posted by Sharath M G Sep 27, 2013 (Examples) Configuration Process of controlling the behavior of the component using predefined configurations Personalization, default parameters, view display modifications etc. Types of Configurations Application Configuration - Configure application properties(macro level) Component Configuration - Configure the component context ( Code level ) View personalization, app parameters, scrolling etc.(App. Config) Modify the context values, define default values of context variables etc. ( Component Config) User Scenarios ( Use case based scenarios) SAP has identified four scenarios which are commonly used across customers, to fulfill their requirements. 1. Workflow Scenario 2. Cockpit Scenario 3. Tabular Scenario 4. Simple Data Scenario Floor Plan Floor plan is a design pattern( or template) which is a generic web dynpro component,with predefined yet configurable set of principles/properties. The Floor plan restricts/recommends the developer to follow the SAP defined implementation discipline. View - where the error are displayed at top, user interfaces are segregated into blocks and a page which is components of these blocks Generic Component This is the main component which defined the composition of content in the view. It composes of IDR(Identification Region), Tool bar, Title, and UIBB(User Interface Building Blocks). UIBB are basically containers which will hold the view developed in custom Web Dynpro components or FPM related classes. A single generic component page can contain multiple number of UIBBs Similar to a layout template. It ensures that the view composition is performed using configurations ensuring re- usability and view consistency Scenario 1 - Guided Activity Floor Plan A floor plan which is used for scenarios like workflows, approvals, step by step process. Component name: FPM_GAF_COMPONENT Scenario 2 - Overview Floor Plan A floor plan which is used for cockpit based scenarios. Component name: FPM_OVP_COMPONENT Scenario 3 - Object Instance Floor Plan A floor plan which is used for tabular data display scenarios. Component name: FPM_OIF_COMPONENT Scenario 4 - Quick Activity Floor Plan A floor plan which is used for single page display scenarios. Component name: FPM_QAF_COMPONENT FLUID - Flexible User Interface Designer Editor for FPM application configurations and their individual components. When we implement FPM, SAP provides a special designer for component configuration called as FLUID Create an application configuration in a floor plan and try to edit its component configuration. This designeris similar to a perspective in Eclipse. Based on the type of floor plan, it provides relevant options for user. Ex: Initial screen, main steps etc for GAF. UIBB - User Interface Building Block UIBBs are the basic building blocks of the FPM. UIBBs hold the custom implementation of the customer requirements. UIBBs are categorized into many types - Form type, Tab type, List Type etc. An individual component developed for a specific user requirement can be included a single UIBB. The behavior fo the component can be controlled using its configuration. We can choose the relevant config ID in the UIBB configuration Integrate custom Web Dynpro Component as UIBB To integrate the custom Web Dynpro Component as UIBB, the component needs to implement the web dynpro component interface IF_FPM_UI_BUILDING_BLOCK In the WD Component, under the implementation tab, add this interface to be implemented. GUIBB - Generic UI Building Blocks Are SAP predefined template classes which are to implemented by custom classes. The customer classes which uses these GUIBBs are known as feeder classes. A programmatic approach to implementing the user requirement. Interface: IF_FPM_GUIBB_FORM for forms, IF_FPM_GUIBB_LIST for lists etc.
Enough of the definitions. Now to the initial steps to start a FPM based implementation.
1. Open a the specific floor plan 2. Create your own application configuration. 3. In the Component configuration of your application configuration, view the FLUID designer. 4. Based on the type of floor plan, you will be able to create specific screens or steps. 5. Create a new web dynpro component - implement the interface IF_FPM_UI_BUILDING_BLOCK 6. 7. 8.
Where are the next steps?
In the next part of the blog.
But Why?
Because the next steps are covered in tomorrow's class.
[ Edit: The link to the Blog - Part 2 : Eureka - FPM ( Floor Plan Manager ) is so simple - Part 2 ( Not Anymore ) ]
Credit: To the trainer at my organization. He did a damn good job of simplifying it. ( Unless all my above understanding are incorrect )
Thank you one and all.
Regards, Sharath
P.S. How I wish there was a common space for both web dynpro java and abap developers. 876 Views 8 Comments Tags: beginner, web_dynpro, web_dynpro_abap, webdynpro_abap, webdynpro_f or_abap, f loorplan_manager_f or_webdynpro_abap;, f loor_plan_manager_f pm Downloading a SO10 text in word format(In presentation server) in wda abap. Create an input field and button on the view. In the input field user enters the SO10 text that needs to be downloaded Assign an action to this button.So that when user clicks on the button , desired So10 text should get downloaded in MS word. Downloading a SO10 text in word format(In presentation server) in wda abap. Posted by Kavita Rathore Sep 27, 2013 Then the entire coding of reading the input field and downloading the SO10 text can be done in the method ONACTIONONDOWNLOAD
Copy paste the below code in the method. method ONACTIONONDOWNLOAD . DATA lo_el_context TYPE REF TO if_wd_context_element. DATA ls_context TYPE wd_this->element_context. DATA lv_so10_text TYPE wd_this->element_context-so10_text. * get element via lead selection lo_el_context = wd_context->get_element( ). * @TODO handle not set lead selection IF lo_el_context IS INITIAL. ENDIF. * get single attribute lo_el_context->get_attribute( EXPORTING name = `SO10_TEXT` IMPORTING value = lv_so10_text ). DATA lt_lines TYPE TABLE OF TLINE. DATA wa_lines TYPE tline. *** DECLARATION OF CONSTANT CONSTANTS: lc_ID TYPE THEAD-TDID VALUE 'ST', lc_object TYPE THEAD-TDOBJECT VALUE 'TEXT'. DATA: lv_name TYPE thead-tdname. lv_name = lv_so10_text. ** CALLING OF THE STANDARD TEXTS CALL FUNCTION 'READ_TEXT' EXPORTING CLIENT = SY-MANDT ID = lc_ID LANGUAGE = sy-langu NAME = lv_name OBJECT = lc_object ARCHIVE_HANDLE = 0 LOCAL_CAT = ' ' * IMPORTING * HEADER = TABLES LINES = lt_lines EXCEPTIONS ID = 1 LANGUAGE = 2 NAME = 3 NOT_FOUND = 4 OBJECT = 5 REFERENCE_CHECK = 6 WRONG_ACCESS_TO_ARCHIVE = 7 OTHERS = 8 . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF. DATA: lv_notetmp1 TYPE string, lv_note1 TYPE string, lv_note2 TYPE xstring. loop at lt_lines into wa_lines. lv_notetmp1 = wa_lines-tdline. concatenate lv_note1 wa_lines-tdline cl_abap_char_utilities=>newline into lv_note1 SEPARATED BY space. ENDLOOP. CALL FUNCTION 'SCMS_STRING_TO_XSTRING' EXPORTING text = lv_note1 * MIMETYPE = ' ' * ENCODING = IMPORTING BUFFER = lv_note2 * EXCEPTIONS * FAILED = 1 * OTHERS = 2 . IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. CALL METHOD cl_wd_runtime_services=>attach_file_to_response EXPORTING i_filename = '.doc' i_content = lv_note2 i_mime_type = 'DOC' * i_in_new_window = ABAP_FALSE * i_inplace = ABAP_FALSE . endmethod.
Create the application and run it. The screen will appear as shown below. 131 Views 1 Comments Tags: web_dynpro Downloading SO10 text into MS word in WDA Downloading a SO10 text in word format(In presentation server) in wda abap. Create an input field and button on the view. In the input field user enters the SO10 text that needs to be downloaded Assign an action to this button.So that when user clicks on the button , desired So10 text should get downloaded in MS word.
Then the entire coding of reading the input field and downloading the SO10 text can be done in the action method say for eg ONACTIONONDOWNLOAD
Copy paste the below code in the method. method ONACTIONONDOWNLOAD . DATA lo_el_context TYPE REF TO if_wd_context_element. DATA ls_context TYPE wd_this->element_context. DATA lv_so10_text TYPE wd_this->element_context-so10_text. * get element via lead selection lo_el_context = wd_context->get_element( ).* @TODO handle not set lead selection IF lo_el_context IS INITIAL. ENDIF. * get single attribute lo_el_context->get_attribute( EXPORTING name = `SO10_TEXT` IMPORTING value = lv_so10_text ). DATA lt_lines TYPE TABLE OF TLINE. DATA wa_lines TYPE tline.*** DECLARATION OF CONSTANTCONSTANTS: lc_ID TYPE THEAD-TDID VALUE 'ST', lc_object TYPE THEAD-TDOBJECT VALUE 'TEXT'. DATA: lv_name TYPE thead-tdname. lv_name = lv_so10_text. ** CALLING OF THE STANDARD TEXTSCALL FUNCTION 'READ_TEXT' EXPORTING CLIENT = SY-MANDT ID = lc_ID LANGUAGE = sy-langu NAME = lv_name OBJECT = lc_object ARCHIVE_HANDLE = 0 LOCAL_CAT = ' '* IMPORTING* HEADER = TABLES LINES = lt_lines EXCEPTIONS ID = 1 LANGUAGE = 2 NAME = 3 NOT_FOUND = 4 OBJECT = 5 REFERENCE_CHECK = 6 WRONG_ACCESS_TO_ARCHIVE = 7 OTHERS = 8 .IF SY-SUBRC <> 0.* Implement suitable error handling hereENDIF.DATA: lv_notetmp1 TYPE string, lv_note1 TYPE string, Posted by Kavita Rathore Sep 26, 2013 lv_note2 TYPE xstring. loop at lt_lines into wa_lines. lv_notetmp1 = wa_lines-tdline. concatenate lv_note1 wa_lines-tdline cl_abap_char_utilities=>newline into lv_note1 SEPARATED BY space. ENDLOOP. CALL FUNCTION 'SCMS_STRING_TO_XSTRING' EXPORTING text = lv_note1* MIMETYPE = ' '* ENCODING = IMPORTING BUFFER = lv_note2* EXCEPTIONS* FAILED = 1* OTHERS = 2 .IF sy-subrc <> 0.* Implement suitable error handling hereENDIF. CALL METHOD cl_wd_runtime_services=>attach_file_to_response EXPORTING i_filename = '.doc' i_content = lv_note2 i_mime_type = 'DOC'* i_in_new_window = ABAP_FALSE* i_inplace = ABAP_FALSE . endmethod.
Create the application and run it.
101 Views 0 Comments Tags: web_dynpro This document explains how to read contents from .xlsx file. It explains reading file contents from .xlsx file by code snippets. Following are the steps explaining the procedure:- 1. Define a Web Dynpro component with name for example ZZDEV_WD_TEST. 2. Define File Upload UI element and a Button UI element in the main view. 3. Create context node with attributes FILENAME (string), FILETYPE (string), FILECONTENTS (xstring). Upload/Read .xlsx file in SAP Web Dynpro Posted by Devesh Singh Aug 28, 2013 4. Bind these to the File Upload UI element. Bind FILECONTENTS to DATA attribute, FILENAME to FILENAME attribute and FILETYPE to MIMETYPE attribute. 5. Browse the .xlsx file and click on upload button. 6. On action of upload button read the context node defined in step 3. 7. Follow below code to read the browsed .xlsx file. * Internal tables declaration DATA: lt_worksheets TYPE STANDARD TABLE OF string, lt_contents TYPE string_table, lt_final_contents TYPE <target structure table type>.
* Structures declarations DATA: ls_return TYPE bapiret1, ls_contents TYPE <target structure>, ls_file_upload TYPE wd_this->element_file_upload.
* Local variables declaration DATA: lv_name TYPE string, lv_string TYPE string, lv_msg TYPE string, lv_flag TYPE boolean, lv_message TYPE string.
* References declarations DATA: lref_excel TYPE REF TO cl_fdt_xl_spreadsheet, lref_excel_core TYPE REF TO cx_fdt_excel_core, lref_data TYPE REF TO data, lref_dref TYPE REF TO data, lo_nd_file_upload TYPE REF TO if_wd_context_node, lo_el_file_upload TYPE REF TO if_wd_context_element.
* Field symbols declarations FIELD-SYMBOLS: <fs_table> TYPE table, <fs_data> TYPE any, <fs_data_str> TYPE any, <fs_comp> TYPE any, <fs_output> TYPE string.
* navigate from <CONTEXT> to <FILE_UPLOAD> via lead selection lo_nd_file_upload = wd_context->get_child_node( name = wd_this->wdctx_file_upload ).
* get element via lead selection lo_el_file_upload = lo_nd_file_upload->get_element( ).
* get all declared attributes lo_el_file_upload->get_static_attributes( IMPORTING static_attributes = ls_file_upload ).
TRY. * Create object of class to read .xlsx file contents CREATE OBJECT lref_excel EXPORTING document_name = ls_file_upload-filename xdocument = ls_file_upload-filecontents.
CATCH cx_fdt_excel_core INTO lref_excel_core. CLEAR lv_msg.
* Call method to get error message text CALL METHOD lref_excel_core->if_message~get_text RECEIVING result = lv_msg. *<< Display error message returned in lv_msg >> RETURN.
ENDTRY.
* Call method to get list of worksheets in the .xlsx file lref_excel->if_fdt_doc_spreadsheet~get_worksheet_names( IMPORTING worksheet_names = lt_worksheets ).
* Condition to check whether .xlsx file has any active worksheets IF lt_worksheets IS NOT INITIAL. * Read active worksheet READ TABLE lt_worksheets INDEX 1 INTO lv_ws_name. ELSE. *<< Display error message >> RETURN.
ENDIF.
* Get reference of .xlsx file contents in the active worksheet lref_data = lref_excel->if_fdt_doc_spreadsheet~get_itab_from_worksheet( lv_name).
* Fetch all records in the active worksheet ASSIGN lref_data->* TO <fs_table>.
* Prepare exporting table with .xlsx file contents IF <fs_table> IS NOT ASSIGNED. *<< Display error message >> RETURN. ENDIF.
* Loop dynamic table to prepare final table contents to pass in exporting parameter LOOP AT <fs_table> ASSIGNING <fs_data>. * Initialize flag lv_flag = abap_true.
WHILE lv_flag = abap_true. * Read columnwise entries ASSIGN COMPONENT sy-index OF STRUCTURE <fs_data> TO <fs_comp>. IF <fs_comp> IS NOT ASSIGNED. lv_flag = abap_false. * Exit the loop when a row ends EXIT. ELSE. * Concatenate each cell data in a row into string seperated by '||' CONCATENATE lv_string <fs_comp> INTO lv_string SEPARATED BY '||'.
ENDIF.
* Unassign field symbol UNASSIGN <fs_comp>.
ENDWHILE.
* Shift final string having a row left by 2 places to remove leading '||' SHIFT lv_string LEFT BY 2 PLACES.
* Append prepared row data to exporting parameter APPEND lv_string TO lt_contents.
* Clear variable having row data CLEAR lv_string.
ENDLOOP.
* Loop internal table to split records and fill in target internal table LOOP AT lt_contents ASSIGNING <fs_output>. * Split file contents returned at '||' SPLIT <fs_output> AT '||' INTO ls_contents-col1 ls_contents-col2 ls_contents-col3.. * Append split records in internal table APPEND ls_contents TO lt_final_contents.
ENDLOOP.
Follow SCN Site Index Contact Us SAP Help Portal Privacy Terms of Use Legal Disclosure Copyright 7. Contents will be appended to internal table LT_FINAL_CONTENTS. Define a structure in SE11 with fields corresponding to upload file structure and declare LS_CONTENTS of this type. Define a table type in SE11 with this structure and declare LT_FINAL_CONTENTS of this type. 8. Finally LT_FINAL_CONTENTS will have all the records present in the browsed .xlsx file.