cancel
Showing results for 
Search instead for 
Did you mean: 

Display Smartform Pdf output in ABAP Webdynpro application

Udo_Ahle
Explorer
0 Kudos

Hello,

there is a solution for displaying Smartform output in Java Webdynpro application in this forum. Since i want to start an project in ABAP Webdynpro i need a solution for this technology since i don't want to recreate all the paperwork again using Adobe. Is there any solution available?

Thanks

Udo Ahle

Accepted Solutions (0)

Answers (2)

Answers (2)

Udo_Ahle
Explorer
0 Kudos

Hello,

this is the solution which i was able to implement using the hints given by Heidi and Thomas. Thank you for the support. With this solution it is possible to reuse oldstyle sapscripts and smartforms in todays environment. Here is the sample code which solves the problem:

In WDA you define for example a pushbutton to start the display of the PDF.

In the onaction method you implement:

method ONACTIONSHOW_PDF .
  data LX_pdf type xstring.

* get PDF from existing sapscript or smatform
  call function 'Y_PDF_GET' destination '46c'
    IMPORTING
      ex_PDF = LX_PDF.

* append the pdf to the response
  cl_wd_runtime_services=>attach_file_to_response(
    i_filename  = 'Hello.PDF'
    i_content   = lx_pdf
    i_mime_type = 'application/pdf'
    i_in_new_window = 'X'
    i_inplace       = 'X' ).

endmethod.

The function 'Y_PDF_GET' is implemented as follows:

FUNCTION Y_PDF_GET .
*"--------------------------------------------------------
*"*"Local interface:
*"  EXPORTING
*"     VALUE(EX_PDF) TYPE  XSTRING
*"  TABLES
*"      ET_OTF STRUCTURE  ITCOO OPTIONAL
*"--------------------------------------------------------
  data: lf_filesize type i,
        lt_otf type table of ITCOO,
        lt_lines type table of tline,
        tline type tline.
* start sapscript or smatforms and return
  perform make_otf.

  CALL FUNCTION 'READ_OTF_FROM_MEMORY'
    TABLES
      OTF                = lt_otf
   EXCEPTIONS
     MEMORY_EMPTY       = 1
     OTHERS             = 2
            .

  et_otf[] = lt_otf.

  CALL FUNCTION 'CONVERT_OTF'
   EXPORTING
     FORMAT                      = 'PDF'
*   MAX_LINEWIDTH               = 132
*   ARCHIVE_INDEX               = ' '
   IMPORTING
     BIN_FILESIZE                = lf_filesize
    TABLES
      OTF                         = lt_otf
      LINES                       = lt_lines
   EXCEPTIONS
     ERR_MAX_LINEWIDTH           = 1
     ERR_FORMAT                  = 2
     ERR_CONV_NOT_POSSIBLE       = 3
     OTHERS                      = 4
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* convert tline to xstring as needed in 
* in web dynpro             
  field-symbols <X>.
  data: st(268) type c.
  data l1 type i.
  data len type i.
  data maxline type i value 134.
  l1 = 0.
  loop AT lt_lines INTO tline.
    clear st.
    st+l1(maxline) = tline.
    len = maxline + l1.
    l1 = maxline - strlen( tline ).
    ASSIGN st TO <x> TYPE 'X'.
    CONCATENATE ex_pdf <x>(len) INTO ex_pdf.
  endloop.
ENDFUNCTION.

The make_otf for sapscript is the following:

* the next attribute enables the otf output.
* no other output will be generated
<b>options-TDGETOTF = 'X'</b>
  CALL FUNCTION 'OPEN_FORM'
       EXPORTING
*         APPLICATION        = 'TX'
*         ARCHIVE_INDEX      = ARCHIVE_INDEX
         ARCHIVE_PARAMS     = ARCHIVE_PARAMS
            DEVICE             = DEVICE
            DIALOG             = ' '
            FORM               = FORM
            LANGUAGE           = language
           OPTIONS            = OPTIONS
*     IMPORTING
*          LANGUAGE           =
*          NEW_ARCHIVE_PARAMS =
*          RESULT             =
       EXCEPTIONS
            CANCELED           = 1
            DEVICE             = 2
            FORM               = 3
            OPTIONS            = 4
            UNCLOSED           = 5
            OTHERS             = 6.

*... make some write forms
  data lT_OTF	type table of	ITCOO.

* get the otf data
  CALL FUNCTION 'CLOSE_FORM'
*     IMPORTING
*          RESULT   = result
       TABLES
           OTFDATA  = lt_otf
       EXCEPTIONS
            UNOPENED = 1
            OTHERS   = 2.

* put otf into memory for later usage
  if not lt_otf is initial.
    CALL FUNCTION 'SAVE_OTF_TO_MEMORY'
* EXPORTING
*   MEMORY_KEY       = 'DEF_OTF_MEMORY_KEY'
      TABLES
        OTF              = lt_otf.
  endif.

For Smartforms technology it is possible to implement the same concept.

Former Member
0 Kudos

Hi Udo,

can you specify the Web Dynpro Java solution for Smartforms?

Regards, Heidi

Udo_Ahle
Explorer
0 Kudos

Hello Heidi,

in

a solution has been given for the java world.

Best regards

Udo

Former Member
0 Kudos

Hello Udo,

officially Web Dnypro ABAP supports Adobe forms.

The Web Dnypro Java solution in an individual solution, and something similar is possible in Web Dynpro ABAP as well.

I would suggest not to use an iFrame UI element for your individual solution, because it's deprecated. But of course you could also use function module CONVERT_OTF with an InteractiveForm UI element.

Regards, Heidi

Udo_Ahle
Explorer
0 Kudos

Hello Heidi,

my company has developed dozends of sapscript forms and smartforms over the past years. It would save a lot of money if we could reuse all this solutions. <i>I mean it would be nice if there was a documentation on how to use the output in pdf format of the old style printing method (sapscript and smartforms) in the WDA world.</i> I think a lot of companies need to provide paper output in form of Handling unit Labels, delivery papers, Shipment papers, invoices ... to their internal and external partners they want to reach over the internet application. For me as the responsible for the technical design it is a show stopper if i can't provide a printing functionality with the same output as our R/3 system would have generated.

Best regards

Udo

Former Member
0 Kudos

Hello Udo,

if you hang on another week or so, I'm sure that an appropriate solution for your issue will be posted...

Regards, Heidi

thomas_szcs
Active Contributor
0 Kudos

Hi Udo,

Have you tried to set legacy_editing_enabled at the method handler of the interactive form ui element? You can access the method handler by property methodhandler at the view element. You need to cast it to interface

IF_WD_IACTIVE_FORM_METHOD_HNDL as follows in wdDoModifyView:


  data:
    lr_interactive_form type ref to cl_wd_interactive_form,
    lr_method_handler   type ref to if_wd_iactive_form_method_hndl.


  lr_interactive_form ?= view->get_element( 'DDIC_BASES_FORM' ).
  lr_method_handler ?= lr_interactive_form->_method_handler.
  lr_method_handler->set_legacy_editing_enabled( abap_true ).

This will allow you to edit old smartforms with a function module based interface. Without setting this flag, the form will remain read-only.

Best regards,

Thomas