cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform - PDF attachment through E-mail issue

Former Member
0 Kudos

Hi,

A custom form and custom program was created to print the Purchase order information through ME21N, 22n and 23n.

It also has E-mail option. when output medium 5(Simple mail) and 7(External send), email will be send to respective mail-id's with the PDF attachment.

I have issue at the time of saving PO which processed with medium 5. when i save A popup appears "Express document update was terminated received from author". Brief message about it is

"Error Info... 00 671: ABAP/4 processor: COMMIT_IN_POSTING"

In Smartform driver program i am using below function modules to convert OTF into PDF and send through e-mail.

Function Module: CONVERT_OTF.

Function Module: SO_DOCUMENT_SEND_API1.

I am not sure, what i missed out. Can you guys tell is this the correct way to send PDF attachment through E-mail or i missed out any function module for commit.

Regards,

Hemanth.

Edited by: keerthipati hemanth on Jul 31, 2008 1:15 PM

<MOVED BY MODERATOR TO THE CORRECT FORUM>

Edited by: Alvaro Tejada Galindo on Jul 31, 2008 3:14 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member598013
Active Contributor
0 Kudos

Hi Hemant,

Below is the code for the downloading of the smartform into the PDF Format.


*--------------------------------------------------------------------*
* Program Name : ZPPREP_SHOPFLOOR_VIEWER_ZOOM

REPORT zppeerep_shorepfloor_viewer_zoom.

*--------------------------------------------------------------------*
* T A B L E S    D E C L A R A T I O N
*--------------------------------------------------------------------*
*---Tables Used.
TABLES: afpo,
        mara,
        marc,
        aufk,
        afko,
        itcoo,
        nast,                          "Messages
        *nast,                         "Messages
        tnapr,                         "Programs & Forms
        addr_key,
        arc_params,                    "Archive parameters
        toa_dara.                      "Archive parameters



*--------------------------------------------------------------------*
* I N T E R N A L    T A B L E S     D E C L A R A T I O N
*--------------------------------------------------------------------*
*--Internal Tables Used.

*--------------------------------------------------------------------*
* D A T A     D E C L A R A T I O N
*--------------------------------------------------------------------*
*--Global Variables Used.
DATA: ws_matnr LIKE afpo-matnr,
      ws_werks LIKE aufk-werks,
      ws_mtart LIKE mara-mtart,
      ws_wrkst LIKE mara-wrkst,
      ws_fname TYPE rs38l_fnam,
      ws_ctrlp TYPE ssfctrlop,
      ws_optns TYPE ssfcompop,
      w_padest LIKE tsp03l-padest.                          "BMC01+

DATA: da_message_printed(1) TYPE c,
      da_preview_processed(1) TYPE c,
      repeat(1) TYPE c,
      da_subrc LIKE sy-subrc.

DATA: w_otfdata  TYPE ssfcrescl.
DATA: BEGIN OF it_itcoo OCCURS 0.
        INCLUDE STRUCTURE itcoo.
DATA: END OF it_itcoo.
DATA: w_otf  TYPE itcoo.

*--Data Declaration for Printing Layout
DATA: ls_itcpo     TYPE itcpo.
DATA: lf_repid     TYPE sy-repid.
DATA: lf_device    TYPE tddevice.
DATA: cf_retcode   TYPE sy-subrc.
DATA: ls_recipient TYPE swotobjid.
DATA: ls_sender    TYPE swotobjid.
DATA: ls_control_param   TYPE ssfctrlop.
DATA: ls_composer_param  TYPE ssfcompop.
DATA: ls_addr_key        LIKE addr_key.
DATA: w_screen(1) TYPE c.
DATA: xscreen(1) TYPE c.

DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
*--------------------------------------------------------------------*
* C O N S T A N T S
*--------------------------------------------------------------------*
CONSTANTS: c_fas1(8)  TYPE c VALUE 'PRINTFAS',
           c_fas2(15) TYPE c VALUE 'PRINTFASDRAWING',
           c_wip1(8)  TYPE c VALUE 'PRINTWIP',
           c_wip2(15) TYPE c VALUE 'PRINTWIPDRAWING'.

