+ All Categories
Home > Documents > how to guide for smart form

how to guide for smart form

Date post: 14-Apr-2015
Category:
Upload: mallikarjun7700
View: 105 times
Download: 7 times
Share this document with a friend
Description:
how to guide for smart form
12
How to Guide for Displaying a Smart form in CRM WEB UI Screen, in PDF Format. (As an Pop up) NAME DESIGNATION Nikhil Prateek Kulkarni SAP Associate Consultant
Transcript
Page 1: how to guide for smart form

How to Guide for

Displaying a Smart form in CRM WEB UI Screen, in PDF Format.

(As an Pop up)

NAME DESIGNATION

Nikhil Prateek Kulkarni SAP Associate Consultant

Page 2: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 2 of 12

REVISION HISTORY

Doc

Ver. #

Date

Prepared/Changed

By

Reviewed

By

Authorized by

Description

0.0 11/July/2012 Nikhil Prateek Kulkarni

Page 3: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 3 of 12

Contents

1 Purpose ......................................................................................................... 4

2 Audience ........................................................................................................ 4

3 Scope ............................................................................................................. 4

4 Prerequisites ................................................................................................. 4

5 Introduction ................................................................................................... 4

6 Advantages ................................................................................................... 4

7 Implementation ............................................................................................. 5

Page 4: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 4 of 12

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.

2. 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.

3. 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 .

4. Prerequisites :

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

5. 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 .

6. 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 .

Page 5: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 5 of 12

7. 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

Execute the smart form and it looks something like this .

Page 6: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 6 of 12

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 :

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.

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.

Page 7: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 7 of 12

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

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 .

Page 8: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 8 of 12

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 :

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.

Page 9: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 9 of 12

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,

Page 10: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 10 of 12

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

Page 11: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 11 of 12

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.

Now you are done with your “Page” coding.

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.wdf.sap.corp:44326/sap/bc/bsp/sap/znikhi

l1/testpage.pdf' .

%>

<script language="javascript">

window.open("<%= GV_URL%>").focus();

</script>

Note:

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

Page 12: how to guide for smart form

Document No: PEOL/HWT/001 Ver: 0.0 07/JULY/2012

HOW TO GUIDE PROPRIETARY & CONFIDENTIAL

© PEOL – Expeditious Business Solutions, 2012

Page 12 of 12

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 .

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:

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 .


Recommended