Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can use Smartforms to display pdf in your app.

Step-by-step guide

  1. Create and design smartform layout.   
  2. Create an odata service to call and process created smartform returning pdf data. 
    1. Sample entity set definition:

                     Entity set:  ReqData – import parameter/form data, PDFData – export parameter/pdf data

                    

                 b. Sample js script to pass form data to smartform using odata Odata service: 

var oModel = getModel("CN_CAPEX");

...

var filters = [];

...

var filterindex = 0;

...

//details

...

var ReqData = {};

...

ReqData.TITLE = getField("Title");

...

ReqData.BUDGET_YEAR = getField("BudgetYear");

...

ReqData.ACCOUNTABILITY = getField("Accountability");

...

ReqData.DIVISION = getField("Region");

...

ReqData.LOCATION = getField("Location");

...

ReqData.STATE = getField("ProvinceText");

...

ReqData.SUBDIVISION = getField("Subdivision");

...

ReqData.COMPANY = getField("Company");

...

ReqData.MULTIYEAR = getField("MultiYear");

...

ReqData.NUMBEROFYEARS = getField("CommitmentYear");

...

ReqData.SPONSORSHIP = getField("Sponsorship");

...

ReqData.TYPE = getField("Type");

...

ReqData.SUBTYPE = getField("SubType");

...

ReqData.PROJECTTYPE = getField("ProjectType");

...

ReqData.SUBPROJECTTYPE = getField("SubProjectType");

...

ReqData.CURRENCY = getField("Currency");

...

ReqData.BUSINESSCASE = getField("BusinessCase");

...

oFilter1 = fabFilter("ReqData", JSON.stringify(ReqData));

...

filters.push(oFilter1);

...

oModel.read("/ShowPDFs",{

...

success:function(data){

...

if(data.results){

...

var PDFDataFinal = "data:application/pdf;base64," + data.results[0].PDFData;

...

if( data.results[0].PDFData != "" ){

...

setField("PDFDataOut",PDFDataFinal);

...

}else{

...

setField("PDFDataOut","");

...

}

...

getControl("PDFPageId").setBusy(false);

...

}

...

},

...

filters:filters

...

});

...


                 c. Inside Odata service to retrieve pdf content

...

.

...

1. Get function module name using form name. See sample code below:

...


CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

...

EXPORTING

...

formname =

...

'ZCN_CAPEX'

...

IMPORTING

...

fm_

...

name =

...

lv_fmname

...

EXCEPTIONS

...

no_

...

form =

...

1

...

no_function_

...

module =

...

2

...

OTHERS =

...

3.


2. Trigger

...

Smartform created using the FM passing form data. Make sure to set GETOTF flag of CONTROL_PARAMETERS when calling the smartform.


cl_fdt_json=

...

>json_to_data(

...

EXPORTING iv_

...

json =

...

lv_reqdata

...

CHANGING ca_

...

data =

...

ls_

...

details ).

...


CALL FUNCTION lv_fmname

...

EXPORTING

...

control_

...

parameters =

...

ls_ctrlop

...

output_

...

options =

...

ls_compop

...

user_

...

settings =

...

abap_true

...

im_capex_

...

details =

...

ls_details

...

IMPORTING

...

job_output_

...

info =

...

ls_return

...

EXCEPTIONS

...

formatting_

...

error =

...

1

...

internal_

...

error =

...

2

...

send_

...

error =

...

3

...

user_

...

canceled =

...

4

...

OTHERS =

...

5.


3. Use function module CONVERT_OTF to convert OTF to PDF

...

.

IF ls_return-otfdata[] IS NOT INITIAL.


lt_otf[] = ls_return-otfdata[].


CALL FUNCTION 'CONVERT_OTF'

...

EXPORTING

...

format =

...

'PDF'

...

max_

...

linewidth =

...

132

...

IMPORTING

...

bin_

...

filesize =

...

lv_len_in

...

bin_

...

file =

...

lv_pdf_xstring

...

TABLES

...

otf =

...

lt_otf

...

lines =

...

lt_tline

...

EXCEPTIONS

...

err_max_

...

linewidth =

...

1

...

err_

...

format =

...

2

...

err_conv_not_

...

possible =

...

3

...

OTHERS =

...

4.

 ENDIF.

4. Pass bin_file parameter from FM CONVERT_OTF to PDFData form field.

...

3. Create a new page/or section in FAB that will serve as a placeholder for the pdf content. Add HTML attribute with the following content to display pdf.

<iframe src="{PDFDataOut}"  width="100%" height="100%">PDF</iframe>


Info

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@223dfe
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "kb-how-to-article" and type = "page" and space = "IFAB"
labelskb-how-to-article

...