*--------------------------------------------------------------------*
* S E L E C T I O N - S C R E E N.
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
* Production order
PARAMETERS: p_aufnr LIKE afpo-aufnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK bl1.

*--------------------------------------------------------------------*
START-OF-SELECTION.
*--------------------------------------------------------------------*
*--Begin of Commenting                   "
*--Get Partially processed orders
  MOVE: sy-mandt         TO nast-mandt,
        'V1'             TO nast-kappl,
        p_aufnr          TO nast-objky,
        p_aufnr          TO nast-parnr,
        sy-langu         TO nast-spras,
        sy-datum         TO nast-erdat,
        '1'              TO nast-nacha,
        '3'              TO nast-vsztp,
        'X'              TO nast-manue,
        sy-uname         TO nast-usnam,
        'DFLT'           TO nast-ldest,
        sy-langu         TO nast-tdspras,
        'Shop Floor Papers' TO nast-tdcovtitle,
        '1'              TO nast-tdarmod,
        'BUS2032'        TO nast-objtype.

*--Printer settings
  CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
    EXPORTING
      pi_nast       = nast
      pi_repid      = sy-repid
    IMPORTING
      pe_returncode = cf_retcode
      pe_itcpo      = ls_itcpo
      pe_device     = lf_device
      pe_recipient  = ls_recipient
      pe_sender     = ls_sender.

  MOVE-CORRESPONDING ls_itcpo TO ls_composer_param.
  ls_control_param-device      = 'PRINTER'.
  ls_control_param-no_dialog   = 'X'.
  ls_control_param-preview     = 'X'.
  ls_control_param-getotf      = ls_itcpo-tdgetotf.
  ls_control_param-langu       = sy-langu.

*--End   of Commenting                   "
*--Start of Addition                     "
  CLEAR:   ws_werks.
  SELECT   SINGLE werks
           INTO   ws_werks
           FROM   aufk
           WHERE  aufnr = p_aufnr.

  CLEAR:   ws_matnr.
  SELECT   SINGLE plnbez
           INTO   ws_matnr
           FROM   afko
           WHERE  aufnr = p_aufnr.

  CLEAR:   marc.
  SELECT   SINGLE matgr
           INTO   marc-matgr
           FROM   marc
           WHERE  matnr = ws_matnr
           AND    werks = ws_werks.


*--End   of Addition                     "
*  CHECK NOT ws_matnr IS INITIAL.        
  IF NOT ws_matnr IS INITIAL.           

*--Start of Addition                     
    SELECT   SINGLE matgr
             INTO   marc-matgr
             FROM   marc
             WHERE  matnr = ws_matnr
             AND    werks = ws_werks.

*--Start of Addition BY Rapidigm01_01+
  ELSE.
    marc-matgr = c_wip1.
  ENDIF.
*--End Of Addition BY Rapidigm01_01+
*--End   of Addition                     "
*--------------------------------------------------------------------*
END-OF-SELECTION.
*--------------------------------------------------------------------*
  PERFORM call_smartform.

*--------------------------------------------------------------------*
* F O R M    R O U T I N E S
*--------------------------------------------------------------------*
*&-------------------------------------------------------------------*
*&      Form  call_smartform
*&-------------------------------------------------------------------*
*       text
*--------------------------------------------------------------------*
FORM call_smartform.

  CLEAR: ws_ctrlp, ws_optns, ws_fname.

*--Start of Addition                                 "

  TRANSLATE marc-matgr TO UPPER CASE.
  IF marc-matgr = c_fas1 OR
     marc-matgr = c_fas2.
    PERFORM call_paper_a.
  ELSEIF marc-matgr = c_wip1 OR
         marc-matgr = c_wip2.
    PERFORM call_paper_b.
  ENDIF.

