on 01-20-2011 1:23 PM
1. How to upload a Excel or PDF file into SAP through ABAP WedDynpro?
Upload file name convention is <salesordernumber>_<itemnumber>_YYYYMMDD.xls or
<salesordernumber>_<itemnumber>_YYYYMMDD.pdf
2. There is a sales order report which contains header and item details. With addition to these details there is 'Reamrks'
column. Previous uploaded filename (it can appear either as icon with file name or just file name with file type) needs to
display in reamrks column.
Can anybody help me how to do part 2? I know only how to do part 1.
Regards,
Meera.
Do you want to upload the file and store it as a file or do you want to read the contents of the excel and upload it to a table?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes,
When you click on file name in the output(Table UI element used for data display). Remarks Cell Property in the table is LinkToAction. When you click on the string in this cell then the program has to read file stored in the Application server and open-up for viewing. I mean how to read file that uploaded to Data Management System? Please let me know if you need more details. Thank you!
Regards,
Meera.
hi meera,
note do remeber that ._XLS file cannot be uploaded in WDA_ instead you will have to go for .csv format after taking this in consideration try the following.
(1). Define one Context attribute,for example you can name it as "DATASOURCE". In addition , you can define one node named "table" to hold the information of your EXCEL. pls take attention to the format/structure.
(2).Using the UI element "FileUpload", then bind the property "data" to the context attribute declared in 1st step.
Off course, maybe you need one button name "Upload" to trigger the action which will upload the EXCEL.
(3).in the action of the button(or anyother action only if you use it to upload), using the following example code:
method ONACTIONUPLOAD .
DATA:
lo_Node type ref to If_Wd_Context_Node,
lo_Elem type ref to If_Wd_Context_Element,
lw_datasour type xstring,
lw_string type string,
lt_data type TABLE OF string,
lt_field type TABLE OF string,
lv_field TYPE string,
ls_context type wd_this->element_TABLE,
lt_context type wd_this->elements_TABLE .
* get the datasource Xstring
wd_context->get_attribute(
EXPORTING
name = 'DATASOURCE'
IMPORTING
value = lw_datasour ).
* convert the XString ==> string
* CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
* EXPORTING
* IM_XSTRING = lw_datasour
* IM_ENCODING = 'UNICODE'
* IMPORTING
* EX_STRING = lw_string.
DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = lw_datasour
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = conv.
conv->READ( importing data = lw_string ).
* get the data of file
split lw_string at cl_abap_char_utilities=>newline into TABLE lt_data.
* delete the header
DELETE lt_data INDEX 1.
* get all the field name
LOOP AT lt_data into lw_string.
SPLIT lw_string at cl_abap_char_utilities=>horizontal_tab into table lt_field.
***get all the 3 fields of one line
READ TABLE lt_field INTO lv_field INDEX 1.
ls_context-carrid = lv_field.
READ TABLE lt_field INTO lv_field INDEX 2.
ls_context-connid = lv_field.
READ TABLE lt_field INTO lv_field INDEX 3.
ls_context-text = lv_field.
append ls_context to lt_context.
ENDLOOP.
* bind table
lo_node = wd_context->get_child_node( 'TABLE' ).
lo_node->bind_table( lt_context ).
endmethod.
regards,
sahai.s
Edited by: sahai.s on Jan 21, 2011 5:16 AM
Hi ,
Thank you so much for the reply with code!
One more question....
There are two windows and each have few few views placed in it. When I perform some action from Window 1 then current application will be able to openup a separate Browser Window with information in the Window2. Is it possible to create a URL for a specific window at runtime? Any ideas please....
Regards,
Meera.
hi meera,
yes it is possible to navigate between the windows
create 2 windows namely WINA,WINB. and 2 views namely VIEWA VIEWB. embed VIEW A in WINA and VIEWB in WINB.
Suppose u want to open second WINB from WINA .
DATA: lr_view TYPE REF TO if_wd_view_controller,
lr_api_main TYPE REF TO if_wd_component,
lr_window_man TYPE REF TO if_wd_window_manager.
l_window2 type REF TO IF_WD_WINDOW.
lr_view = wd_this->wd_get_api( ).
lr_api_main = wd_comp_controller->wd_get_api( ).
lr_window_man = lr_api_main->get_window_manager( ).
*Creating the Popup Window
CALL METHOD lr_window_man->create_window
EXPORTING
modal = abap_true
window_name = 'WINB'
title = 'Demo example'
close_button = abap_true
RECEIVING
window = wd_comp_controller->l_window2.
wd_comp_controller->l_window2->open( ).
regards,
sahai.s
Edited by: sahai.s on Jan 21, 2011 8:17 AM
Hi Sahai,
My requirement is not calling a dailog box. Instead of it, I want show window 2 information in a new web browser".
Here is more details.
http://help.sap.com/saphelp_rc10/helpdata/en/45/c87f413e70010de10000000a1550b0/content.htm
Please open above link and place mouse cursor on Cross-Component Programming text and right click on it. You will see a context menu with some option. Click on 'Open in a New Window'. When you choose this option more details about the selected information will be shown in a separate internet explorer window.
This is what I want. Hope you got it what I mean.
hi meera,
see when you talk about Cross-Component Programming the scene is quite different you will have to provide the URL of the second component in the first component so the second component will open in another browser.....i am sharing the code as below...try this on the action of a button,link or anything else it will work fr sure.
method ONACTIONCONFIGURATION .
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER.
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT.
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW.LO_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).
LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).
CALL METHOD LO_WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW
EXPORTING
URL = 'http://forums.sdn.sap.com/post!reply.jspa?messageID=9927612'
MODAL = ABAP_FALSE
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW.LO_WINDOW->OPEN( ).
IF SY-SUBRC EQ 0.
ENDIF.
endmethod.
this code once pasted in your development will open this very thread in another browser because we have provided the url. so if you want to open another component just provide the url there .....hope you got this
thanks and regards,
sahai.s
Hi Sahai,
Thank you! Yeah. It is possible with the help of cross component. I do not know how to pass values from one component to other component. Could you please tell me how to pass parameters from component1 to other component2? So that I can use inputs entered in the first component in component 2 for further process in it.
Thank you so much for the help!
Regards,
Meera.
hi meera,
whenever we talk about tranfer of value/data in web dypro we do it using context nopde/attribute.......now coming to your case...
in the first component make a node and make it as a interface node ...(hope you know how to make the node as interface node if not tell me).
set the value n this node .....now open the second componet where you want to transfer the value to ..in property tab mention the name of componet 1 here just liike we mention whenever we use alv(hope you have done this also if not tell me).....now doing this in the context tab you will be able to get the interface attribute you made in the component 1....now you can read it...using the code wizard...
Caution:....do not use simple get_static_attribute method to read it .....instead use Get_attribute......you will get your value transported.
thanks and regards,
sahai.s
You can use interface node in the component 2.
for this create a node in then component controller of compoennt 2 and there check the tick box interface node and
this node then will be available in the interface controller.
now when in the comp 1 you use this compoennt as used component . then you can access the interface contorller context there in any view or comp controller by adding this interface controller in the used controller list.
so set the context there in comp 1 and you can access it in comp 2.
thanks
sarb
Hi Sahai,
I fallowed your instructions and able to call Component2 in a seperatre browser
but unable to see the value. Please see below sample piece of design and code
and correct me. Variable lv_contract_number contains null value.
Creating Application 2
Go to SE80,
Step1.
Create Webdynpro Componet:
Name: ZAPPLICATION2
Description: Application 2(Data Receiver)
Type: Web Dynpro Component
Window Name: ZAPPLICATION2
View Name: MAIN2
Save and Activate Component
Step2.
Create WebDynpro Application:
Place the mouse cursor on component name(ZAPPLICATION2) and
right click and choose CREATE->Webdynpro Application
In the pop-up box enter enter applicaiton name and description
Application: ZBROWSER_TAB2
Name: Example program 2
Save and Activate Component
Step3.
Create a node in COMPONENT CONTROLLER
Click on 'COMPONENT CONTROLLER' and go to context tab & create a node with field 'CONTRACT_NUMBER'.
Attribute property is 'EBELN'
Node Name: ZCONTRACT_DETAIILS
Attribute Name: CONTRACT_NUMBER
Go to property tab of node and check the field "Interface Node"
SAVE the application.
Step4.
View design
Go the View "MAIN2" and Place a UI Element 'INPUT'.
Bind the attribute "CONTRACT_NUMBER" to 'value' parameter in the properties tab.
Go to "Methods" tab in the same view and write below code in the "WDDOINIT" method
DATA lo_nd_contract_detaiils TYPE REF TO if_wd_context_node.
DATA lo_el_contract_detaiils TYPE REF TO if_wd_context_element.
DATA ls_contract_detaiils TYPE wd_this->element_contract_detaiils.
DATA lv_contract_number TYPE wd_this->element_contract_detaiils-contract_number.
lo_nd_contract_detaiils = wd_context->get_child_node( name = wd_this->wdctx_contract_detaiils ).
lo_el_contract_detaiils = lo_nd_contract_detaiils->get_element( ).
get single attribute
lo_el_contract_detaiils->get_attribute(
EXPORTING
name = `CONTRACT_NUMBER`
IMPORTING
value = lv_contract_number ).
"=========================================
Creating Application 1
Go to SE80,
Step1.
Create Webdynpro Componet:
Name: ZAPPLICATION1
Description: Application 1(Data Sender)
Type: Web Dynpro Component
Window Name: ZAPPLICATION1
View Name: MAIN1
Save and Activate Component
Step2.
Create WebDynpro Application:
Place the mouse cursor on component name(ZAPPLICATION1) and
right click and choose CREATE->Webdynpro Application
In the pop-up box enter enter applicaiton name and description
Application: ZBROWSER_TAB1
Name: Example program 1
Save and Activate Component
Step3.
Create a interface node in COMPONENT CONTROLLER
Click on 'COMPONENT CONTROLLER' and go to context tab & create a node with field 'CONTRACT_NUMBER'.
Attribute property is 'EBELN'
Node Name: ZCONTRACT_DETAIILS
Attribute Name: CONTRACT_NUMBER
Go to property tab of node and check the field "Interface Node"
SAVE the application.
Step4.
View design
Go the View "MAIN1" and Place Two UI Elements 'INPUT', 'LABEL' & 'BUTTON'.
Go to properties tab of UI Element "INPUT' and Bind the attribute "CONTRACT_NUMBER"
to 'value' parameter in the properties tab.
Button name is "Call Application 2"
On Action (Event) for the button (call application 2) is 'APP2'.
Go to "Actions" tab and click on event "APP2" and write below code to call application 2.
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER.
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT.
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW.LO_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).
LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).
CALL METHOD LO_WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW
EXPORTING
URL = 'HTTPS://XXXXXXXXXXXXXXXXXXX/xyz'
MODAL = ABAP_FALSE
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW.LO_WINDOW->OPEN( ).
IF SY-SUBRC EQ 0.
ENDIF.
save, activate and run the application.
Now you can see input field and a button with text "Call Application 2".
Enter '100002' in inputfield and click on button.
Then you will see second application in a separate browser.
Hello,
in the compnent 1 here is the problem.
Step3.
Create a node in COMPONENT CONTROLLER
Click on 'COMPONENT CONTROLLER' and go to context tab & create a node with field 'CONTRACT_NUMBER'.
Attribute property is 'EBELN'
Node Name: ZCONTRACT_DETAIILS
Attribute Name: CONTRACT_NUMBER
Go to property tab of node and check the field "Interface Node"
SAVE the application.
no need of creating an interface node there, you just need to map the interface node of comp 2 which will be available in the
interface controller.
for that you need to add the comp 2 in the used comp list in the comp 1.
follow the following steps.
1. go to comp 1.
2. double click on th cmponent name and then add Component 2 as used component there.
3. save it and interface controller of comp 2 will be available.
4. go to the view and context tab there click on used controller and add the interface controller of comp2 as used controller.
5. now on the right hand side you can see the interface node created in the comp2.
6. map it to some local node present in the comp1 view or just drag it from there to the LHS and it will create a new one.
now you can set the value which will be replicated in the interface node and then in the input field of comp 2.
thanks
sarbjeet singh
hi meera,
just check that are you using the same node in both the components....only in one of the application you have to make the node as interface and then after declaring the name of the component in second component you will make the node usable in that component also.also remember that using get_static_attributes and set_static attributes wont work because the values will be lost as the control leaves the program1...so to prevent this use get_attribute....
regards,
sahai.s
Hi Sarbjeet Singh,
Sahai,
I would like to say thank you for your effort.
To move data from one component to other, you have to pass input value(s) with URL of the called component to
CALL METHOD lo_window_manager->create_external_window method. cl_http_server=>append_field_url method can be used to concatenate field name and value.
Go to called coponent(Component 2) WDDOINIT Method can import the values that exported with the URL.
{
Creating Application 1
Go to SE80,
Step1.
Create Webdynpro Componet:
Name: ZAPPLICATION1
Description: Application 1(Data Sender)
Type: Web Dynpro Component
Window Name: ZAPPLICATION1
View Name: MAIN1
Save and Activate Component
Step2.
Create WebDynpro Application:
Place the mouse cursor on component name(ZAPPLICATION1) and
right click and choose CREATE->Webdynpro Application
In the pop-up box enter enter applicaiton name and description
Application: ZBROWSER_TAB1
Name: Example program 1
Save and Activate Component
Step3.
Create a interface node in COMPONENT CONTROLLER
Click on 'COMPONENT CONTROLLER' and go to context tab & create a node with field 'CONTRACT_NUMBER'.
Attribute property is 'EBELN'
Node Name: ZCONTRACT_DETAIILS
Attribute Name: CONTRACT_NUMBER
SAVE the application.
Step4.
View design
Go the View "MAIN1" and Place Two UI Elements 'INPUT', 'LABEL' & 'BUTTON'.
Go to properties tab of UI Element "INPUT' and Bind the attribute "CONTRACT_NUMBER"
to 'value' parameter in the properties tab.
Button name is "Call Application 2"
On Action (Event) for the button (call application 2) is 'APP2'.
Go to "Actions" tab and click on event "APP2" and write below code to call application 2.
"Get attribute value entered in the field 'CONTRACT_NUMBER'
DATA lo_nd_zcontract_detaiils TYPE REF TO if_wd_context_node.
DATA lo_el_zcontract_detaiils TYPE REF TO if_wd_context_element.
DATA ls_zcontract_detaiils TYPE wd_this->element_zcontract_detaiils.
DATA lv_contract_number TYPE wd_this->element_zcontract_detaiils-contract_number.
lo_nd_zcontract_detaiils = wd_context->get_child_node( name = wd_this->wdctx_zcontract_detaiils ).
lo_el_zcontract_detaiils = lo_nd_zcontract_detaiils->get_element( ).
get single attribute
lo_el_zcontract_detaiils->get_attribute(
EXPORTING
name = `CONTRACT_NUMBER`
IMPORTING
value = lv_contract_number ).
"Passing values from component1 to component 2 with URL of component2.
DATA: lv_derive_url TYPE string,
lv_valuepass TYPE string.
"Get the URL of the called application(component2)
CALL METHOD cl_wd_utilities=>construct_wd_url
EXPORTING
application_name = 'ZAPPLICATION2'
IMPORTING
out_absolute_url = lv_derive_url.
" Attach the attribute and it's value with the URL
lv_valuepass = lv_contract_number.
CALL METHOD cl_http_server=>append_field_url
EXPORTING
name = 'CONTRACT_NUMBER'
value = lv_valuepass
CHANGING
url = lv_derive_url.
DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER.
DATA LO_API_COMPONENT TYPE REF TO IF_WD_COMPONENT.
DATA LO_WINDOW TYPE REF TO IF_WD_WINDOW.LO_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).
LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).
CALL METHOD LO_WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW
EXPORTING
URL = lv_derive_url "URL with values
MODAL = ABAP_FALSE
HAS_MENUBAR = ABAP_TRUE
IS_RESIZABLE = ABAP_TRUE
HAS_SCROLLBARS = ABAP_TRUE
HAS_STATUSBAR = ABAP_TRUE
HAS_TOOLBAR = ABAP_TRUE
HAS_LOCATION = ABAP_TRUE
RECEIVING
WINDOW = LO_WINDOW.LO_WINDOW->OPEN( ).
IF SY-SUBRC EQ 0.
ENDIF.
}
Creating Application 2
{
Go to SE80,
Step1.
Create Webdynpro Componet:
Name: ZAPPLICATION2
Description: Application 2(Data Receiver)
Type: Web Dynpro Component
Window Name: ZAPPLICATION2
View Name: MAIN2
Save and Activate Component
Step2.
Create WebDynpro Application:
Place the mouse cursor on component name(ZAPPLICATION2) and
right click and choose CREATE->Webdynpro Application
In the pop-up box enter enter applicaiton name and description
Application: ZBROWSER_TAB2
Name: Example program 2
Save and Activate Component
Step3.
Create a node in COMPONENT CONTROLLER
Click on 'COMPONENT CONTROLLER' and go to context tab & create a node with field 'CONTRACT_NUMBER'.
Attribute property is 'EBELN'
Node Name: ZCONTRACT_DETAIILS
Attribute Name: CONTRACT_NUMBER
SAVE the application.
Step4.
View design
Go the View "MAIN2" and Place a UI Element 'INPUT'.
Bind the attribute "CONTRACT_NUMBER" to 'value' parameter in the properties tab.
Go to "Methods" tab in the same view and write below code in the "WDDOINIT" method
"Declare a local variable to import value that exported in Component 1
DATA:
lv_contract_num type string.
lv_contract_num =
wdr_task=>client_window->get_parameter( 'CONTRACT_NUMBER' ).
"Here 'CONTRACT_NUMBER' is the attribute in the componenet 1
"Set the imported value to screen attribute.
DATA lo_nd_contract_detaiils TYPE REF TO if_wd_context_node.
DATA lo_el_contract_detaiils TYPE REF TO if_wd_context_element.
DATA ls_contract_detaiils TYPE wd_this->element_contract_detaiils.
DATA lv_contract_number TYPE wd_this->element_contract_detaiils-contract_number.
navigate from <CONTEXT> to <CONTRACT_DETAIILS> via lead selection
lo_nd_contract_detaiils = wd_context->get_child_node( name = wd_this->wdctx_contract_detaiils ).
lo_el_contract_detaiils = lo_nd_contract_detaiils->get_element( ).
set single attribute
lv_contract_number = lv_contract_num.
lo_el_contract_detaiils->set_attribute(
name = `CONTRACT_NUMBER`
value = lv_contract_number ).
}
Now Run the application 1, enter some value in input field and click Action buttion on the screen. Now you will second application with value entered in the calling application.
Thanks a lot to all.
Regards,
Meera.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.