Displaying A Smart Form As PDF in Enterprise Portal Using WebDynpro For Java
Displaying A Smart Form As PDF in Enterprise Portal Using WebDynpro For Java
By Nagaraju Donikena
I have seen many questions on how a smart form should be displayed in portal. To answer this question a person should have both
Portal and ABAP knowledge. By giving this basic information I want to make sure that displaying a smart form as PDF is a simple
task.
Create a smart form. Here I have created a simple smart form which displays “Welcome to SAP Smart forms”.
data :
EXPORTING
formname = 'YNAG_TEST_PDF'
IMPORTING
FM_NAME = lv_fnam
EXCEPTIONS
NO_FORM =1
NO_FUNCTION_MODULE =2
OTHERS =3 .
IF sy-subrc <> 0.
ENDIF.
CLEAR gs_job_output_info.
CLEAR gs_job_output_info-otfdata.
MOVE :
'X' TO gs_control-no_dialog,
'X' TO gs_control-getotf,
'LOCL'(047) TO GS_OUTPUT_OPTIONS-TDDEST.
EXPORTING
CONTROL_PARAMETERS = gs_control
OUTPUT_OPTIONS = gs_output_options
USER_SETTINGS = space
IMPORTING
JOB_OUTPUT_INFO = gs_job_output_info
EXCEPTIONS
FORMATTING_ERROR =1
INTERNAL_ERROR =2
SEND_ERROR =3
USER_CANCELED =4
OTHERS =5 .
IF sy-subrc <> 0.
ENDIF.
CLEAR gs_otfdata.
OF tline
EXPORTING
format = 'PDF'
max_linewidth = 255
IMPORTING
bin_filesize = lv_bytes
BIN_FILE = bin_file
TABLES
otf = gt_otfdata
lines = gt_pdfdata
EXCEPTIONS
err_max_linewidth =1
err_format =2
err_conv_not_possible = 3
OTHERS = 4.
Make sure that the function module is marked remote enabled.
In NWDS (Net Weaver Developer Studio) create an Adaptive RFC model which points to the FM created in R/3.
Insert a frame inside the view
{
//@@begin wdDoInit()
wdContext.nodeYnag_Test_Pdf_Input().bind(input);
try {
wdContext.currentYnag_Test_Pdf_InputElement().modelObject().execute();
} catch (WDDynamicRFCExecuteException e) {
e.printStackTrace();
wdContext.currentContextElement().setSdfgdsfsd(e.getMessage());
} wdContext.currentInternalElement().setUrl(convertXStringToUrl(wdContext.currentOutputElement().getBin_File()));
//@@end
}
//@@begin others
try {
url = webResource.getURL();
} catch (WDURLException e) {
e.printStackTrace();
}
return url;
//@@end
If you are using single sign on make sure to enable User authentication in the application parameters.
User details are required for this as it is using Single sign on to connect to R/3.