cancel
Showing results for 
Search instead for 
Did you mean: 

Emailing smartform as PDF from Webdynpro is causing dump "Screen output without connection to user"

Former Member
0 Kudos

Hello all,

I have a request that at the end of the PCR workflow, to email the PCR as PDF to a person.

Our PCR is created in Webdynpro, which triggers a workflow.

In the method for closing the PCR, I am calling a function module with the import parameters from the Webdynpro context. This function module in return is calling a smartform to which is passing the same import parameters (from the function module). It is then creating OTF data, which I am converting to binary data and then this is emailed as PDF to a person. Everything works good in the sense that it is sending the email with the PDF from the smartform attached and it's also triggering the workflow...except for one problem...in Webdynpro it is generating one dump:

Attached is the code of the function module I created (FM ZHR.txt).

In the Webdynpro I am calling the function module like that:

CALL FUNCTION 'ZHR_PCR_PDF_EMAIL'

    EXPORTING I_PERNR = LS_PATD-PERNR  "which is retrieved from the context of Webdynpro

.

If I take out the import parameter output_options from l_functionmodule, I don't get any dump, but then it doesn't send the email....

I know the error is caused by the fact that is calling GUI screen, but I don't know what I need to change in the structure ls_outputoptions.

Can anyone help with this?

Thank you,

Iuliana

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The Function Module code:

FUNCTION ZHR_PCR_PDF_EMAIL.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     REFERENCE(I_PERNR) TYPE  PERSNO

*"----------------------------------------------------------------------

DATA: l_form TYPE tdsfname,

      l_functionmodule TYPE rs38l_fnam,

      ls_out_parameters TYPE pri_params,

      ls_outputoptions TYPE ssfcompop,

      ls_output TYPE ssfcrescl,

      ls_control_param TYPE ssfctrlop,

      lv_pernr type persno.

DATA:   flt_otf_data TYPE tsfotf,

        fl_pdf_length TYPE i,

        fl_pdf_xstring TYPE xstring,

        flt_pdf_data TYPE tsftext.

types: begin of ty_solix,

       line TYPE x LENGTH 255,

       END OF ty_solix.

data: lt_solix type STANDARD TABLE OF ty_solix.

data: gd_doc_data like sodocchgi1,

      gd_error type sy-subrc,

      gd_sent_all(1) type c,

      it_packing_list like sopcklsti1 occurs 0 with header line,

      it_receivers like somlreci1 occurs 0 with header line,

      it_message type standard table of SOLISTI1 initial size 0

                with header line,

      gt_objbin TYPE TABLE OF solisti1.

lv_pernr = i_pernr.

* execute document form (print)

l_form = 'ZHR_PCR'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

  EXPORTING

    formname           = l_form

  IMPORTING

    fm_name            = l_functionmodule

  EXCEPTIONS

    no_form            = 1

    no_function_module = 2

    OTHERS             = 3.

CLEAR ls_outputoptions.

ls_control_param-no_dialog = 'X'.

ls_control_param-preview = space.

ls_control_param-GETOTF = 'X'.

ls_outputoptions-tddest   = 'LOCL'.

* call function to generate form!!

CALL FUNCTION l_functionmodule

  EXPORTING

    control_parameters = ls_control_param

    output_options     = ls_outputoptions

*   user_settings      = 'X'

    user_settings      = ''

    i_pernr            = lv_pernr

  IMPORTING

    job_output_info    = ls_output

  EXCEPTIONS

    formatting_error   = 1

    internal_error     = 2

    send_error         = 3

    user_canceled      = 4

    OTHERS             = 5.

IF syst-subrc NE 0.

ELSE.

  flt_otf_data = ls_output-otfdata.

ENDIF.

IF NOT flt_otf_data IS INITIAL.

  CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

      format                = 'PDF'

    IMPORTING

      bin_filesize          = fl_pdf_length

      bin_file              = fl_pdf_xstring

    TABLES

      otf                   = flt_otf_data

      lines                 = flt_pdf_data

    EXCEPTIONS

      err_max_linewidth     = 1

      err_format            = 2

      err_conv_not_possible = 3

      err_bad_otf           = 4

      OTHERS                = 5.

endif.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

  EXPORTING

    buffer     = fl_pdf_xstring

  TABLES

    binary_tab = lt_solix.

IF ls_output-otfdata is not initial.

  data: I_EMAIL_PO_NOTIF    type soli_tab,

        L_EMAIL             LIKE LINE OF I_EMAIL_PO_NOTIF.

