‎2013 Sep 05 1:32 PM
Hello!
Normaly we are printing our invoices with SAPSCRIPT on a printer. Sometimes we are creating with the same SAPSCRIPT an E-Mail with the invoice as PDF-Attachment. The attachment name is everytime the same. We only create a variable subject title in our sapscript.
Now we have a special requirement of one customer. This customer would like to get his invoices only as PDF-Attachment per E-Mail. So this is possible for use but what he also want is that the attachment name should be variable. He has defind a instruction to create the attachment name (name must contains invoice number and the date of creating the invoice and some fix parts).
How can we implement this requirement in our sapscript-report?
Best Regards
Markus
‎2013 Sep 05 2:01 PM
Hi Markus
In the driver program or smart form u will get invoice numbe and invoice date , create new variable like string, concatenate invoice number , date into string ,
pass the string in attachment name.
Thanks
srini
‎2013 Sep 05 2:36 PM
Hi ,
For creating the attacment name does he using any Function Module ..he is using means
Define One variable say
VAR1 TYPE CHAR255
After that Concatenate invoice number and the date of creating the invoice and some fix parts into VAR1 and pass this to That function module .
Thianks,
Hiriz
‎2013 Sep 05 4:28 PM
Hi,
Assuming you are using class CL_BC and you are using "otfdata" .
Look at form "mail_1_prep_4" you can rename the attachment as requested .
the only limitation is heading length (50 Characters) and valid file name see "attachment_subject TYPE so_obj_des"
*----------------------------------------------------------------------*
FORM mail_1_prep_4
CHANGING
ob_document_bcs TYPE REF TO cl_document_bcs .
DATA: st_thead TYPE thead .
DATA: it_lines TYPE tline_tab .
st_thead-tdobject = 'TEXT' .
st_thead-tdname = p_tdname .
st_thead-tdid = 'ST' .
st_thead-tdspras = 'E' .
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = st_thead-tdid
language = st_thead-tdspras
name = st_thead-tdname
object = st_thead-tdobject
IMPORTING
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
* CALL FUNCTION 'INIT_TEXT'
* EXPORTING
* id = st_thead-tdid
* language = st_thead-tdspras
* name = st_thead-tdname
* object = st_thead-tdobject
* TABLES
* lines = it_lines
* EXCEPTIONS
* id = 1
* language = 2
* name = 3
* object = 4
* OTHERS = 5.
DATA: st_lines LIKE LINE OF it_lines .
DO 1000 TIMES .
st_lines-tdformat = '*' .
st_lines-tdline = 'This is a test +++++++++++++++++++++++++++++++++++++++++++++++' .
APPEND st_lines TO it_lines .
ENDDO .
DATA: it_otfdata TYPE otf_t_itcoo .
DATA: st_options TYPE itcpo.
st_options-tdgetotf = abap_true .
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
dialog = abap_false
header = st_thead
OPTIONS = st_options
TABLES
lines = it_lines
otfdata = it_otfdata
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
unknown = 6
format = 7
textformat = 8
communication = 9
bad_pageformat_for_print = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA: it_otfdata_m TYPE otf_t_itcoo .
* "Merge pdf output demo"
APPEND LINES OF it_otfdata TO it_otfdata_m .
DATA: bin_file TYPE xstring .
DATA: it_lines_dummy TYPE tline_tab .
DATA: bin_filesize TYPE i .
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_file = bin_file
bin_filesize = bin_filesize
TABLES
otf = it_otfdata_m
lines = it_lines_dummy
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
DATA: it_solix TYPE solix_tab .
CALL METHOD cl_bcs_convert=>xstring_to_solix
EXPORTING
iv_xstring = bin_file
RECEIVING
et_solix = it_solix.
DATA: attachment_subject TYPE so_obj_des .
MESSAGE s000(oo) WITH 'attachment PDF hex' space INTO attachment_subject .
TRY.
CALL METHOD ob_document_bcs->add_attachment
EXPORTING
i_attachment_type = 'pdf'
i_attachment_subject = attachment_subject
i_att_content_hex = it_solix.
CATCH cx_document_bcs .
ENDTRY.
ENDFORM . "mail_1_prep_4
*----------------------------------------------------------------------*
Regards.
Eitan.
The full program is here:
http://scn.sap.com/servlet/JiveServlet/download/14309154-180712/y_r_eitan_test_10_02.txt.zip
‎2013 Sep 06 10:32 AM
Hello!
Thanks to all for there answer.
We have already changed the subject title in our SAPSCRIPT-program (field NAST-TDCOVTITLE). Now I should change the name of the attachment in our SAPSCRIPT-program.
Regards
Markus