One morning, after arriving at the office, I was browsing emails as usual when I came across a message stating that the administration had decided to upgrade Solution Manager 7.1 to Solution Manager 7.2. This reminded me of the importance of knowing how to Save Word Document on Desktop from Web Dynpro using OBN, as such practical tasks can often arise during system upgrades. Did this ever happen to you?
It nearly came as a shock and part of liability/work on my end as I was the specialized designer/SME for arrangement supervisor execution in my task. As there was a ton of customization in 7.1 and everything must be overhauled in 7.2 as 7.1 is GUI based ( tcode SOLAR01) and 7.2 is webdynpro (tcode SOLDOC) for making/overseeing records and there is a tremendous change in design. One of the vital necessities in 7.1 was that the word report ( like Specialized Determination, Practical, Unit Test ) and so forth will be directed through work process to assigned approvers and the record must be joined in the work thing as a pdf so clients can check their inbox, survey the pdf and support/reject the work thing.
As 7.1 was GUI based this was finished through OLE ( ie prior to setting off the work process ) word doc content was altered (expansion of certain headers/footers) and afterward switched over completely to pdf by utilizing OLE objects/strategies and that parallel substance was passed to work process compartment so it very well may be subsequently joined to the work things utilizing suitable Programming interface’s .
Anyway in 7.2 since the frontend ie UI is webdynpro so we got a mistake in the first step itself when we attempted to call Programming interface like GUI_DOWNLOAD to save the word doc, disregard the later part utilizing OLE.
This was a gem for the project since there was not enough time or budget for exploring alternatives like using third-party software for PDF conversion, and the entire solution had to be revised. Understanding how to Save Word Document on Desktop from Web Dynpro using OBN became crucial in this scenario, as it offered a practical solution within the constraints.
So then I began investigating things and invested a lot of energy/exertion ran over the idea of OBN ( Item Based Route) which made my life simple.
Here, I will talk about OBN finally and furthermore will exhibit by a simple model how to execute it. I’m not delving into the subtleties of work process and complex OLE which isn’t the goal of the blog. By utilizing OBN you can send off and set off any GUI exchange/report. OBN is utilized in Jobs (PFCG) to dole out an item to a capability.
What is OBN?
Object-Based Route (OBN) is a runtime gateway capacity of exploring and passing business information between applications in the extent of the client jobs. Offers to gateway clients an extra strategy for route in light of business protests and its activities to reach/send off target sees without understanding what the genuine objective will be. For instance, there is a button and the button when clicked will fire the OBN occasion and during runtime, it will be settled with the client’s relegated job to conclude what application ought to be begun. With various jobs with various OBN mappings, various targets can be accomplished on snap of a similar button.
To state essentially what fundamentally happens is that the OBN call look through the Jobs of the client calling a specific capability and when found it dispatches the relating exchange (or other capability). Thus, we will later see, that the OBN is exceptionally fixed to the Jobs of the client
Each OBN occasion likewise contains boundaries (in our model the quantity of the deals request) that is passed to the objective application. Presently, we should hop directly to perceive how it functions.
How OBN functions?
As referenced, OBN is Business object based so we should make a Business Item first through SWO1.
Step1: Creation of business object in SWO1
Give an article type name and afterward click on make button.
Then, at that point, on the following screen give every one of the subtleties in the spring up.
Press enter. Naturally a few techniques, trait and interact will be added.
Presently we will change the situation with this item to ‘Implemented‘ and continue to stage 2.
Step 2: Creation of simple webdynpro component with a field and a button.’
Go to SE80 and make a webdynpro part.
Presently explore to the unique circumstance and make a hub, trait.
Make Property.
Initiate the webdynpro part.
Map the view regulator setting to part regulator setting.
After the button is added make a web dynpro application for this part. Right-click on the part name->Create-> Web Dynpro application.
Web dynpro application ZOBNDEMO made.
Execution of button overseer will be taken care of in later post stage 3.
Stage 3: Make a module pool program having a screen where the OLE rationale will be taken care of and afterward relegate the exchange to it. We won’t compose any code inside this program now. All the coding will be a piece of the last step.
Give program name as ZDEMOOBN1 and save the exchange. This exchange will be subsequently relegated to a PFCG job.
Step 4: Create a PFCG role as below.
In the menu, we will add another folder by clicking the Create folder button and then inside that the webdynpro application on clicking the Transaction button.In the menu, we will add another folder by clicking the Create folder button and then inside that the webdynpro application on clicking the Transaction button.
Then add the webdynpro application by clicking the insert node button and choose web dynpro application from the list as shown below.
Then on the next screen provide the web dynpro app from F4 help created above ie ZOBNDEMO.
Pick ZOBNDEMO and press enter.
So one more hub for webdynpro application included the menu inside OBN organizer. Presently we will add the exchange made above under web dynpro application by the supplement hub button and afterward pick exchange from the rundown. Then pick ZDEMOOBN from F4 help
and click on assign transactions button.
Transaction gets added as next level.
So the role created above consist of a Root folder and a Subfolder (NWBC requires at least one lower level). First “pin” is the Web Dynpro Application created in step one – just basic call of a Web Dynpro application.
Second “pin” is the z transaction which will call the OLE to save word doc on local desktop.. When you press the Other Node Details button you will notice the OBN part below.
Then check the checkbox ‘Force SAP GUI in HTML’ checkbox. This is very important otherwise webdynpro will not be able to trigger GUI.
Might you at any point see a segment called Item Based Route in the above screen capture? Now that is the stunt. We will add the BO object made in sync 1 and its technique show by tapping on the supplement symbol. So when we call the OBN ie the article and its technique at runtime from this job task it decides the exchange. Add the item type id and the Technique id the from F4 help so a portion of different fields are auto-populated.
Press enter.
Presently to pass a few information from web dynpro to OBN we can utilize boundaries. At this point how about we add one boundary which is doc num which is on the web dynpro view.
Put the boundary name and a similar name in boundary esteem yet in second sections.
So we have added every one of the subtleties in Menu tab.
Presently come to approvals tab, propose profile name and afterward produce the profile and save. When done the tab will be green.
Then come to client tab and afterward add the clients to whom this job ought to be relegated.
Click on client examination button.
When client examination is finished, the client tab will be green status. Then at long last snap on save.
So our PFCG job creation is finished. This job should be tried from NWBC.
So execute NWBC and click on the job ZDEMOOBN from the rundown of jobs.
Uh oh, we got the beneath mistake. “The client menu tree for client XXXX with job YYYY is vacant. Kindly contact your framework chairman”.
Again it required me an investment to find the reason why we are getting this mistake lastly found the solution. Trust you would save some time.
The job passage should be kept up with in a table DSWP_ROLES. So go to SM30 and make another passage in this table.
Then save the section. Presently again test similarly ie go to NWBC and click on job ZDEMOOBN you get the web dynpro opened as underneath.
Talking, the screen, to be perfectly honest, doesn’t look spotless as the field and the button shows up in a similar line and furthermore name isn’t shown for the field. Additionally, second tab Demo for OBN ought not be apparent just like the hub for the exchange which will be approached snap of the button.
How about we change the design of webdynpro first. For that, we really want to put the UI components in a gathering of type Line design or Lattice design as underneath.
Right snap on rootelementuicontainer and make a component of type Gathering.
Of course, the new gathering added has stream design. Transform it to push design starting from the drop as beneath and move both the UI components in the gathering.
As need might arise to be in next line in format information in the properties change the worth from column information to push head information.
Likewise, make a mark for record number.
When the progressions are done open the PFCG job and make the second tab as undetectable as displayed underneath.
Presently execute NWBC with that job again to test the changes.
You can mess with various kind of format and plan more mind boggling screens according to prerequisite. This is a straightforward rough screen with least components to make sense of how OBN can be executed. Presently as we are finished with the making of the relative multitude of items we will execute the coding in the button occasion overseer and the program that we made previously.
Stage 4: Execute technique onactionclick of the fundamental view as underneath. To begin with, we want to get the worth of the field on the screen.
Click on the wizard with the read activity and in setting pick doc_num.
Press enter. Below code is generated by the wizard.
*First read value of doc numbe.Use wizard DATA lo_nd_obn TYPE REF TO if_wd_context_node. DATA lo_el_obn TYPE REF TO if_wd_context_element. DATA ls_obn TYPE wd_this->Element_obn. DATA lv_doc_num TYPE wd_this->Element_obn-doc_num. * navigate from <CONTEXT> to <OBN> via lead selection lo_nd_obn= wd_context->get_child_node( name = wd_this->wdctx_obn ). * @TODO handle non existant child * IF lo_nd_obn IS INITIAL. * ENDIF. * get element via lead selection lo_el_obn= lo_nd_obn->get_element( ). * @TODO handle not set lead selection IF lo_el_obn IS INITIAL. ENDIF. * get single attribute lo_el_obn->get_attribute( EXPORTING name= `DOC_NUM` IMPORTING value = lv_doc_num ).
Now the actual part ie calling the OBN with the below code. This is done by calling method navigate_to_object of interface if_wd_portal_integration.
DATA: lo_api_component TYPE REF TO if_wd_component. DATA lo_portal_manager TYPE REF TO if_wd_portal_integration. TYPES: BEGIN OF t_obn_param, key TYPE string, value TYPE string, END OF t_obn_param. DATA: lt_obn_param TYPE STANDARD TABLE OF t_obn_param. DATA: ls_obn_param TYPE t_obn_param. lo_api_component = wd_comp_controller->wd_get_api( ). lo_portal_manager = lo_api_component->get_portal_manager( ). CALL METHOD lo_portal_manager->navigate_to_object EXPORTING object_type = 'ZDEMOOBN' - *Object type created in Step 1 object_value_name = 'G_DOCNUM' - *Name of the parameter assigned in PFCG config- Check above object_value = lv_doc_num - *Value of the above parameter input on the web dynpro screen operation = 'Display' - *Method of the object type which will resolve OBN
The framework was told to call a Business Item called ZDEMOOBN with the technique Show (ZDEMOOBN.Display). At the point when that call was executed it look through the Jobs allocated to the signed in client for a passage with the OBN task ZDEMOOBN.Display.
At the point when found in the Job, it will execute the exchange appointed to that menu point and passed the worth from the Screen field to the boundary G_DOC_NUM in exchange ZDEMOOBN.
In the event that you really want to pass more than 1 boundary strategy NAVIGATE_TO_OBJECT has a boundary called business_parameters. All things considered, we really want to utilize this boundary rather than object_value_name and object_value.
For example add the parameters as below. ls_obn_param-key = 'p_param1'. ls_obn_param-value = '17'. APPEND ls_obn_param TO lt_obn_param. ls_obn_param-key = 'p_param2'. ls_obn_param-value = 'X'. APPEND ls_obn_param TO lt_obn_param. CALL METHOD lo_portal_manager->navigate_to_object EXPORTING object_type = 'ZDEMOOBN' operation = 'Display' business_parameters= lt_obn_param.
For our situation, we will utilize just 1 boundary.
Finished with the essential coding of webdynpro view. Presently we will execute the code expected to save a word doc on the work area in the report and afterward start to finish testing.
Recall that we made a screen 9000 in module pool program ZDEMOOBN1 and not a straightforward report program. Indeed, the explanation is that anything boundaries are being gone through OBN the program can get those boundaries with screen fields of a similar name. Got some margin for me to figure out this.
Thus, for this situation, we will make a screen field with name G_DOCNUM so the worth of G_DOCNUM which for this situation is the record no contribution on the webdynpro screen.
We should run NWBC with the ideal job and check whether the worth of doc number contribution on webdynpro UI screen gets streamed to the GUI program or not.
We have not composed any rationale. In all likelihood will actually look at the way of behaving.
Since we needn’t bother with the client show this field we will make the field no – show and produce a word report in neighborhood drive with a text ‘ Word record made for record G_DOCNUM esteem ‘.
In PBO make screen field as no-show.
if g_docnum is not initial. loop at screen. if screen-name = 'G_DOCNUM'. screen-active = '0'. modify screen. ENDIF. endloop. endif.
Code for saving the word doc on the desktop using OLE.
Code in PBO of screen 9000 just after the above code.
DATA: w_word TYPE ole2_object, w_actdoc type ole2_object, w_document TYPE ole2_object, w_add type ole2_object, w_selection TYPE ole2_object, w_font TYPE ole2_object, w_paragraphformat TYPE ole2_object, w_system(10), w_line(80). if g_docnum is not initial. * Create OLE automation object of type Word.Application. CREATE OBJECT w_word 'Word.Application'. * Display MS-Word when executing the program. SET PROPERTY OF w_word 'Visible' = 0. * Add a new blank document. CALL METHOD OF w_word 'Documents' = w_document. CALL METHOD OF w_document 'Add' . * call method of W_WORD 'Activate'. get property of w_word 'ActiveDocument' = w_actdoc. * Add data to the new MS-Word document. CALL METHOD OF w_word 'Selection' = w_selection. CALL METHOD OF w_selection 'ParagraphFormat' = w_paragraphformat. CALL METHOD OF w_selection 'Font' = w_font. * Use bold, a bigger font and center the title. SET PROPERTY OF w_paragraphformat 'Alignment' = 1. SET PROPERTY OF w_font 'Size' = 16. SET PROPERTY OF w_font 'Bold' = 1. CONCATENATE 'Word document created for document' g_docnum INTO w_line SEPARATED BY space. * Export title to Word document. CALL METHOD OF w_selection 'TypeText' EXPORTING #1 = w_line. CALL METHOD OF w_selection 'TypeParagraph'. GET PROPERTY of w_word 'ActiveDocument' = w_actdoc. CALL METHOD of w_ACTDOC 'SaveAs2' exporting #1 = 'H:\demoobn9.docx' #2 = 12. CALL METHOD OF w_word 'Quit'. ENDIF.
Testing steps:
- Execute NWBC tcode and click on job ‘ZDEMOOBN’
- On the webdynpro screen give doc number as 6789 and tap on create pdf.
- GUI exchange will be called and a word doc ‘Demoobn9’ will be saved in H drive.
So the word doc will be generated as below.
With OLE capabilities, we can now incorporate any GUI transaction with Web Dynpro using NWBC as an interface. This means that understanding how to Save Word Document on Desktop from Web Dynpro using OBN is more relevant than ever, as it allows us to streamline document management processes directly within the Web Dynpro environment.
Assuming no one really minds, note that if your client’s users do not have access to NWBC, we can create a Fiori tile and trigger this application using the Fiori Platform as well. This will be covered in a later blog. Nevertheless, I hope this article provides a helpful guide on how to save a Word document on the desktop from Web Dynpro using OBN.
YOU MAY BE INTERESTED IN
Analysis Of Algorithm In DAA-2024
Top SAP ABAP Interview Questions (2024)
Steampunk Chronicles: Navigating the Cloud with SAP BTP ABAP Environment