Quantcast
Viewing all articles
Browse latest Browse all 7775

Re: Content Management , Uploading a PDF file on a CRM WEB UI Screen

Hello Nithin , 

 

Please find the Below How to Guide Prepared by Me. Reward if useful.

 

 

Contents

  1. 1....... Purpose. 4
  2. 2....... Audience. 4
  3. 3....... Scope. 4
  4. 4....... Prerequisites. 4
  5. 5....... Introduction.. 4
  6. 6....... Advantages. 4
  7. 7....... Implementation.. 5

 

 

 
 

1.  Purpose :

The purpose of this document is to give a detailed idea about how to Display a Smart form in SAP CRM WEB UI Screen in a PDF Format.

  1. Audience :

This document can be used by CRM WEB UI consultants for displaying a Smart form Out put on a CRM WEB UI Screen in PDF Format.

  1. Scope :

Many times there will be requirement of displaying a smart form out put on the web ui screen. This How to guide helps in achieving that . 

  1. Prerequisites :

Should know how to create a Simple smart form. Should have basic knowledge of view.

  1. Introduction :

There will be often lots of documents in an project which are getting generated by SMARTFORMS and there may be requirement that you need to display them on the CRM Web UI Screen . This is possible with a little Java coding and with a little ABAP code play around. With this we will see how to achieve this .

  1. Advantage :

        Any Text / pictures displayed in PDF Format looks clean and decent. Till now we used to write the driver program         

              for displaying the smart form output and this option is now available in CRM WEB UI for doing the same .

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. Implementation :

It is assumed that reader knows the transaction to create Smart form. With a little overview of smart form I would like to jump directly into the technical things I.E. step by step to Display Smart form in CRM WEB UI SCREEN.

 

You Should Have an error free, tested Smart form so that you can able to run it without any dumps.

Say for Example I have one Smart form which looks like this.

 

T-code for opening Smart form : SMARTFORMS

Image may be NSFW.
Clik here to view.
1.png

Execute the smart form and it looks something like this .

 

 

Now the same out put will be displayed in the CRM WEB UI Screen as a PDF format in Pop upView.

Step 1:

            Create WEB UI Component . T-Code is BSP_WD_CMPWB.

It looks some this like this after creating  :

Image may be NSFW.
Clik here to view.
2.png

 

Note : No need of adding Model as I am just implementing this particular scenario where no model nodes are needed .

 

Step 2:

            Go to SE80 Transaction and Navigate to your package where you have stored your BSP Application.

  Image may be NSFW.
Clik here to view.
3.jpg

Navigate: - BSP LIBRARY -> BSP APPLICATIONS -> ZXXXX Component and Right click as shown in above figure and Create a PAGE. Here the BSP APPLICATION is ZNIKHIL1.

 

As Shown above, right click on Create Page and give the format of the page as shown below .

Image may be NSFW.
Clik here to view.
4.jpg

 

Note: It looks some thing like this when you create a page . The reason for creating PAGE in SE80 is , you cannot create it else where !!!! in BSP_WD_CMP , you can see the created Pages , but cannot create there .

 

Image may be NSFW.
Clik here to view.
5.jpg.png

 

There is one Tab strips you can see which is displays like Properties, layout, Event handler, Page Attributes and Type Definitions.

Now you need to implement some of these to get the work done.

In Properties give the following details.

Mime Type    =   application/pdf.

Status as shown Below :

Image may be NSFW.
Clik here to view.
6.jpg

 

 

And also you can see an URL which is generated automatically when you activate that page you can able to see the URL in Properties tab.

Note: This URL will be used later.

Now Click Event Handler Tab as shown below and select the event handler.

  Image may be NSFW.
Clik here to view.
7.jpg

 

Paste the following code in OnIniitalization Event Handler .

DATA    lv_xlen              TYPE i.
DATA :   lv_pdf           TYPE xstring.

**** Function Module which converts the smartform into PDF
CALL FUNCTION 'ZSMARTFORMTOPDF'
EXPORTING
FORMNAME                  
= 'ZDUMMY'
IMPORTING
E_LV_PDF     
= lv_pdf.


lv_xlen
= xstrlen( lv_pdf ).
_m_response
->set_data( data = lv_pdf length = lv_xlen ).
_m_response
->set_header_field( name = if_http_header_fields=>content_type value = 'application/pdf' ).
_m_response
->set_header_field( name  if_http_header_fieLds=>CACHE_CONTROL  value = 'max-age=0' ).
_m_response
->set_status( code = 200 reason = 'OK' ).
_m_response
->server_cache_expire_rel( expires_rel = 180 ).

 

Now here there is a Function module call. This Function Module Basically Reads the Smart form name and converts it to the suitable format and is processed further.

Function Module:ZSMARTFORMTOPDF’

Importing Parameter: FORMNAME         TYPE    TDSFNAME.

Exporting Parameter: E_LV_PDF           TYPE    XSTRING.

 

