Writing ABAP Processing Program for InterFAX Mail-to-Fax

To enable mail-to-fax from the SAP SD or MM module, a SAP developer must create an ABAP processing program that does the following: (1) converts the SAP OTF document to PDF – this Sapscript code generates the PDF, (2) attaches the PDF to an email, (3) inserts the recipient's fax number, in a special email format, into the To field of the email, (4) inserts text into the body of the email (this text is used as the cover letter of the fax), and (5) delivers the email to the outgoing queue.

A few important points:

  • The program can either be based on an existing processing program used for regular printing (this will be referred to as the printing program), or it can be written from scratch.
  • The mail-to-fax processing program must be specified as the processing program of the special mail-to-fax output type, which is defined in the SD or MM module (see Defining Output Type and Fax Numbers in SD or MM Module).
  • You can create a processing program for InterFAX mail-to-fax whether your form is based on Sapscript or on Smart Forms.

To create a processing program for InterFAX mail-to-fax:

  1. Do one of the following:
    • If you have a Sapscript form, and you are writing the processing program from scratch, use our Sapscript program example as a basis. Proceed to step 5.
    • If you have a Sapscript form, and you are modifying the existing printing program, proceed to the next step.
    • If you are using Smart Forms, it is recommended to write the processing program from scratch, based on our Smart Forms program example. Proceed to step 5.
  2. In the existing Smartscript printing program, immediately below the line
    FORM form_close
    add the following code:

     DATA : BEGIN OF lt_otf OCCURS 0.
    
          INCLUDE STRUCTURE itcoo.
          DATA : END OF lt_otf.
          DATA : BEGIN OF lt_doctab OCCURS 0.
          INCLUDE STRUCTURE docs.
          DATA : END OF lt_doctab.
          DATA : BEGIN OF lt_pdfdata OCCURS 0.
    
          INCLUDE STRUCTURE tline.
          DATA : END OF lt_pdfdata.
          DATA : v_bin. 
  3. In the existing Smartscript printing program, immediately above the line

    ENDFORM. "Form_CLOSE

    add the following code:

     IF sy-subrc = 0.
    
          IF nast-kschl EQ 'ZARM'. " = Output type for Email/Efax 
          PERFORM mail_object TABLES lt_otf.
          ENDIF.
          ENDIF.
          
  4. In the existing Smartscript printing program, immediately below the line

    ENDFORM. "Form_CLOSE

    add the InterFAX Form Mail Object – Sapscript code used to generate the PDF.

  5. In your ABAP code, look for the comments EMAIL BODY TEXT STARTS HERE and EMAIL BODY TEXT ENDS HERE. The code between these two comments defines the body of the email that will be sent to the InterFAX server. InterFAX uses this email to send a fax to the recipient: the body text of the email (if any) becomes the cover letter (the first page) of the fax, while the attachment to the email (a PDF in this case) becomes the rest of the fax. Check with the SD or MM user whether they need a cover sheet in their faxes, and do one of the following:
    • If the SD or MM user does not want a cover sheet, erase the code between these two comments.
    • If the SD or MM user wants a cover sheet, ask them to provide text for the cover sheet. In the code between the two comments, replace the sample text ("We received your order", etc.) with the user's required text.
    • If the SD or MM user wants a cover sheet, and has a specific layout for the cover sheet, you can implement this layout in HTML. The following code sample shows how to insert HTML tags into the email generated by the program:
      
      it_mailtxt= ''.
      append it_mailtxt.
      it_mailtxt = ''.
      append it_mailtxt.
      it_mailtxt = 'Untitled
      Document'.
      append it_mailtxt.
      it_mailtxt = ''.
      append it_mailtxt.
      it_mailtxt = ''.
      append it_mailtxt.
      it_mailtxt = ''.
      append it_mailtxt.
      it_mailtxt = '
      THIS'. append it_mailtxt. it_mailtxt = ' IS A TEST '. append it_mailtxt. it_mailtxt = '
      '. append it_mailtxt. it_mailtxt = ''. append it_mailtxt. it_mailtxt = ''. append it_mailtxt.
  6. In the output type you are working on, the SAP documents will be sent as emails. If there is a chance that some of the emails will be received by an actual person (not by the InterFAX server), it is important to define the email subject. Ask the SD or MM user which text they would prefer in the email subject. The subject is defined in a line starting with CONCATENATE, towards the end of the InterFAX form object. Replace Email to InterFAX with the required email subject text.

Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today