Skip to Content
avatar image
Former Member

Creating a PDF attachment and send it via Email

Hi,

I have following problem.

I want to send a Purchase Order via Mail to email inbox.

I already read in the forum that I should use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

Could anyone please provide me with some information about that. So how can I insert my PO into this function module (PO-Document is based on smartform and not stored in the database as a pdf-file so far) - so do I need to use another FM first to create a PDF file or how is it working?

Thanks for your help,

Christoph

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 08, 2008 at 07:28 AM

    first u write Internal table to spool then u can convert the spool to pdf....see the below code.. hope it helps...

    1. Convert the spool to PDF.

    DATA: BEGIN OF i_mara OCCURS 0,
    matnr LIKE mara-matnr.
    DATA: END OF i_mara.
    
    DATA: v_dest LIKE tsp01-rqdest,
    v_handle LIKE sy-tabix,
    v_spool_id LIKE tsp01-rqident,
    v_rc TYPE c,
    v_errmessage(100) TYPE c,
    v_text(70) TYPE c.
    
    START-OF-SELECTION.
    
    SELECT matnr FROM mara INTO TABLE i_mara.
    
    CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
    EXPORTING
    dest = 'LOCL'
    * LAYOUT =
    * NAME =
    * SUFFIX1 =
    * SUFFIX2 =
    * COPIES =
    * PRIO =
    * IMMEDIATE_PRINT =
    * AUTO_DELETE =
    * TITLELINE =
    * RECEIVER =
    * DIVISION =
    * AUTHORITY =
    * POSNAME =
    * ACTTIME =
    * LIFETIME = '8'
    * APPEND =
    * COVERPAGE =
    * CODEPAGE =
    * DOCTYPE =
    IMPORTING
    handle = v_handle
    spoolid = gd_spool_nr
    rc = v_rc
    errmessage = v_errmessage.
    
    LOOP AT i_mara.
    v_text = i_mara-matnr.
    CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
    EXPORTING
    handle = v_handle
    text = v_text
    * LENGTH =
    * CODEPAGE =
    * TRUNCATE =
    IMPORTING
    rc = v_rc
    errmessage = v_errmessage
    EXCEPTIONS
    handle_not_valid = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    ENDLOOP.
    
    CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
    EXPORTING
    handle = v_handle
    IMPORTING
    rc = v_rc
    errmessage = v_errmessage
    EXCEPTIONS
    handle_not_valid = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = gd_spool_nr
    no_dialog = c_no
    dst_device = c_device
    IMPORTING
    pdf_bytecount = gd_bytecount
    TABLES
    pdf = it_pdf_output
    EXCEPTIONS
    err_no_abap_spooljob = 1
    err_no_spooljob = 2
    err_no_permission = 3
    err_conv_not_possible = 4
    err_bad_destdevice = 5
    user_cancelled = 6
    err_spoolerror = 7
    err_temseerror = 8
    err_btcjob_open_failed = 9
    err_btcjob_submit_failed = 10
    err_btcjob_close_failed = 11
    OTHERS = 12.
    CHECK sy-subrc = 0.
    

    2. Get the spool Id

    
    get the spool number
    * Declaration of local variables.
    DATA:
    LV_RQ2NAME LIKE TSP01-RQ2NAME.
     
    CONCATENATE SY-REPID+0(8)
    SY-UNAME+0(3)
    INTO LV_RQ2NAME SEPARATED BY '_'.
    * Get the spool number.
    SELECT * FROM TSP01 WHERE RQ2NAME = LV_RQ2NAME
    ORDER BY RQCRETIME DESCENDING.
    V_RQIDENT = TSP01-RQIDENT.
    EXIT.
    ENDSELECT.
    IF SY-SUBRC NE 0.
    CLEAR V_RQIDENT.
    ENDIF
    
    

    2. Now sent mail with attachment :

    
    REPORT Z34332_MAIL_WITH_ATTACHMENT1.
    
    types: begin of t_mara,
    matnr type mara-matnr,
    matkl type mara-matkl,
    mtart type mara-mtart,
    meins type mara-meins,
    end of t_mara.
    
    
    data: gt_mara type table of t_mara,
    wa_mara like line of gt_mara,
    it_packing_list type table of SOPCKLSTI1,
    wa_packing_list like line of it_packing_list,
    it_receivers type table of SOMLRECI1,
    wa_receivers like line of it_receivers,
    it_mailbody type table of SOLISTI1,
    wa_mailbody like line of it_mailbody,
    it_attachment type table of SOLISTI1,
    wa_attachment like line of it_attachment.
    
    data: la_doc type SODOCCHGI1.
    
    constants:
    con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    con_cret type c value cl_abap_char_utilities=>CR_LF.
    
    * get material
    select matnr matkl mtart meins
    into table gt_mara
    from mara
    up to 25 rows.
    
    
    * Populate the subject/generic message attributes
    la_doc-obj_langu = sy-langu.
    la_doc-obj_descr = 'Material Details' . "Mail Header
    la_doc-sensitivty = 'F'.
    la_doc-doc_size = 1.
    
    * Add the recipients email address
    CLEAR wa_receivers.
    REFRESH it_receivers.
    wa_receivers-receiver = 'PCSDEVL'.
    wa_receivers-rec_type = 'U'.
    wa_receivers-com_type = 'INT'.
    wa_receivers-notif_del = 'X'.
    wa_receivers-notif_ndel = 'X'.
    APPEND wa_receivers to it_receivers.
    
    * Mail Body
    CLEAR wa_mailbody.
    REFRESH it_mailbody.
    wa_mailbody-line = 'Please find the attachment'.
    APPEND wa_mailbody to it_mailbody.
    
    * Mail attachmwnt
    CLEAR wa_attachment.
    REFRESH it_attachment.
    
    CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
    INTO wa_attachment SEPARATED BY con_tab.
    CONCATENATE con_cret wa_attachment INTO wa_attachment.
    APPEND wa_attachment to it_attachment.
    
    LOOP AT gt_mara INTO wa_mara.
    CONCATENATE wa_mara-matnr wa_mara-matkl
    wa_mara-mtart wa_mara-meins
    INTO wa_attachment SEPARATED BY con_tab.
    CONCATENATE con_cret wa_attachment INTO wa_attachment.
    APPEND wa_attachment to it_attachment.
    ENDLOOP.
    
    
    * Describe the body of the message
    CLEAR wa_packing_list.
    REFRESH it_packing_list.
    wa_packing_list-transf_bin = space.
    wa_packing_list-head_start = 1.
    wa_packing_list-head_num = 0.
    wa_packing_list-body_start = 1.
    wa_packing_list-body_num = 1.
    wa_packing_list-doc_type = 'RAW'.
    APPEND wa_packing_list to it_packing_list.
    
    * Create attachment notification
    wa_packing_list-transf_bin = 'X'.
    wa_packing_list-head_start = 1.
    wa_packing_list-head_num = 1.
    wa_packing_list-body_start = 1.
    
    DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
    wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
    wa_packing_list-obj_descr = ' '.
    concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
    separated by space.
    wa_packing_list-doc_size = wa_packing_list-body_num * 255.
    APPEND wa_packing_list to it_packing_list.
    
    
    
    
    
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
    document_data = la_doc
    PUT_IN_OUTBOX = 'X'
    * SENDER_ADDRESS = SY-UNAME
    * SENDER_ADDRESS_TYPE = 'B'
    COMMIT_WORK = 'X'
    * IMPORTING
    * SENT_TO_ALL =
    * NEW_OBJECT_ID =
    * SENDER_ID =
    tables
    packing_list = it_packing_list
    * OBJECT_HEADER =
    CONTENTS_BIN = it_attachment
    CONTENTS_TXT = it_mailbody
    * CONTENTS_HEX =
    * OBJECT_PARA =
    * OBJECT_PARB =
    receivers = it_receivers
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8
    .
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    
    

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 08, 2008 at 07:32 AM

    this code will help you

    &----


    *& Report YSMARTFORM_EMAIL

    *&

    &----


    *&

    *&

    &----


    REPORT YSMARTFORM_EMAIL.

    TABLES: VBAK.

    ************************************************************************

    • Constants *

    ************************************************************************

    CONSTANTS:

    C_X TYPE C VALUE 'X', " Value X

    C_0 TYPE C VALUE '0', " Value 0

    C_1 TYPE C VALUE '1'. " Value 1

    ************************************************************************

    • Work Variables declaration *

    ************************************************************************

    DATA:

    W_UCOMM LIKE SY-UCOMM, " Function code

    W_TABLN TYPE I, " Lines

    W_LINE TYPE SO_TEXT255, " Line of text

    W_EADDR(60) TYPE C. " FieldLength for Email

    DATA: VBAP_TAB LIKE VBAP OCCURS 0 WITH HEADER LINE.

    DATA: W_FUNMOD TYPE RS38L_FNAM.

    • Structure to hold the Attributes of new Document

    DATA: FS_DOCDATA TYPE SODOCCHGI1.

    • Internal table for storing OTF data form Smart-Form

    DATA: BEGIN OF FS_OTF_DATA.

    INCLUDE STRUCTURE ITCOO.

    DATA: END OF FS_OTF_DATA,

    T_OTF_DATA LIKE STANDARD TABLE OF FS_OTF_DATA.

    • Internal table for storing PDF data form Smart-Form

    DATA: BEGIN OF FS_PDF_DATA.

    INCLUDE STRUCTURE TLINE.

    DATA: END OF FS_PDF_DATA,

    T_PDF_DATA LIKE STANDARD TABLE OF FS_PDF_DATA.

    • Internal table to hold the attachment data text of the email

    DATA: BEGIN OF FS_ATTACH_DATA.

    INCLUDE STRUCTURE SOLISTI1.

    DATA: END OF FS_ATTACH_DATA,

    T_ATTACH_DATA LIKE STANDARD TABLE OF FS_ATTACH_DATA.

    • Internal table to hold Message body of the email

    DATA: BEGIN OF FS_MESSBODY.

    INCLUDE STRUCTURE SOLISTI1.

    DATA: END OF FS_MESSBODY,

    T_MESSBODY LIKE STANDARD TABLE OF FS_MESSBODY.

    • Internal table for packing list for main document

    DATA: BEGIN OF FS_OBJPACK.

    INCLUDE STRUCTURE SOPCKLSTI1.

    DATA: END OF FS_OBJPACK,

    T_OBJPACK LIKE STANDARD TABLE OF FS_OBJPACK.

    • Internal table for header text of the attachment

    DATA: BEGIN OF FS_OBJHEAD.

    INCLUDE STRUCTURE SOLISTI1.

    DATA: END OF FS_OBJHEAD,

    T_OBJHEAD LIKE STANDARD TABLE OF FS_OBJHEAD.

    • Internal table receiver information

    DATA: BEGIN OF FS_RECEIVER.

    INCLUDE STRUCTURE SOMLRECI1.

    DATA: END OF FS_RECEIVER,

    T_RECEIVER LIKE STANDARD TABLE OF FS_RECEIVER.

    *Internal table to store data upto 255 lines

    DATA: BEGIN OF FS_OBJCONT.

    INCLUDE STRUCTURE SOLI.

    DATA: END OF FS_OBJCONT,

    T_OBJCONT LIKE STANDARD TABLE OF FS_OBJCONT.

    *DATA : P_VBELN LIKE VBAK-VBELN.

    DATA: P_EADDR(60) TYPE C

    VALUE 'SUVARCHALA.CHINTALAPUDI@YASH.COM'.

    PARAMETERS : P_VBELN LIKE VBAK-VBELN.

    *PARAMETERS:

    • P_EADDR(60) TYPE C. " Email address

    SELECT SINGLE *

    FROM VBAK

    WHERE VBELN EQ P_VBELN.

    SELECT *

    FROM VBAP

    INTO TABLE VBAP_TAB

    WHERE VBELN EQ P_VBELN.

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    FORMNAME = 'YSMARTFORM_EMAIL'

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    IMPORTING

    FM_NAME = W_FUNMOD

    EXCEPTIONS

    NO_FORM = 1

    NO_FUNCTION_MODULE = 2

    OTHERS = 3 .

    IF SY-SUBRC <> 0.

    • Do nothing

    ENDIF.

    DATA: FS_CONT_PARM TYPE SSFCTRLOP,

    T_JOB_INFO TYPE SSFCRESCL.

    CLEAR FS_CONT_PARM.

    FS_CONT_PARM-GETOTF = 'X'.

    FS_CONT_PARM-NO_DIALOG = 'X'.

    FS_CONT_PARM-PREVIEW = ''.

    CALL FUNCTION W_FUNMOD

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    CONTROL_PARAMETERS = FS_CONT_PARM

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    • OUTPUT_OPTIONS =

    • USER_SETTINGS = 'X'

    VBAK = VBAK

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    JOB_OUTPUT_INFO = T_JOB_INFO

    • JOB_OUTPUT_OPTIONS =

    TABLES

    VBAP = VBAP_TAB

    EXCEPTIONS

    FORMATTING_ERROR = 1

    INTERNAL_ERROR = 2

    SEND_ERROR = 3

    USER_CANCELED = 4

    OTHERS = 5 .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    PERFORM CONVERT_OTF_TO_PDF.

    &----


    *& Form convert_otf_to_pdf

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM CONVERT_OTF_TO_PDF .

    DATA: LV_BYTES TYPE P.

    IF FS_CONT_PARM-GETOTF EQ 'X'.

    REFRESH T_OTF_DATA.

    CLEAR FS_OTF_DATA.

    LOOP AT T_JOB_INFO-OTFDATA INTO FS_OTF_DATA.

    APPEND FS_OTF_DATA TO T_OTF_DATA.

    CLEAR FS_OTF_DATA.

    ENDLOOP. " LOOP AT t_outtab-otfdata

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    FORMAT = 'PDF'

    MAX_LINEWIDTH = 255

    IMPORTING

    BIN_FILESIZE = LV_BYTES

    TABLES

    OTF = T_OTF_DATA

    LINES = T_PDF_DATA

    EXCEPTIONS

    ERR_MAX_LINEWIDTH = 1

    ERR_FORMAT = 2

    ERR_CONV_NOT_POSSIBLE = 3

    OTHERS = 4.

    IF SY-SUBRC EQ 0 AND LV_BYTES IS NOT INITIAL.

    PERFORM TABLE_SHIFT.

    • To send the output by email

    PERFORM SET_UP_EMAIL.

    PERFORM SEND_MAIL.

    ENDIF. " IF sy-subrc EQ space.

    ENDIF. " IF gs_control_pars-getotf

    ENDFORM. " convert_otf_to_pdf

    ----


    • Form set_up_email *

    ----


    • This subroutine is used to set mail attributes *

    ----


    • There are no interface parameters to be passed to this subroutine. *

    ----


    FORM SET_UP_EMAIL .

    • To setup attributes of the document

    PERFORM SET_EMAIL_HEADER.

    • To set body of email

    PERFORM SET_EMAILBODY.

    • To convert output table data with tab delimiter

    PERFORM PREPARE_OUTPUT_DATA_FOR_ATTACH.

    • To set the Receipents

    PERFORM SET_RECEIPENTS.

    ENDFORM. " Set_up_email

    ----


    • Form set_email_header *

    ----


    • This subroutine is used to Setup the attributes of the Document *

    ----


    • There are no interface parameters to be passed to this subroutine. *

    ----


    FORM SET_EMAIL_HEADER.

    CONSTANTS :

    LC_P TYPE C VALUE 'P', " Production system name

    LC_F TYPE C VALUE 'F', " Sensitivity

    LC_OBJNAME(6) TYPE C " Object name

    VALUE 'SAPRPT'.

    CLEAR FS_DOCDATA.

    • Populate the subject/generic message attributes

    FS_DOCDATA-DOC_SIZE = 1.

    FS_DOCDATA-OBJ_LANGU = SY-LANGU.

    FS_DOCDATA-OBJ_NAME = LC_OBJNAME.

    FS_DOCDATA-SENSITIVTY = LC_F.

    IF SY-SYSID+0(1) NE LC_P.

    CONCATENATE 'Test mail'(003)

    'Sales Order Details'(002)

    INTO FS_DOCDATA-OBJ_DESCR

    SEPARATED BY SPACE.

    ELSE.

    MOVE TEXT-002 TO FS_DOCDATA-OBJ_DESCR.

    ENDIF. " IF sy-sysid+0(1)...

    ENDFORM. " Set_email_header

    ----


    • Form set_emailbody *

    ----


    • This subroutine is used to set body of an email *

    ----


    • There are no interface parameters to be passed to this subroutine. *

    ----


    FORM SET_EMAILBODY.

    CONSTANTS:

    LC_DOC_TYPE(3) TYPE C VALUE 'RAW'. " Document type

    REFRESH : T_OBJPACK,

    T_MESSBODY.

    CLEAR : FS_OBJPACK,

    FS_MESSBODY.

    MOVE:

    'Hi,'(004) TO FS_MESSBODY-LINE.

    APPEND FS_MESSBODY TO T_MESSBODY.

    CLEAR FS_MESSBODY.

    MOVE:

    • 'The attachment contains sales order details.'(005)

    'www.google.com'

    TO FS_MESSBODY-LINE.

    APPEND FS_MESSBODY TO T_MESSBODY.

    CLEAR W_TABLN.

    DESCRIBE TABLE T_MESSBODY LINES W_TABLN.

    CLEAR FS_MESSBODY.

    READ TABLE T_MESSBODY INTO FS_MESSBODY INDEX W_TABLN.

    FS_DOCDATA-DOC_SIZE = ( W_TABLN - 1 ) * 255 + STRLEN( W_LINE ).

    MOVE:

    SPACE TO FS_OBJPACK-TRANSF_BIN,

    C_1 TO FS_OBJPACK-HEAD_START,

    C_0 TO FS_OBJPACK-HEAD_NUM,

    C_1 TO FS_OBJPACK-BODY_START,

    W_TABLN TO FS_OBJPACK-BODY_NUM,

    LC_DOC_TYPE TO FS_OBJPACK-DOC_TYPE.

    APPEND FS_OBJPACK TO T_OBJPACK.

    ENDFORM. " Set_emailbody

    ----


    • Form prepare_output_data_for_attach *

    ----


    • To convert the output table data with comma delimiter *

    ----


    • There are no interface parameters to be passed to this subroutine. *

    ----


    FORM PREPARE_OUTPUT_DATA_FOR_ATTACH.

    CONSTANTS:

    LC_DOC_TYPE(3) TYPE C VALUE 'PDF', " Document type

    LC_OBJNAME(6) TYPE C VALUE 'SAPRPT'. " Object name

    REFRESH T_OBJHEAD.

    REFRESH T_ATTACH_DATA[].

    CLEAR FS_ATTACH_DATA.

    T_ATTACH_DATA[] = T_OBJCONT[].

    DESCRIBE TABLE T_ATTACH_DATA LINES W_TABLN.

    FS_DOCDATA-DOC_SIZE = ( W_TABLN - 1 ) * 255 + STRLEN( W_LINE ).

    FS_OBJPACK-BODY_NUM = W_TABLN.

    FS_OBJPACK-DOC_SIZE = W_TABLN * 255.

    FS_OBJPACK-TRANSF_BIN = C_X.

    FS_OBJPACK-HEAD_START = C_1.

    FS_OBJPACK-HEAD_NUM = C_1.

    FS_OBJPACK-BODY_START = C_1.

    FS_OBJPACK-DOC_TYPE = LC_DOC_TYPE.

    FS_OBJPACK-OBJ_NAME = 'Attachment'.

    FS_OBJPACK-OBJ_DESCR = 'Sales Order Details.PDF'(007).

    APPEND FS_OBJPACK TO T_OBJPACK.

    ENDFORM. " Prepare_output_data_for_attach

    ----


    • Form set_receipents *

    ----


    • This subroutine is used to set the Receipents *

    ----


    • There are no interface parameters to be passed to this subroutine. *

    ----


    FORM SET_RECEIPENTS .

    CONSTANTS

    LC_REC_TYPE TYPE C VALUE 'U'. " Receipent type

    REFRESH T_RECEIVER.

    IF P_EADDR IS NOT INITIAL.

    MOVE:

    P_EADDR TO FS_RECEIVER-RECEIVER,

    LC_REC_TYPE TO FS_RECEIVER-REC_TYPE.

    APPEND FS_RECEIVER TO T_RECEIVER.

    ENDIF. " IF P_EMAIL IS NOT.....

    ENDFORM. " Set_receipents

    ----


    • Form send_mail *

    ----


    • This subroutine is used to send output by email *

    ----


    • There are no interface parameters to be passed to this subroutine. *

    ----


    FORM SEND_MAIL.

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = FS_DOCDATA

    PUT_IN_OUTBOX = C_X

    • SENDER_ADDRESS = SY-UNAME

    • SENDER_ADDRESS_TYPE = 'B'

    COMMIT_WORK = C_X

    TABLES

    PACKING_LIST = T_OBJPACK

    OBJECT_HEADER = T_OBJHEAD

    CONTENTS_BIN = T_ATTACH_DATA

    CONTENTS_TXT = T_MESSBODY

    RECEIVERS = T_RECEIVER

    EXCEPTIONS

    TOO_MANY_RECEIVERS = 1

    DOCUMENT_NOT_SENT = 2

    DOCUMENT_TYPE_NOT_EXIST = 3

    OPERATION_NO_AUTHORIZATION = 4

    PARAMETER_ERROR = 5

    X_ERROR = 6

    ENQUEUE_ERROR = 7

    OTHERS = 8.

    IF SY-SUBRC NE 0.

    MESSAGE I007(CLAIM).

    ELSE.

    MESSAGE S592(EI).

    ENDIF. " IF sy-subrc NE 0.

    ENDFORM. " Send_mail

    &----


    *& Form table_shift

    &----


    • The PDF file that is generated out of the above function module

    • cannot be transported as it needs to be of 255 chars.Hence

    • converting the file to get a 255 char single line,internal table.

    ----


    *There are no interface parameters to be passed to this subroutine

    ----


    FORM TABLE_SHIFT .

    CONSTANTS:

    CNV_HEXCONST_ZERO TYPE X VALUE '00'.

    DATA:

    LV_BIG_LINES(268) TYPE C

    OCCURS 0 WITH HEADER LINE.

    DATA:

    LFL_FLAG TYPE C,

    LV_LEFT_T(268) TYPE C,

    LV_LEFT_I TYPE I,

    TV_LEFT_I TYPE I,

    LV_CURR_I TYPE I.

    FIELD-SYMBOLS: <F>.

    • Get the lines into a table of 268 char as the first step to put it in

    • the pdf file of 255 chars

    CLEAR LFL_FLAG.

    LOOP AT T_PDF_DATA INTO FS_PDF_DATA.

    IF LFL_FLAG EQ ' '.

    CLEAR LV_BIG_LINES WITH CNV_HEXCONST_ZERO.

    ASSIGN LV_BIG_LINES(134) TO <F>.

    <F> = FS_PDF_DATA.

    LFL_FLAG = 'X'.

    ELSE.

    LV_BIG_LINES+134 = FS_PDF_DATA.

    APPEND LV_BIG_LINES.

    CLEAR: LFL_FLAG.

    ENDIF. " If lfl_flag = ''..

    ENDLOOP. " Loop at t_pdf

    IF LFL_FLAG EQ 'X'.

    APPEND LV_BIG_LINES.

    ENDIF. " If lflf_flag eq 'X'..

    • Next fill it into a 255 char table

    CLEAR: LV_LEFT_T, LV_LEFT_I, TV_LEFT_I.

    LV_CURR_I = 255.

    LOOP AT LV_BIG_LINES.

    IF LV_LEFT_I NE 0.

    IF LV_CURR_I NE 0.

    FS_OBJCONT(LV_LEFT_I) = LV_LEFT_T(LV_LEFT_I).

    FS_OBJCONT+LV_LEFT_I(LV_CURR_I) = LV_BIG_LINES(LV_CURR_I).

    ELSE.

    FS_OBJCONT = LV_LEFT_T(LV_LEFT_I).

    ENDIF. " IF lv_curr_i NE 0

    ELSE.

    FS_OBJCONT = LV_BIG_LINES(LV_CURR_I).

    ENDIF. " IF lv_left_i NE 0

    APPEND FS_OBJCONT TO T_OBJCONT.

    TV_LEFT_I = 268 - LV_CURR_I.

    IF TV_LEFT_I > 255.

    FS_OBJCONT = LV_BIG_LINES+LV_CURR_I(255).

    APPEND FS_OBJCONT TO T_OBJCONT.

    LV_LEFT_I = TV_LEFT_I - 255.

    TV_LEFT_I = 255 + LV_CURR_I.

    LV_CURR_I = 255 - LV_LEFT_I.

    LV_LEFT_T = LV_BIG_LINES+TV_LEFT_I.

    ELSE.

    LV_LEFT_T = LV_BIG_LINES+LV_CURR_I.

    LV_LEFT_I = 268 - LV_CURR_I.

    LV_CURR_I = 255 - LV_LEFT_I.

    ENDIF. " IF tv_left_i > 255

    ENDLOOP. " LOOP AT lv_big_lines.

    CLEAR FS_OBJCONT WITH CNV_HEXCONST_ZERO.

    ASSIGN FS_OBJCONT(LV_LEFT_I) TO <F>.

    <F> = LV_LEFT_T(LV_LEFT_I).

    APPEND FS_OBJCONT TO T_OBJCONT.

    ENDFORM. " Table_shift

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      thanks for your answers, I took a look at the codes, very helpful.

      Thanks,

      Christoph

      Edited by: Christoph on Feb 8, 2008 11:19 AM