*--End   of Addition                                 "


ENDFORM.                    "call_smartform

*&-------------------------------------------------------------------*
*&      Form  call_paper_a
*&-------------------------------------------------------------------*
*       text
*--------------------------------------------------------------------*
FORM call_paper_a.

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
*>>BC SPARTA03    DATE: 19/05/2008
*      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_A'  "Rapidigm03_01-
      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_C'  "Rapidigm03_01-
*<<EC SPARTA03    DATE: 19/05/2008
*       formname  = 'ZPPSF_SHOP_FLOOR_PAPER_A_2893'   "Rapidigm03_01+
    IMPORTING
      fm_name            = ws_fname
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.

  CHECK NOT ws_fname IS INITIAL.

  CLEAR w_otfdata.
  ls_control_param-getotf = 'X'.

  CALL FUNCTION ws_fname
    EXPORTING
      archive_index      = toa_dara
      archive_parameters = arc_params
      control_parameters = ls_control_param
      mail_recipient     = ls_recipient
      mail_sender        = ls_sender
      output_options     = ls_composer_param
      user_settings      = ' '
      is_nast            = nast
      aufnr              = p_aufnr
      flag_orig          = 'X'
    IMPORTING
      job_output_info    = w_otfdata
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.

  LOOP AT w_otfdata-otfdata INTO w_otf.

    APPEND w_otf TO it_itcoo.

  ENDLOOP.

  CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
    TABLES
      otf_table = it_itcoo.


ENDFORM.                    "call_paper_a

*&-------------------------------------------------------------------*
*&      Form  call_paper_b
*&-------------------------------------------------------------------*
*       text
*--------------------------------------------------------------------*
FORM call_paper_b.

  DATA: ws_doknr TYPE draw-doknr,
        ws_dokvr TYPE draw-dokvr.

  CLEAR: ws_doknr, ws_dokvr.

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_B'
    IMPORTING
      fm_name            = ws_fname
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.

  CHECK NOT ws_fname IS INITIAL.

  CLEAR w_otfdata.
  ls_control_param-getotf = 'X'.

  CALL FUNCTION ws_fname
    EXPORTING
      archive_index      = toa_dara
      archive_parameters = arc_params
      control_parameters = ls_control_param
      mail_recipient     = ls_recipient
      mail_sender        = ls_sender
      output_options     = ls_composer_param
      user_settings      = ' '
      is_nast            = nast
      aufnr              = p_aufnr
      doknr              = ws_doknr
      dokvr              = ws_dokvr
      flag_orig          = 'X'
    IMPORTING
      job_output_info    = w_otfdata
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.

  LOOP AT w_otfdata-otfdata INTO w_otf.

    APPEND w_otf TO it_itcoo.

  ENDLOOP.

  CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
    TABLES
      otf_table = it_itcoo.


ENDFORM.                    "call_paper_b

Answers (3)

Answers (3)

Former Member
0 Kudos

Resolved myself

former_member1242340
Participant
0 Kudos

Hi,

try this function module

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = g_filesize

TABLES

otf = l_otfdata_tab "da...

lines = g_pdf_tab "...a

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

CLEAR objbin.

REFRESH objbin.

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = g_pdf_tab "da...

t_target_tab = objbin. "...a

EXPORT objbin TO MEMORY ID nast-objky.

Former Member
0 Kudos

Hi,

Mail with attachment is coming to Mail box. Problem is with the error, When i saves the PO it get saves and later i goto messages to see the status of output type i will be getting the "Express document update process terminated". Do you have any idea how to get ride of message.

Regards,

Hemanth.

Former Member
0 Kudos

It seems data is not getting updated into database due to some reason(s). From transactions SM13, ST22,SM21 u will get the details for it.

Regards,

Joy.

Former Member
0 Kudos

Hi,

Please check the links below with sample code .

Hope this solves your issue.

Regards

Chandralekha.