FUNCTION zsmartformtopdf.

 

  DATA: it_otf      TYPE STANDARD TABLE OF itcoo,
it_docs    
TYPE STANDARD TABLE OF docs,
it_lines   
TYPE STANDARD TABLE OF tline.
* Declaration of local variables.
DATA:
st_job_output_info      
TYPE ssfcrescl,
st_document_output_info 
TYPE ssfcrespd,
st_job_output_options   
TYPE ssfcresop,
st_output_options       
TYPE ssfcompop,
st_control_parameters   
TYPE ssfctrlop,
v_len_in                
TYPE so_obj_len,
v_language              
TYPE sflangu VALUE 'E',
v_e_devtype             
TYPE rspoptype,
v_bin_filesize          
TYPE i,
v_name                  
TYPE string,
v_path                  
TYPE string,
v_fullpath              
TYPE string,
v_filter                
TYPE string,
v_uact                  
TYPE i,
v_guiobj                
TYPE REF TO cl_gui_frontend_services,
v_filename              
TYPE string,
v_fm_name               
TYPE rs38l_fnam,
c_formname              
TYPE tdsfname  ,
lv_st_job_output_info   
TYPE ssfcrescl-otfdata,
lv_pdf                  
TYPE               xstring ,
pdf_tab                 
LIKE tline OCCURS 0 WITH HEADER LINE...
.
c_formname
= formname .
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language   
= v_language
i_application
= 'SAPDEFAULT'
IMPORTING
e_devtype    
= v_e_devtype.
st_output_options
-tdprinter = v_e_devtype.
st_control_parameters
-no_dialog = 'X'.
st_control_parameters
-getotf = 'X'.
*.................GET SMARTFORM FUNCTION MODULE NAME.................*
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname          
= c_formname
IMPORTING
fm_name           
= v_fm_name
EXCEPTIONS
no_form           
= 1
no_function_module
= 2
OTHERS             = 3.
*...........................CALL SMARTFORM............................*
CALL FUNCTION v_fm_name
EXPORTING
control_parameters  
= st_control_parameters
output_options      
= st_output_options
IMPORTING
document_output_info
= st_document_output_info
job_output_info     
= st_job_output_info
job_output_options  
= st_job_output_options
EXCEPTIONS
formatting_error    
= 1
internal_error      
= 2
send_error          
= 3
user_canceled       
= 4
OTHERS               = 5.

****Convert the output of the smart form
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format                = 'PDF'
IMPORTING
bin_filesize         
= v_bin_filesize
bin_file             
= lv_pdf
TABLES
otf                  
= st_job_output_info-otfdata
lines                 = pdf_tab
EXCEPTIONS
err_max_linewidth    
= 1
err_format           
= 2
err_conv_not_possible
= 3
err_bad_otf          
= 4
OTHERS                = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

**** Passing the obtained value to Exporting Parameter
e_lv_pdf
= lv_pdf.

ENDFUNCTION.

 

  1. Now you are done with your “Page” coding. J J

 

As I have already mentioned there is an URL Generated when you create a Page.

Now the remaining Job is, you just need to create a view and call this URL with a little java coding.

 

Now as there are no BOL Objects present in my UI Component, I will continue creating an Empty View.

Assumed that you created a empty view in the same BSP Application, proceed with this coding in .HTM of the view as your last stem in completing this task .

 

Step 3:

            Copy Paste the below code :

<%@page language="abap" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="bsp" prefix="bsp" %>

<%
Data  GV_URL type string value 'https://uxciq0e....... <Complete URL Address>' .
%>

<script language=
"javascript">
window.open(
"<%= GV_URL%>").focus();
</script>

 

Note:

1)  The URL Which I have passed above is auto created in PAGE Properties .

2) The Value for this URL should be taken from the Controller reference. Here I am passing it directly and ideally it should not done in this way , we need to compulsory check the reference of the controller class , get the url from that reference and then we need to call the URL . Hope it is understandable.

As I don’t have the controller reference here I have passed the URL Directly .

Ideally coding should be in this way in your .HTM Page .

data:  gv_url type string.

<%
if controller->gv_url is not initial.
%>
<script language="javascript">
window.open("<%= controller->gv_url %>").focus();
</script>
<%
clear controller->gv_url.
endif.
%>        

Now Add your View to the mainwindow in runtime repository of your BSP Application and Execute .

 

  1. Note: Some times you may be displayed a empty view with no smart form in the pop up, in this case log off from the system , clear the internet explorer cache and then run your BSP Application, it definitely works in this case .

Look and Feel:

 

Image may be NSFW.
Clik here to view.
8.jpg

 

Note: Here in this illustration , I am just opening this pop up where your Smartform Output is shown . May be you can try out with clicking on any Button or any other UI Element .

Hope this provided you 100% Solution .

 

 

Thanks and Regards,

Nikhil Kulkarni


Viewing all articles
Browse latest Browse all 7775

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>