Skip to Content
author's profile photo Former Member
Former Member

Attaching files from the Application Server to Business documents

Hi Experts,

I need to attach files from the Application Server to Business documents like (PO Invoice, Sales Order etc.)

Here my requirement is as fallows.

1) I am getting the Invoice from the Vendor in the form of IDOC also they will place the image of that invoice in FTP Server with the their invoice number say 12345.tif

2) I am creating an Invoice in SAP with the Idoc data

4) Once i create/Park the Invoice

3) I transferring the 12345.tif from FTP server to application server by using the FTP Function modules.

4) Now i have to attach this image to created Invoice in SAP.

Please let me know if any one knows about this.

I would be greatly appreciated with your help in this regard.

Thanks in advance.

Regards,

Venkat

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2008 at 01:26 PM

    Hi Venkat!!

    I am uploading into BW Docs after reading the files from application server . Check it so as to get some idea.

    REPORT ZMAST_BWDOC_IMPORT.

    • TEXT ELEMENTS

    • 001 Error reading file/directory

    • 002 Error uploading file

    • 003 Successfully Loaded

    DATA: l_s_chavl TYPE rsod_s_chanm_chavl.

    DATA: l_t_chavl TYPE TABLE OF rsod_s_chanm_chavl.

    DATA: l_s_excpt(5) TYPE c.

    DATA: l_t_data_tab_asc TYPE sdokcntascs.

    DATA: l_t_data_tab_bin TYPE sdokcntbins.

    DATA: rc TYPE sy-subrc.

    DATA: wa_dir(100). " like file_info.

    DATA: day(2) TYPE c.

    DATA: l_s_content_info TYPE rsod_s_content_info.

    DATA: dir_tab TYPE STANDARD TABLE OF file_info.

    DATA: dir_entry(100).

    *DATA: p_path(40) type C .

    DATA: l_s_peri LIKE t009b-poper.

    DATA: l_s_per(2) TYPE c.

    TYPES: BEGIN OF fileinfostruc,

    zcustomer(18),

    END OF fileinfostruc.

    TYPES: date TYPE sy-datum.

    DATA: l_s_year LIKE t009b-bdatj.

    DATA: fileinfo TYPE fileinfostruc.

    DATA: date TYPE date.

    DATA: count TYPE i.

    DATA: len TYPE i.

    DATA: offset TYPE i.

    DATA: id TYPE i.

    DATA: filename TYPE string.

    DATA: thema TYPE string.

    DATA: pfad TYPE c.

    DATA: dir TYPE string.

    DATA: descr TYPE sdok_descr.

    DATA: name TYPE skwf_urlp.

    DATA: l_t_return TYPE bapiret2.

    DATA: l_filelength TYPE i.

    DATA: file_tab TYPE filetable,

    single_file TYPE filetable.

    DATA: file_line LIKE LINE OF file_tab.

    DATA: ls_path TYPE string.

    INTERFACE IF_RSOD_CONST LOAD.

    PARAMETER p_path(40) OBLIGATORY DEFAULT 'C:\'.

    • Display file selection dialog

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

    PERFORM get_files.

    START-OF-SELECTION.

    PERFORM section_main.

    &----


    *& Form get_files

    &----


    • text

    -


    FORM get_files.

    dir = p_path.

    DATA: folder TYPE string.

    CALL METHOD cl_gui_frontend_services=>directory_browse

    EXPORTING

    • WINDOW_TITLE =

    initial_folder = 'C:\'

    CHANGING

    selected_folder = folder.

    • EXCEPTION

    • CNTL_ERROR = 1

    • ERROR_NO_GUI = 2

    • NOT_SUPPORTED_BY_GUI = 3

    • others = 4

    IF sy-subrc 0.

    • add your error message here

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

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

    ENDIF.

    p_path = folder.

    *fetch all files from directory, use *.doc as mask

    CALL METHOD cl_gui_frontend_services=>directory_list_files

    EXPORTING

    directory = folder

    filter = '*.doc'

    files_only = 'X'

    • DIRECTORIES_ONLY =

    CHANGING

    file_table = dir_tab

    count = count

    EXCEPTIONS

    cntl_error = 1

    directory_list_files_failed = 2

    wrong_parameter = 3

    error_no_gui = 4

    not_supported_by_gui = 5

    OTHERS = 6.

    ENDFORM. "get_files

    &----


    *& Form section_main

    &----


    • text

    -


    FORM section_main.

    LOOP AT dir_tab INTO dir_entry.

    • Build filename

    TRANSLATE dir_entry TO UPPER CASE.

    CLEAR: filename.

    CONCATENATE p_path '\' dir_entry INTO filename.

    • call upload

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = filename

    filetype = 'BIN'

    • HAS_FIELD_SEPARATOR = ' '

    • HEADER_LENGTH = 0

    • READ_BY_LINE = 'X'

    • DAT_MODE = ' '

    IMPORTING

    filelength = l_filelength

    TABLES

    data_tab = l_t_data_tab_bin

    EXCEPTIONS

    file_open_error = 1

    file_read_error = 2

    no_batch = 3

    gui_refuse_filetransfer = 4

    invalid_type = 5

    no_authority = 6

    unknown_error = 7

    bad_data_format = 8

    header_not_allowed = 9

    separator_not_allowed = 10

    header_too_long = 11

    unknown_dp_error = 12

    access_denied = 13

    dp_out_of_memory = 14

    disk_full = 15

    dp_timeout = 16

    OTHERS = 17.

    IF sy-subrc 0.

    WRITE: / text-002, sy-subrc, dir_entry. "Error in uploading File

    EXIT.

    ENDIF.

    • fill assignments for Customer

    len = strlen( dir_entry ) - 4.

    REFRESH l_t_chavl.

    l_s_chavl-chanm = 'ZCUSTOMER'.

    l_s_chavl-chavl = dir_entry+0(len).

    APPEND l_s_chavl TO l_t_chavl.

    • set mime-type

    l_s_content_info-mimetype = 'application/msword'.

    l_s_content_info-file_name = dir_entry.

    l_s_content_info-file_size = l_filelength.

    • set name and title

    name = dir_entry.

    CLEAR l_t_return.

    • upload document

    CALL FUNCTION 'RSOD_DOC_MAST_CHANGE'

    EXPORTING

    i_chanm = l_s_chavl-chanm

    i_chavl = l_s_chavl-chavl

    • I_DOC_TYPE =

    i_description = descr

    i_name = name

    • I_LANGU = SY-LANGU

    i_overwrite_mode = if_rsod_const=>mode_replace_phio

    i_with_content = 'X'

    i_s_content_info = l_s_content_info

    • I_WITH_URL =

    • I_URL =

    • I_COPY_URL_CONTENT =

    IMPORTING

    • E_NAME =

    e_s_return = l_t_return

    TABLES

    i_t_file_content_ascii = l_t_data_tab_asc

    i_t_file_content_binary = l_t_data_tab_bin.

    IF l_t_return-type = 'E' OR

    l_t_return-type = 'W' OR

    l_t_return-type = 'A'.

    • error

    WRITE: / dir_entry(25), text-004, l_t_return-type,

    l_t_return-id, l_t_return-number.

    ELSE.

    • successfuly loaded

    WRITE: / dir_entry(25), text-003.

    ENDIF.

    ENDLOOP.

    ENDFORM. "section_main

    kindly reward if found helpful.

    cheers,

    Hema.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 19, 2008 at 12:52 PM

    you can use FM BDS_BUSINESSDOCUMENT_CREATEF for this. search the forum with this FM name to find code sample.

    Raja

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.