* Blank line

  CLEAR: L_EMAIL.

  APPEND L_EMAIL TO it_message.

* Column headings

  CLEAR: L_EMAIL.

  L_EMAIL = 'Testing PCR form:'.

  APPEND L_EMAIL TO it_message.

               " POPULATE_MESSAGE_TABLE

*&---------------------------------------------------------------------*

*&      Form  POPULATE_MESSAGE_TABLE

*&---------------------------------------------------------------------*

*       Adds text to email text table

*----------------------------------------------------------------------*

  DATA: L_EMAIL_SUBJECT TYPE SOOD1-OBJDES.

  L_EMAIL_SUBJECT = 'Test'.

* Fill the document data.

  gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes

  gd_doc_data-obj_langu = sy-langu.

  gd_doc_data-obj_name  = 'SAPRPT'.

  gd_doc_data-obj_descr = L_EMAIL_SUBJECT.

  gd_doc_data-sensitivty = 'F'.

  describe table it_message lines it_packing_list-body_num.

  it_packing_list-transf_bin = space.

  it_packing_list-head_start = 1.

  it_packing_list-head_num   = 0.

  it_packing_list-body_start = 1.

  it_packing_list-doc_type   = 'RAW'.

  append it_packing_list.

  clear it_packing_list.

  it_packing_list-transf_bin = 'X'.

  it_packing_list-head_start = 1.

  it_packing_list-head_num = 1.

  it_packing_list-body_start = 1.

  DESCRIBE TABLE lt_solix LINES it_packing_list-body_num.

  it_packing_list-doc_type = 'PDF'.

  it_packing_list-obj_descr = 'PCR'.

  it_packing_list-obj_name = 'test'.

  it_packing_list-doc_size = it_packing_list-body_num * 255.

  APPEND it_packing_list.

** Add the recipients email address

  clear it_receivers.

  refresh it_receivers.

  it_receivers-receiver = 'ievdochi@steelcase.com'.

  it_receivers-rec_type = 'U'.

  it_receivers-com_type = 'INT'.

  it_receivers-notif_del = 'X'.

  it_receivers-notif_ndel = 'X'.

  append it_receivers.

  append fl_pdf_xstring to gt_objbin.

  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

      document_data              = gd_doc_data

      PUT_IN_OUTBOX              = 'X'

      SENDER_ADDRESS             = 'PRODHR1@steelcase.com'

      SENDER_ADDRESS_TYPE        = 'INT'

      COMMIT_WORK                = 'X'

    IMPORTING

      SENT_TO_ALL                = gd_sent_all

    TABLES

      packing_list               = it_packing_list

*     PACKING_LIST               = GT_OBJPACK

      CONTENTS_TXT               = it_message

      CONTENTS_HEX               = lt_solix

*     CONTENTS_HEX               = flt_pdf_data

      receivers                  = it_receivers

    EXCEPTIONS

      TOO_MANY_RECEIVERS         = 1

      DOCUMENT_NOT_SENT          = 2

      DOCUMENT_TYPE_NOT_EXIST    = 3

      OPERATION_NO_AUTHORIZATION = 4

      PARAMETER_ERROR            = 5

      X_ERROR                    = 6

      ENQUEUE_ERROR              = 7

      OTHERS                     = 8.

  IF sy-subrc <> 0.

* Implement suitable error handling here

  ENDIF.

* Store function module return code

  gd_error = sy-subrc.

* Get it_receivers return code

  loop at it_receivers.

  endloop.

                  "F_SEND_EMAIL

*&---------------------------------------------------------------------*

*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM

*&---------------------------------------------------------------------*

*       Instructs mail send program for SAPCONNECT to send email.

*----------------------------------------------------------------------*

  wait up to 2 seconds.

  if gd_error eq 0.

    submit rsconn01 with mode = 'INT'

                  with output = 'X'

                  and return.

  endif.

                  " INITIATE_MAIL_EXECUTE_PROGRAM

endif.

ENDFUNCTION.

former_member184578
Active Contributor
0 Kudos

Hi,

Check sy-subrc value when you don't pass output options to know why otf output is not returning.

Also try this instead of the one you wrote,

ls_control_param-no_dialog = 'X'.

ls_control_param-GETOTF = 'X'.

ls_outputoptions-tdnoprev  = 'X'.

Regards,

Kiran