on 10-09-2013 2:08 PM
Hey everybody,
i'm working on my bachelor-thesis. I have to develop a Web Dynpro Prototyp but i'm new in ABAP Developing.
A requirement to the Protyp is that the user can open the attachted documents to a material number.
We use a function module which show me a list of all attached documents in a normal Dynpro. With the following Code i tested to display the documents. But I know that i can't use this function module in Web Dynpro.
REPORT Z_GET_DOCUMENTS.
PARAMETERS matnr TYPE mara-matnr.
DATA: gs_draw TYPE DRAD.
SELECT SINGLE *
FROM drad
INTO CORRESPONDING FIELDS OF gs_draw
WHERE dokob = 'MARA'
AND objky = matnr
AND delflag = space.
CALL FUNCTION 'CV141_SHOW_LINK_DOCUMENT'
EXPORTING
ps_drad_objky = gs_draw-objky
ps_drad_dokob = 'MARA'.
__________________________________________________________________________________________________
So i tried to get the documents links in a WebDynpro with following code:
METHOD onactionget_zeichnung .
*TYPEDECLARATIONS
DATA input_node TYPE REF TO if_wd_context_node.
DATA materialnummer TYPE mara-matnr.
*lokale persistente Objektreferenz - BOR kompatibel
DATA gs_bor TYPE sibflporb.
* Read the links
DATA: t_linktabelle TYPE obl_t_link,
la_links LIKE LINE OF t_linktabelle.
* Selectoptions für Beziehungstypen
DATA: lt_relat TYPE obl_t_relt,
ls_relat LIKE LINE OF lt_relat.
*Exception
DATA lo_root TYPE REF TO cx_root.
*navigate from CONTEXT to IDENTIFY_NODE via lead_section
input_node = wd_context->get_child_node( 'IDENTIFY' ).
*GET NOTIFACTION VALUE
input_node->get_attribute( EXPORTING name = 'MATN' IMPORTING value = materialnummer ).
*BO Key setzen
gs_bor-instid = materialnummer.
gs_bor-typeid = 'BUS1001'.
gs_bor-catid = 'BO'.
* Suchoptionen setzen
ls_relat-sign = 'I'.
ls_relat-option = 'NE'.
ls_relat-low = ''.
APPEND ls_relat TO lt_relat.
*Links lesen
TRY.
CALL METHOD cl_binary_relation=>read_links
EXPORTING
is_object = gs_bor
it_relation_options = lt_relat
IMPORTING
et_links = t_linktabelle.
CATCH cx_root INTO lo_root.
ENDTRY.
ENDMETHOD.
But the "t_linktabelle" is always emtpy. I also tried another BUS the BUS100106 but without any positiv result.
Maybe one of you can help me with my problem.
Thanks a lot.
Alexander
Hey,
i found out that our files which are attached to the material number are all stored in the archive i think that is something else then dms?
So i think the posibilities you show will not work?
I found a thread https://scn.sap.com/thread/991533 which describes how to open an archived document.
But i don't understand how i can get arc_id and doc_id over materialnumber. I know that the Objecttype is DRAW and the linkage table is TOA01, look here: http://help.sap.com/saphelp_46c/helpdata/de/d7/e21cd0408e11d1896b0000e8322d00/content.htm
Maybe you have an another idea? I would be very glad about your help!
Thank you.
Regards
Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I saw your responses today.
Once you have all the URLS then follow second part of step 2.
Step 2:
Fill the urls in an internal table.
Step 3:
Make sure that the View has a TABLE with a field of type 'Link to URL'. (Image 1)
Reference attribute/property of that field should point to the element of the context node which has the data from Step2. (Image 2)
The attribute 'Type' should have value 'Navigation'. (Image 2)
If it is a PDF document then it will open in a new window or tab of your browser but you should make sure that the browser supports PDF display.
Let me explain with screenshots.
Image 1
Image 2
Please let me know if you have further questions.
I can also explain the function
SDOK_PHIO_GET_URL_FOR_GET
but if you have the path already from draw table then it is better to directly access it using select statements on table DRAW.
Regards
Anurag
Hi Anurag,
thank you for your replay. I tested the way you describe. I tried to solve the problem with the example described in the link below:
http://saptechnical.com/Tutorials/WebDynproABAP/url/Index.htm but i alwas get exception with typeconflict.
I also tried to open the link from DRAW Table in external window but i get an error message that the file could have malicious script. Any other ideas?
Regards
Alexandert
Hi,
Alexander I know the problem that you are facing. It will require a step by step demo from my side.
Since it will consume considerable time to create a demo,
I suggest a workaround which suits your requirement. This method is a bit longer but useful.
This method is for purchase documents but you can understand the code and modify the select query in step 1 to fetch materials later. This code has worked for others as well.
I request you to follow the steps exactly as described in this document and understand the concept explained. Make sure that you get all the results that the writer is getting.
Step 1:
http://webdynproabap.wordpress.com/2012/10/28/a-simple-alv-report/
Step 2 :
http://webdynproabap.wordpress.com/2012/10/30/alv-with-link-to-action/
Step 3 :
After you get the desired result then go back to the place in step 2 where you have coded the following:
and remove the code after that.
We have received the value in ALV on which the user has clicked.
(For your requirement, it means that at this point in time we have received the material number).
Once we have the material number then it means that you have to fetch the URL corresponding to that material. Instead of fetching the URL for the material in table draw, I suggest that you first try to
open any random URL to understand whether the logic is working or not.
For this, copy paste the following code and activate the entire webdynpro component and let me know if the site opened successfully.
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://www.google.com/'
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( ).
Regards
Anurag
Hi Anurag,
thank you for your instruction. I Solved the problem on an other way.
I have the path to the file. So i replaced the network drive character with FQDN. After that i can read the file with data set in xstring and so i could display the file in an interactive form.
Thank you very very very much for your help.
The next Questions will follow
Regards
Alexander
Hi Alexander,
You are right. You can not use FM to the Webdynpro until it's Remote-Enabled is activated for it.
You need to check any BAPI for this or direct query to the table using Material no.
May be you can use: BAPI_DOCUMENT_GETOBJECTDOCS for your purpose, try to check with your reqirement.
For opening POPUP in the Webdynpro application, do the steps below:
1. Create one view with required UI Element to display
2. Create one Window in the same component
3. Embed this View to the window:
4. Write the code below on the action with which you want to open popup:
**************
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.
data: lr_view_controller type ref to if_wd_view_controller.
lo_api_component = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).
lo_window = lo_window_manager->create_window(
window_name = 'W_BUCKET'
* title =
* close_in_any_case = abap_true
message_display_mode = if_wd_window=>co_msg_display_mode_selected
* close_button = abap_true
* button_kind = if_wd_window=>co_buttons_okClose
button_kind = if_wd_window=>CO_BUTTONS_OKCANCEL
message_type = if_wd_window=>co_msg_type_none
* default_button = if_wd_window=>co_button_ok
).
wd_comp_controller->go_window = lo_window.
lr_view_controller = wd_this->wd_get_api( ).
lo_window->subscribe_to_button_event(
button = if_wd_window=>co_button_ok
button_text = 'Confirm'
action_name = 'YYYY'
action_view = lr_view_controller ).
*wd_comp_controller->go_window = lo_window.
lo_window->open( ).
******************************************************
Here, Action YYYY is to be defined in the view from where you are calling that popup. This Action will be triggered after 'confirming' the pop window.
Hope, this will help you.
Regards,
chandan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey chandan,
thank you for your reply. I will try to develop your example.
Our documents are stored in the archiv and are linked with the material number.
I found two FMs "SCMS_DOC_READ" and "BAPI_DOCUMENTS_GETDETAIL2" which could help me, maybe.
1. Posibility:
With the Pop-Up I want to display a list with all attached documents. The User should open the Document with the installed Viewer. Is this possible at all? With the FM I posted bellow I can do this.
2. Posibility:
Open the Document with a button wich is linked with the material number.
For example we have CAD-Documents (*.ME1, *.DFT), PDFs and WORD Documents.
Thank you for your help.
Regards
Alexander
Hello Alexander,
I do not have clear idea of the BAPI you listed above. You can check them separately with SE37.
Or if you are using any Ztable to archive your document with material no, you can directly fire the query. (Use the best suitable method).
For opening the POPUP use code I have provided in my previous post.
For Opening the Document (.Text or .PDF) use UI element FILEDOWNLOAD on Button event.
Hope you find your solution..
Regards,
Chandan
Hi Alexander,
Step 1:
You will get the document list from BAPI_DOCUMENT_GETDETAIL2 as you correctly pointed out.
Step 2:
Then after Getting the document list, you can get urls using function
SDOK_PHIO_GET_URL_FOR_GET
Fill the urls in an internal table.
Step 3:
Make sure that the View has a TABLE with a field of type 'Link to URL'.
Reference attribute of that field should point to the element of the context node which has the data
from Step2.
The attribute 'Type' should have value 'Navigation'.
If it is a PDF document then it will open in a new window or tab of your browser but you should make sure that the browser supports PDF display.
Regards
Anurag
Ok i'm trying to test your solultion way.
Call BAPI_DOCUMENT_GETDETAIL2 is no problem. I just select one document wich is attached to material number. This document is a pdf.
But i don't understand step 2.
so i tried this but with error: CX_SY_DYN_CALL_ILLEGAL_TYPE (from ST22)
METHOD onactionget_zeichnung .
*TYPEDECLARATIONS
DATA input_node TYPE REF TO if_wd_context_node.
DATA materialnummer TYPE mara-matnr.
DATA lt_draw TYPE DRAW.
DATA lt_drad TYPE DRAD.
DATA ls_documentdata TYPE BAPI_DOC_DRAW2.
DATA lt_urls TYPE SDOKCOMPURLS.
DATA lv_doc_url TYPE SAEURI.
*navigate from CONTEXT to IDENTIFY_NODE via lead_section
input_node = wd_context->get_child_node( 'IDENTIFY' ).
*GET NOTIFACTION VALUE
input_node->get_attribute( EXPORTING name = 'MATN' IMPORTING value = materialnummer ).
SELECT * FROM DRAD INTO lt_drad WHERE OBJKY = materialnummer AND DOKAR = 'ZBA'.
ENDSELECT.
SELECT * FROM DRAW INTO lt_draw WHERE DOKNR = lt_drad-doknr.
ENDSELECT.
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = lt_draw-dokar
documentnumber = lt_draw-doknr
documentpart = lt_draw-doktl
documentversion = lt_draw-dokvr
* GETOBJECTLINKS = ' '
* GETCOMPONENTS = ' '
* GETSTATUSLOG = ' '
* GETLONGTEXTS = ' '
* GETACTIVEFILES = 'X'
* GETDOCDESCRIPTIONS = 'X'
* GETDOCFILES = 'X'
* GETCLASSIFICATION = ' '
* GETSTRUCTURE = ' '
* GETWHEREUSED = ' '
* HOSTNAME = ' '
* INHERITED = 'X'
IMPORTING
DOCUMENTDATA = ls_documentdata
* RETURN =
* TABLES
* OBJECTLINKS =
* DOCUMENTDESCRIPTIONS =
* LONGTEXTS =
* STATUSLOG =
* DOCUMENTFILES =
* COMPONENTS =
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
* DOCUMENTSTRUCTURE =
* WHEREUSEDLIST =
.
CALL FUNCTION 'SDOK_PHIO_GET_URL_FOR_GET'
EXPORTING
object_id = ls_documentdata
* REQUESTED_COMPONENTS =
* CLIENT = SY-MANDT
* STANDARD_URL_ONLY =
* DATA_PROVIDER_URL_ONLY =
* WEB_APPLIC_SERVER_URL_ONLY =
* URL_LIFETIME =
* URL_USED_AT =
* NO_CACHE =
IMPORTING
URLS = lt_urls
DOCUMENT_URL = lv_doc_url
* EXCEPTIONS
* NOT_EXISTING = 1
* NOT_AUTHORIZED = 2
* NO_CONTENT = 3
* BAD_STORAGE_TYPE = 4
* NO_URLS_AVAILABLE = 5
* OTHERS = 6
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
This is the Function sdok_phio_get_url_for_get.
FUNCTION sdok_phio_get_url_for_get.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(OBJECT_ID) LIKE SDOKOBJECT STRUCTURE SDOKOBJECT
*" VALUE(REQUESTED_COMPONENTS) TYPE SDOKCOMPOS OPTIONAL
*" VALUE(CLIENT) LIKE SY-MANDT DEFAULT SY-MANDT
*" VALUE(STANDARD_URL_ONLY) LIKE SY-DATAR OPTIONAL
*" VALUE(DATA_PROVIDER_URL_ONLY) LIKE SY-DATAR OPTIONAL
*" VALUE(WEB_APPLIC_SERVER_URL_ONLY) LIKE SY-DATAR OPTIONAL
*" VALUE(URL_LIFETIME) TYPE C OPTIONAL
*" VALUE(URL_USED_AT) TYPE SDOK_FBURL OPTIONAL
*" VALUE(NO_CACHE) LIKE SY-DATAR OPTIONAL
*" EXPORTING
*" VALUE(URLS) TYPE SDOKCOMPURLS
*" VALUE(DOCUMENT_URL) TYPE SAEURI
*" EXCEPTIONS
*" NOT_EXISTING
*" NOT_AUTHORIZED
*" NO_CONTENT
*" BAD_STORAGE_TYPE
*" NO_URLS_AVAILABLE
But i don't know what i have to use for the importing parameter. I have to import a SDOKOBJECT structure but where i get the class and objid. And which type must the internal table have?
And step3 i also don't really understand. Ok i can create Table but with Type Link To Url? how? Ok this field should refer to the Url from step2. And what you mean whith: The attribute 'Type' should have value 'Navigation'.?
Maybe you cann explain it to me. I would be very happy about because i have not so much time for my bachelor-thesis.
Thank you very very much.
Regards Alex
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.