PDA

Ver la Versión Completa : parámetro MAIL_APPL_OBJ.


beazoria
21/06/07, 07:01:42
Hola¡

Buenos días, tengo un smartform que quiero enviar via mail por medio de un spool, tengo todo rellenado menos el parametro parámetro MAIL_APPL_OBJ, que no sé como rellenarlo o si por eso no funciona.

Cuando ejecuto la SOST, me aparece mi orden de envío pero con estatus de "Ninguna entrada en la cola de espera".

Ayuda¡¡¡¡¡¡¡¡¡ :eek: :eek:

drmezzetta
21/06/07, 12:56:57
Aca te paso un ejemplo, quizás te sirva:

** Data declaration .....

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_REPORT'
IMPORTING
fm_name = v_form_name
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.
w_ctrlop-getotf = 'X'.
w_ctrlop-no_dialog = 'X'.
w_compop-tdnoprev = 'X'.
w_compop-tddest = 'Locl'.
w_ctrlop-no_dialog = 'X'.
w_ctrlop-device = 'PRINTER'.

CALL FUNCTION v_form_name
EXPORTING
control_parameters = w_ctrlop
output_options = w_compop
user_settings = ' '
l_load = p_load
IMPORTING
job_output_info = w_return
TABLES
i_output = i_output
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.
i_otf[] = w_return-otfdata[].

CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
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 PDF from 132 to 255.
LOOP AT i_tline.
* Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
* Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
* Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR w_objhead.
* Object with PDF.
i_objbin[] = i_record[].
DESCRIBE TABLE i_objbin LINES v_lines_bin.
* Object with main text of the mail.
i_objtxt = text-002.
APPEND i_objtxt.
CLEAR i_objtxt.
APPEND i_objtxt.
i_objtxt = 'Kind regards,'.
APPEND i_objtxt.
i_objtxt = 'Client facing team'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
* Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = 'Shipment Summary Report'.
w_doc_chng-sensitivty = 'O'. "Standard
w_doc_chng-doc_size = v_lines_txt * 255.
* Pack to main body as RAW.
* Obj. to be transported not in binary form
CLEAR i_objpack-transf_bin.
* Start line of object header in transport packet
i_objpack-head_start = 1.
* Number of lines of an object header in object packet
i_objpack-head_num = 0.
* Start line of object contents in an object packet
i_objpack-body_start = 1.
* Number of lines of the object contents in an object packet
i_objpack-body_num = v_lines_txt.
* Code for document class
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
* Packing as PDF.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'Smartform'.
CONCATENATE 'Hazard report-' p_load '.pdf' INTO i_objpack-obj_descr.
i_objpack-doc_size = v_lines_bin * 255.
APPEND i_objpack.

IF sy-subrc = 0.
LOOP AT i_misc INTO w_misc.
i_reclist-receiver = w_misc-z_value_1.
i_reclist-express = 'X'.
i_reclist-rec_type = 'U'. "Internet address
APPEND i_reclist.
ENDLOOP.

* Sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = w_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Mail sent'(003)
txt1 = 'The report is sent via e-mail.'(004)
txt2 = ' '.
LEAVE PROGRAM.
ENDIF.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'No e-mail specified'(005)
txt1 = 'You need to maintain the e-mail adress in table'(006)
txt2 = text-007.
LEAVE PROGRAM.
ENDIF.

beazoria
21/06/07, 14:20:57
Hola de nuevo,

Ya lo he solucionado, lo único que tenia que poner era un commit work al final de la llama a la función del modulo del smartform. Así que solo es necesario el siguiente código (no hace falta rellenar parametro MAIL_APPL_OBJ).

Akí va el código:

*---------------Buscar foto de material,
SELECT *
FROM stxbitmaps
INTO stxbitmaps
UP TO 1 ROWS
WHERE TDOBJECT = 'GRAPHICS'
AND TDNAME = i_dats_form-matnr
AND TDID = 'BMAP'.
ENDSELECT.

IF sy-subrc = 0.
* parametro que informa si la foto será en b/n o en color
l_tipo_img = stxbitmaps-tdbtype.

ELSE.

l_tipo_img = ''.

ENDIF.
---------------------*
R_PARAM-NO_DIALOG = 'X'. "No popup
R_INPUT-TDNOPREV = 'X'. "No preview

D_DEVICE = 'MAIL'.

R_INPUT-tdnewid = 'X'. "nueva orden spool
R_INPUT-tdimmed = 'X'. "salida inmediata

* MONTAR ESTRUCTURA DEL MAIL
R_INPUT-tddataset = text-111.
R_INPUT-tdsuffix1 = text-112.
R_INPUT-tdsuffix2 = sy-uname.

* Titulo email
CONCATENATE text-113
i_dats_form-ematn
i_dats_form-name1
i_dats_form-bukrs
INTO R_INPUT-tdtitle
SEPARATED BY space.

R_PARAM-DEVICE = D_DEVICE.

CALL FUNCTION mod_func
EXPORTING
V_LOGO = i_dats_form-logo "LOGO
V_MODO = l_tipo_img "B/N O COLOR
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = R_PARAM
* MAIL_APPL_OBJ = ls_MAIL_APPL_OBJ
MAIL_RECIPIENT = d_lvs_recipient
MAIL_SENDER = d_lvs_sender
OUTPUT_OPTIONS = R_INPUT
* USER_SETTINGS = 'X'
IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO = JOB_OUTPUT_OPTIONS = R_OUTPUT
TABLES
I_PZA_COMPRA = i_dats_form
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.

COMMIT WORK.

* Si se produce un error, mostrarlo.
IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.