Skip to Content

SAP script open_form method always throw exception 6.

Hi,

We have a scenario where we need to convert script form into PDF and then sending that PDF in mail. We dont need Printer dialog also, even after setting dialog option 'X', still it appears.

Approach taken.

Calling the open_form method and passing the below parameters so can get OTF in return through close_form method.

Parameter for open_form.

ELSEIF sy-ucomm = 'EMAIL'.
        l_device = 'MAIL'.
    i_itcpo-tdgetotf = 'X'.
    i_itcpo-tdnoprev = 'X'.
    v_dialog = SPACE.
Data: ls_recipent_id TYPE SO_NAME.
* Get BOR-Objects for Recipient, Sender und Applikation
    ls_recipent_id = 'xyz@abc.com'.
    PERFORM mail_recipient_object USING ls_recipent_id
                                  CHANGING g_mail_rec_obj.
    PERFORM mail_sender_object    CHANGING g_mail_sen_obj.
    PERFORM mail_appl_object      CHANGING g_mail_app_obj.
*    i_itcpo-tdnoprint = 'X'.
*    l_device = 'SCREEN'.
*--------------------------------------------------------------------*
**********************************************************************
  ENDIF.
  CALL FUNCTION 'OPEN_FORM'
       EXPORTING
            device                      = l_device
            form                        = c_form
            options                     = i_itcpo
            language                    = sy-langu
            dialog                      = v_dialog
            MAIL_SENDER                 = g_mail_sen_obj
            mail_recipient              = g_mail_rec_obj
            MAIL_APPL_OBJECT            = g_mail_app_obj
       IMPORTING
            result                      = i_result
       EXCEPTIONS
            canceled                    = 1
            device                      = 2
            form                        = 3
            options                     = 4
            unclosed                    = 5
            mail_options                = 6
            archive_error               = 7
            invalid_fax_number          = 8
            more_params_needed_in_batch = 9
            spool_error                 = 10
            OTHERS                      = 11. 

Call mail_recipient_object

FORM mail_recipient_object  USING    p_ls_recipient
                            CHANGING p_g_mail_rec_obj.

***fill recipent
    CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
     EXPORTING
*       IP_COUNTRY              =
*       IP_FAXNO                =
       IP_MAILADDR             = p_ls_recipient
       IP_TYPE_ID              = 'U'
     IMPORTING
       EP_RECIPIENT_ID         = p_g_mail_rec_obj
*       EP_ADDRESS              =
*       ET_RECIPIENT            =
     EXCEPTIONS
       INVALID_RECIPIENT       = 1
       OTHERS                  = 2              .
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
ENDFORM.

Call mail_sender_object

FORM mail_sender_object  CHANGING p_g_mail_sen_obj.
  CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
 EXPORTING
   IP_SENDER            = sy-uname
 IMPORTING
   EP_SENDER_ID         = p_g_mail_sen_obj
 EXCEPTIONS
   INVALID_SENDER       = 1
   OTHERS               = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.

Call mail_appl_object

FORM mail_appl_object  CHANGING p_mail_app_obj.
  INCLUDE <cntn01>.
  data:
*        g_mail_rec_obj type SWOTOBJID,
*
*g_mail_sen_obj type SWOTOBJID,
*
*g_mail_app_obj type SWOTOBJID,
FOLDER TYPE SWC_OBJECT,
BEGIN OF SOFMFOL_KEY,
FOLDERTYPE LIKE SOFM-FOLTP,
FOLDERYEAR LIKE SOFM-FOLYR,
FOLDERNUMBER LIKE SOFM-FOLNO,
TYPE LIKE SOFM-DOCTP,
YEAR LIKE SOFM-DOCYR,
NUMBER LIKE SOFM-DOCNO,
FORWARDER LIKE SOUB-USRNAM,
END OF SOFMFOL_KEY,
BOR_KEY LIKE SWOTOBJID-OBJKEY.
TABLES: soud.
  SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
  ENDSELECT.
  IF sy-subrc NE 0.
    CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'
      EXPORTING
        sapname        = sy-uname
      EXCEPTIONS
        no_insert      = 1
        sap_name_exist = 2
        x_error        = 3
        OTHERS         = 4.
    IF sy-subrc NE 0.
      CLEAR soud.
    ELSE.
      SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
      ENDSELECT.
    ENDIF.
  ENDIF.
  CLEAR sofmfol_key.
  sofmfol_key-type   = 'FOL'.
  sofmfol_key-year   = soud-inbyr.
  sofmfol_key-number = soud-inbno.
  bor_key = sofmfol_key.
  IF NOT bor_key IS INITIAL.
    swc_create_object folder 'SOFMFOL' bor_key.
    IF sy-subrc = 0.
      swc_object_to_persistent folder p_mail_app_obj.
      IF sy-subrc NE 0.
        CLEAR p_mail_app_obj.
      ENDIF.
    ENDIF.
  ELSE.
    CLEAR p_mail_app_obj.
  ENDIF.
ENDFORM.

But every time OPEN_FORM method throws exception 6.

Can not understand why

Regards

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers