Foro -Documentación -Código fuente -Contacto -Empleo

Buscar

Traducir

Amazon

ZSENDFAX PDF Imprimir E-mail
Usar puntuación: / 0
MaloBueno 
Código fuente - Ejemplos
Sábado, 28 de Febrero de 2004 00:59
Ejemplo de cómo enviar un fax

REPORT rsksendf 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. "Datos de dirección del usuario

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

Comentarios
Buscar
¡Sólo los usuarios registrados pueden escribir comentarios!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
home search