2012 Oct 25 9:43 PM
Hi,
I have a requirement to create a new QM action to allow users send shop papers to users as well as other documents. The requirement is to pre-attach a shop paper, SAPscript, as an attachment to the SO_DYNP_OBJECT_SEND function module , and to allow the user to enter the title, message note, as well as adding any other attachments as needed.
FM SO_DYNP_OBJECT_SEND works well for this purpose as I am able to add the shop paper to the FM in a preliminary step, and allow the user to update the title, message texts, and add additional attachments. My problem is that the SAPscript attachment is not readable when received by the receiver. I get an Adobe Reader error saying that it could not open the file because the file had been damaged, or it wasn’t correctly decoded. My guess is that I have done something wrong with the packing list, but I am not entirely sure what the problem is.
Below is the test code I am using for this project.. Any help with this issue is greatly appreciated, as I am running out of ideas as to what the problem is.
Thanks,
Roy
<abap> that creates the SAPscript form
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = itcpp
TABLES
otfdata = otfdata
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
OTHERS = 3.
IF sy-subrc = 0.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = c_format_pdf
IMPORTING
bin_filesize = g_filesize
TABLES
otf = otfdata
lines = g_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = g_pdf_tab
t_target_tab = objbin.
* Make each line 255 characters
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
TABLES
content_in = objbin
content_out = objbin2.
LOOP AT objbin2.
MOVE-CORRESPONDING objbin2 TO attach_content.
APPEND attach_content.
ENDLOOP.
* Mail body
APPEND 'Message content' TO message_content.
objhead = 'PDFattch.pdf'.
APPEND objhead.
* Packing List
attach_list-transf_bin = 'X'.
attach_list-head_start = 1.
attach_list-head_num = 0.
attach_list-body_start = 1.
attach_list-objtp = 'RAW'. " 'BIN' 'EXT' 'PDF' 'RAW' 'SCR' 'RAW'...
attach_list-objdes = 'PDFattachment'.
attach_list-objla = sy-langu.
DESCRIBE TABLE g_pdf_tab LINES sy-tfill.
attach_list-body_num = sy-tfill.
attach_list-objnam = 'PDFattachment'. "Attachment
attach_list-objlen = attach_list-body_num * 255.
attach_list-file_ext = 'PDF'.
APPEND attach_list.
* Receivers
CLEAR receiver_list.
receiver_list-recextnam = 'testuser@sfc.com'.
receiver_list-adr_name = 'testuser@sfc.com'.
* EMAIL ADDRESS
receiver_list-recesc = 'E'. "<-
receiver_list-sndart = 'INT'."<-
receiver_list-sndpri = '1'."
APPEND receiver_list.
CALL FUNCTION 'SO_DYNP_OBJECT_SEND'
EXPORTING
outbox_flag = 'S'
raw_editor = 'X'
IMPORTING
return_code = lv_rc
TABLES
** objcont = message_content
** objhead = objhead
rec_tab = receiver_list
packing_list = attach_list
att_cont = attach_content
*** att_head = attach_header
EXCEPTIONS
object_not_sent = 1
owner_not_exist = 2
parameter_error = 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.
ENDIF.
ENDFORM. " SEND_SAPSCRIPT
2012 Oct 30 1:41 PM
This is resolved. The OBLJEN, Size of Document Content, parameter was not required in the packing list.
See below the cleaned up working version of my test code.
Thanks,
Roy
* Call SAPscript and generate the OTF Data
CALL FUNCTION 'ZQM_PRINT_CUST_COMP'
EXPORTING
qmnum = p_qmnum
device = 'PRINTER'
dialog = ' '
OPTIONS = wa_options
get_otf = 'X' " Generate OTF Data parameter
IMPORTING
return = wa_return
TABLES
otf_data = otfdata
EXCEPTIONS
notif_not_found = 1
unable_to_open_form = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Unable to generate notification printout form for &
MESSAGE i035(zqm) WITH p_qmnum.
ENDIF.
* Convert the OTF to PDF format
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = otfdata
doctab_archive = it_doctab_archive
lines = it_lines132
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
* Set line width to 255
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
TABLES
content_in = it_lines132
content_out = it_lines255
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
DESCRIBE TABLE it_lines255 LINES i_linecount.
* Packing List
CLEAR: attach_list.
attach_list-transf_bin = 'X' . " binary attachment.
attach_list-objtp = 'BIN' .
attach_list-objdes = 'shop_paper.pdf '.
attach_list-head_start = 1 .
attach_list-head_num = 0 .
attach_list-body_start = i_bodystart .
attach_list-body_num = i_linecount .
* attach_list-objlen = i_linecount * 255. " ****** NOT NEEDED WITH FM SO_DYNP_OBJECT_SEND
APPEND attach_list .
* Build the attachment content table.
LOOP AT it_lines255 INTO wa_lines255.
APPEND wa_lines255 TO attach_content.
ENDLOOP.
* Receivers
CLEAR receiver_list.
receiver_list-recextnam = p_recvr.
receiver_list-adr_name = p_recvr.
* EMAIL ADDRESS
receiver_list-recesc = 'E'. "<-
receiver_list-sndart = 'INT'."<-
receiver_list-sndpri = '1'."
APPEND receiver_list.
CALL FUNCTION 'SO_DYNP_OBJECT_SEND'
EXPORTING
raw_editor = 'X'
IMPORTING
return_code = lv_rc
TABLES
rec_tab = receiver_list
packing_list = attach_list
att_cont = attach_content
EXCEPTIONS
object_not_sent = 1
owner_not_exist = 2
parameter_error = 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.
2012 Oct 30 1:41 PM
This is resolved. The OBLJEN, Size of Document Content, parameter was not required in the packing list.
See below the cleaned up working version of my test code.
Thanks,
Roy
* Call SAPscript and generate the OTF Data
CALL FUNCTION 'ZQM_PRINT_CUST_COMP'
EXPORTING
qmnum = p_qmnum
device = 'PRINTER'
dialog = ' '
OPTIONS = wa_options
get_otf = 'X' " Generate OTF Data parameter
IMPORTING
return = wa_return
TABLES
otf_data = otfdata
EXCEPTIONS
notif_not_found = 1
unable_to_open_form = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Unable to generate notification printout form for &
MESSAGE i035(zqm) WITH p_qmnum.
ENDIF.
* Convert the OTF to PDF format
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = otfdata
doctab_archive = it_doctab_archive
lines = it_lines132
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
* Set line width to 255
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
TABLES
content_in = it_lines132
content_out = it_lines255
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
DESCRIBE TABLE it_lines255 LINES i_linecount.
* Packing List
CLEAR: attach_list.
attach_list-transf_bin = 'X' . " binary attachment.
attach_list-objtp = 'BIN' .
attach_list-objdes = 'shop_paper.pdf '.
attach_list-head_start = 1 .
attach_list-head_num = 0 .
attach_list-body_start = i_bodystart .
attach_list-body_num = i_linecount .
* attach_list-objlen = i_linecount * 255. " ****** NOT NEEDED WITH FM SO_DYNP_OBJECT_SEND
APPEND attach_list .
* Build the attachment content table.
LOOP AT it_lines255 INTO wa_lines255.
APPEND wa_lines255 TO attach_content.
ENDLOOP.
* Receivers
CLEAR receiver_list.
receiver_list-recextnam = p_recvr.
receiver_list-adr_name = p_recvr.
* EMAIL ADDRESS
receiver_list-recesc = 'E'. "<-
receiver_list-sndart = 'INT'."<-
receiver_list-sndpri = '1'."
APPEND receiver_list.
CALL FUNCTION 'SO_DYNP_OBJECT_SEND'
EXPORTING
raw_editor = 'X'
IMPORTING
return_code = lv_rc
TABLES
rec_tab = receiver_list
packing_list = attach_list
att_cont = attach_content
EXCEPTIONS
object_not_sent = 1
owner_not_exist = 2
parameter_error = 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.