06-19-2007 12:15 PM
Hi,
Can I send documents like XLS, PDF or TXT to fax from SAP? How can I do that?
Thanks.
06-19-2007 12:19 PM
Hi
Use the Medium 2 for sending FAX
Like how you take printout using Medium 1
you can send FAX in similar way using the same Output type , Print program and script output.
By default the driver programs handle the communication type of FAX
You have to configure the FAX in SPAD and to send
Reward points for useful Answers
Regards
Anji
07-29-2007 1:03 PM
HI anji ,
normally we will print the layout ..
how does the communication type will trigger like print , email, fax..
can we get all types of outputs?
can u tell me how can i send script output as fax and mail ? ..
points will be rewarded..
waiting for u r reply..
06-19-2007 12:20 PM
Hi,
U can do that.
Use the following code :
Use FM 'PRINT_TEXT' for FAX.
Pass parameters as follows :-
Exporting
DEVICE = 'TELEFAX' "
DIALOG = 'X' " To get the option of Print Preview along with the fax number on dialog box
HEADER = POPT
Importing
RESULT = PRES " of type ITCPP
Tables
LINE = ITAB_DATA.
POPT is structure of type ITCPO.
Populate following values in POPT :
POPT-TDNEWID = 'X'
POPT-TDIMMED = 'X'
POPT-TDLIFETIME = 8 "To keep 8 days in spool
POPT-TDTELENUM = <Fax Number> " Without country code
POPT-TELELAND = <Country> " Country code
Best regards,
Padmam.
06-19-2007 12:30 PM
Actually, the problem is this. There is a standard functionality that can send documents (e.g. XLS) via fax, email, etc. When sent via email, there is no problem. When sent via fax, the document is not sent correctly. What may be the problem?
06-19-2007 1:48 PM
Hi Padmam,
You said that I can actually send the excel file via fax. If I will send the excel file into fax, how will it look like? Will it look like how we see it in the computer screen? Or we should transfer first the contents of the file into an internal table and the output will just look like a text file?
Thanks.
06-19-2007 12:28 PM
hi..
This is the sample code previously I achieved the same requirement.
FORM send_mail_2 USING msgid msgno msgv1.
mailuser oder Gruppe like sy-uname default 'Ruckerk'.
DATA: express_hold_time LIKE sovaltime.
DATA: text LIKE sotxtinfo.
DATA: receiver LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
MESSAGE ZF100 (FTP an UDB fehlgeschlagen)
text-msgid = msgid.
text-msgno = msgno.
text-msgv1 = msgv1.
text-msgv2 = ' '.
text-msgv3 = ' '.
text-msgv4 = ' '.
express_hold_time
express_hold_time-days = 01.
express_hold_time-h_min_sec = 240000.
receiver
receiver-receiver = mreceivr.
Gruppe von Empfängern
receiver-rec_type = 'C'.
und Expressmeldung ausgeben
receiver-express = 'X'.
APPEND receiver.
CALL FUNCTION 'MESSAGE_SEND_AS_MAIL'
EXPORTING
msgid = text-msgid
msgno = text-msgno
msgv1 = text-msgv1
msgv2 = text-msgv2
msgv3 = text-msgv3
TABLES
receivers = receiver.
IF sy-subrc <> 0.
WRITE:/ 'hat nicht geklappt', 'SY-SUBRC =', sy-subrc.
ENDIF.
PERFORM print_error_report.
Fehlermeldung zum Abbrechen des Report's ausgeben.
MESSAGE e398 WITH 'Jobabbruch' msgv1.
ENDFORM. " SEND_MAIL_2
Thanks
Ashu
06-19-2007 12:29 PM
Hi,
pls chk this sample code.
report ztest.
data: itcpo like itcpo,
tab_lines like sy-tabix.
Variables for EMAIL functionality
data: maildata like sodocchgi1.
data: mailpack like sopcklsti1 occurs 2 with header line.
data: mailhead like solisti1 occurs 1 with header line.
data: mailbin like solisti1 occurs 10 with header line.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: solisti1 like solisti1 occurs 0 with header line.
perform send_form_via_email.
************************************************************************
FORM SEND_FORM_VIA_EMAIL *
************************************************************************
form send_form_via_email.
clear: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.
refresh: mailtxt, mailbin, mailpack, mailhead, mailrec.
Creation of the document to be sent File Name
maildata-obj_name = 'TEST'.
Mail Subject
maildata-obj_descr = 'Subject'.
Mail Contents
mailtxt-line = 'Here is your file'.
append mailtxt.
Prepare Packing List
perform prepare_packing_list.
Set recipient - email address here!!!
mailrec-receiver = 'you@yourcompany.com'.
mailrec-rec_type = 'U'.
append mailrec.
Sending the document
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = maildata
put_in_outbox = ' '
tables
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
endform.
************************************************************************
Form PREPARE_PACKING_LIST
************************************************************************
form prepare_packing_list.
clear: mailpack, mailbin, mailhead.
refresh: mailpack, mailbin, mailhead.
describe table mailtxt lines tab_lines.
read table mailtxt index tab_lines.
maildata-doc_size = ( tab_lines - 1 ) * 255 + strlen( mailtxt ).
Creation of the entry for the compressed document
clear mailpack-transf_bin.
mailpack-head_start = 1.
mailpack-head_num = 0.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'RAW'.
append mailpack.
mailhead = 'TEST.TXT'.
append mailhead.
File 1
mailbin = 'This is file 1'.
append mailbin.
describe table mailbin lines tab_lines.
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'TXT'.
mailpack-obj_name = 'TEST1'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
append mailpack.
endform.
May be you must check the email settings,
http://help.sap.com/saphelp_nw04s/helpdata/en/55/a8b538891b11d2a25a00a0c943858e/content.htm
One more code sample
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-
<b>Reward points</b>
Rregarsd
06-19-2007 12:43 PM
Hi friend .... here is the program for sending the FAX...... we are using it ..
The following program shows you how to send a fax from within ABAP/4. The report is delivered in the standard system and is used in Transaction SCOM for the function "Send test fax".
Only the method via the call of SAPscript with <b>DEVICE='TELEFAX'</b>, described below, ensures thegeneration of a correct transmission request, independent of the R/3 release and of the used fax server solution and its configuration.
The regular printing (for example, with <b>NEW-PAGE PRINT ON...)</b> on an output device created in the spool administration of the device class 'Telefax' does generally not work!
REPORT ZRESD MESSAGE-ID SK.
**********************************************************************
* Test report to send a test fax
* sends a fax to the number <TO_CNTRY>-<TO_NMBER>
* containing an automatically generated message text.
**********************************************************************
TABLES: USR03.
PARAMETERS: TO_CNTRY LIKE T005-LAND1 OBLIGATORY,
TO_NMBER LIKE TSP01-RQTELENUM OBLIGATORY,
FROM_USR(30) TYPE C DEFAULT SY-UNAME,
TO_RECIP(30) TYPE C DEFAULT SY-UNAME.
* SAPscript content ITAB
DATA: BEGIN OF TEST_DOC OCCURS 10.
INCLUDE STRUCTURE TLINE.
DATA: END OF TEST_DOC.
* SAPscript header struct
DATA BEGIN OF HEADER.
INCLUDE STRUCTURE THEAD.
DATA END OF HEADER.
**********************************************************************
INITIALIZATION.
**********************************************************************
* get county from user addres in usr03
* system->user profile->user address
* check if not empty
SELECT SINGLE * FROM USR03 WHERE BNAME = SY-UNAME.
IF SY-SUBRC = 0 AND USR03-LAND1 <> SPACE.
TO_CNTRY = USR03-LAND1.
ENDIF.
**********************************************************************
START-OF-SELECTION.
**********************************************************************
PERFORM FILL_UP_TEST_DOC.
PERFORM SHOW_TEST_DOC.
**********************************************************************
AT PF08.
**********************************************************************
PERFORM SEND_FAX TABLES TEST_DOC USING TO_CNTRY
TO_NMBER.
**********************************************************************
AT SELECTION-SCREEN ON TO_NMBER.
**********************************************************************
PERFORM CHECK_NUMBER USING TO_CNTRY TO_NMBER.
*&---------------------------------------------------------------------*
*& Form CHECK_NUMBER
*&---------------------------------------------------------------------*
FORM CHECK_NUMBER USING
COUNTRY
NUMBER.
DATA: SERVICE LIKE TSKPA-SERVICE VALUE 'TELEFAX',
LEN LIKE SY-FDPOS.
FIELD-SYMBOLS <P>.
* windows GUI push the ? from mandatory input instead
*of overwriting it
LEN = STRLEN( TO_NMBER ).
IF LEN > 1.
SUBTRACT 1 FROM LEN.
ASSIGN TO_NMBER+LEN(1) TO <P>.
IF <P> = '?'.
<P> = SPACE.
ENDIF.
ENDIF.
* official check FM
CALL FUNCTION 'TELECOMMUNICATION_NUMBER_CHECK'
EXPORTING
COUNTRY = COUNTRY
NUMBER = NUMBER
SERVICE = SERVICE.
* on old 21?/22? release you may have to handle the
*exception
* because the Function uses RAISE instead of
*MESSAGE... RAISING....
ENDFORM. " CHECK_NUMBER
*&---------------------------------------------------------------------*
*& Form FILL_UP_TEST_DOC
*&---------------------------------------------------------------------*
* fills test text in itab TEST_DOC *
* real life example needs to get real life data *
*----------------------------------------------------------------------*
FORM FILL_UP_TEST_DOC.
DATA: DATUM(12) TYPE C,
UZEIT(10) TYPE C.
* SAPscript initialization
* of course, you may want to set a few parameter
*(FORM,LAYOUT,....)
CALL FUNCTION 'INIT_TEXT'
EXPORTING
ID = 'ST '
LANGUAGE = SY-LANGU
NAME = 'FOO-BAR'
OBJECT = 'TEXT'
IMPORTING
HEADER = HEADER
TABLES
LINES = TEST_DOC
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC <> 0.
MESSAGE A400 WITH 'INIT_TEXT'.
ENDIF.
PERFORM ADD_EMPTY_LINE.
WRITE: SY-DATUM TO DATUM.
WRITE: SY-UZEIT TO UZEIT.
PERFORM ADD_LINES USING 'This is test Telefax'(001)
DATUM UZEIT.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING 'From: &'(002) FROM_USR SPACE.
PERFORM ADD_LINES USING 'To: &'(003) TO_RECIP SPACE.
PERFORM ADD_LINES USING 'Fax number: & &'(004)
TO_CNTRY TO_NMBER.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING
'This is a test fax send by Report RSKSENDF'(005)
SPACE SPACE.
PERFORM ADD_LINES USING 'on SAP system & '(006)
SY-SYSID SPACE.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING
'the quick brown fox jumps over the lazy dog.'(101)
SPACE space.
PERFORM ADD_LINES USING
'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.'(102)
SPACE space.
PERFORM ADD_EMPTY_LINE.
PERFORM ADD_LINES USING 'End of test'(007) SPACE
SPACE.
ENDFORM. " FILL_UP_TEST_DOC
*&---------------------------------------------------------------------*
*& Form ADD_LINES
*&---------------------------------------------------------------------*
* printf a line an appends it in test_doc *
*----------------------------------------------------------------------*
* --> cformat format.
* --> p1 param1
* --> p2 param2
*----------------------------------------------------------------------*
FORM ADD_LINES USING CFORMAT P1 P2.
TEST_DOC-TDFORMAT = '/'.
TEST_DOC-TDLINE = CFORMAT.
IF TEST_DOC-TDLINE CA '&'.
REPLACE '&' WITH P1 INTO TEST_DOC-TDLINE.
IF TEST_DOC-TDLINE CA '&'.
REPLACE '&' WITH P2 INTO TEST_DOC-TDLINE.
ENDIF.
ENDIF.
APPEND TEST_DOC.
ENDFORM. " ADD_LINES
*&---------------------------------------------------------------------*
*& Form ADD_EMPTY_LINE
*&---------------------------------------------------------------------*
* appends an empty line to test_doc *
*----------------------------------------------------------------------*
FORM ADD_EMPTY_LINE.
TEST_DOC-TDFORMAT = '/'.
CLEAR TEST_DOC-TDLINE.
APPEND TEST_DOC.
ENDFORM. " ADD_EMPTY_LINE
*&---------------------------------------------------------------------*
*& Form SHOW_TEST_DOC
*&---------------------------------------------------------------------*
* lists the test doc for aproval *
* *
*>>>> this is for fun only because PRINT_TEXT also
*offers a preview *
*
*----------------------------------------------------------------------*
FORM SHOW_TEST_DOC.
FORMAT COLOR COL_BACKGROUND INTENSIFIED OFF.
WRITE: / 'Test fax would look like this:'(020).
ULINE.
SKIP.
LOOP AT TEST_DOC.
IF TEST_DOC-TDLINE <> SPACE.
WRITE:/ TEST_DOC-TDLINE.
ELSE.
SKIP.
ENDIF.
ENDLOOP.
SKIP.
ULINE.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE: 'Press PF8 to send it'(021).
ENDFORM. " SHOW_TEST_DOC
*&---------------------------------------------------------------------*
*& Form SEND_FAX
*&---------------------------------------------------------------------*
* send fax by calling SAPscript *
*----------------------------------------------------------------------*
* Note: Instead of using PRINT_TEXT you may also *
* call OPEN_FORM / WRITE_FORM_LINES / CLOSE_FORM, *
* this allows you to use a similar program structure *
* as with NEW-PAGE PRINT ON / WRITE / NEW-PAGE PRINT
*OFF *
*----------------------------------------------------------------------*
FORM SEND_FAX
TABLES DOC2FAX STRUCTURE TEST_DOC
USING COUNTRY
NUMBER.
DATA: SID(5) TYPE N.
DATA BEGIN OF POPT.
INCLUDE STRUCTURE ITCPO.
DATA END OF POPT.
DATA BEGIN OF PRES.
INCLUDE STRUCTURE ITCPP.
DATA END OF PRES.
CLEAR POPT.
POPT-TDCOPIES = 1. " one copy
* POPT-TDDEST = " done internaly by script,
* POPT-TDPRINTER = " do not fill !!!
POPT-TDNEWID = 'X'. " do not reuse old spool request
POPT-TDDATASET = 'TEST'(022). " fill as you want
POPT-TDSUFFIX1 = 'FAX'(023). " fill as you want
POPT-TDSUFFIX2 = SY-UNAME. " fill as you want
POPT-TDIMMED = 'X'. " send now
POPT-TDLIFETIME = 8. " keep 8 days in spool
POPT-TDTELENUM = NUMBER. " number without country code
POPT-TDTELELAND = COUNTRY. " country of recipient
POPT-TDCOVER = 'test fax'(024).
POPT-TDCOVTITLE = 'test fax'(024).
* POPT-TDIEXIT = 'X'.
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX = ' '
ARCHIVE_PARAMS = ' '
DEVICE = 'TELEFAX' "<<< here we say: fax it !
DIALOG = 'X'
HEADER = HEADER
OPTIONS = POPT
IMPORTING
RESULT = PRES
TABLES
LINES = DOC2FAX
EXCEPTIONS
OTHERS = 01.
* do not bother with exception in sample code
* CANCELED = 01
* DEVICE = 02
* FORM = 03
* OPTIONS = 04
* UNCLOSED = 05
* UNKNOWN = 06
* FORMAT = 07
* TEXTFORMAT = 08
* EXTERNAL = 09.
IF SY-SUBRC = 0.
* arriving here means we could send:
SID = PRES-TDSPOOLID.
IF SID > '00000'.
MESSAGE S433 WITH SID.
ENDIF.
LEAVE .
ELSE.
* do not bother with exception in sample code
MESSAGE A400 WITH 'PRIN_TEXT'.
ENDIF.
ENDFORM. " SEND_FAX
reward points if it is usefull ...
Girish
07-16-2007 12:43 PM
Hi ,
Using the program for FAX , the FAX request sits in the Outbox , it doesnt trigger the FAX . Is there any other configuration to be carried out .
I am just providing the FAX number of the FAX machine located in my office with country code and all.
thanks,
abhi