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. 

Let me start from R/3 side 

Create a smart form. Here I have created a simple smart form which displays “Welcome to SAP Smart forms”. 

 

Now create a function module with the following export parameter:

 

Place the following code in the function module 

data :

  lv_fnam type RS38L_FNAM,

  gs_control                 TYPE ssfctrlop,

  gs_output_options   TYPE ssfcompop,

  gs_otfdata  TYPE itcoo,

  gs_job_output_info  TYPE ssfcrescl,

   gt_otfdata    TYPE STANDARD TABLE  OF itcoo  INITIAL SIZE 0. 

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

  EXPORTING

    formname                 = 'YNAG_TEST_PDF'

IMPORTING

   FM_NAME                  = lv_fnam

 EXCEPTIONS

   NO_FORM                  = 1

   NO_FUNCTION_MODULE       = 2

   OTHERS                   = 3      .

IF sy-subrc <> 0.

 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

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. 

CALL FUNCTION lv_fnam

 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.

 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF. 

*Populate OTF data table

LOOP AT gs_job_output_info-otfdata INTO gs_otfdata.

  APPEND gs_otfdata TO gt_otfdata.

  CLEAR gs_otfdata.

ENDLOOP.                           " LOOP AT t_outtab-otfdata

DATA: lv_bytes TYPE p,

      lv_bin_file type xstring,

      gt_pdfdata       TYPE STANDARD TABLE

                                  OF tline

                             INITIAL SIZE 0. 

*   Convert OTF into PDF

    CALL FUNCTION 'CONVERT_OTF'

      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. 

 

With this we are done on the R/3 side.

Continued...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image