Skip to Content

Reading file from CV03N and send as email attachment

Hi Team,

Requirement :- While Creating/Changing sales order, an output type "BA00" will trigger for medium '5' (mail) which will read the file present in CV03N and send this file as email attachment.

1. I have done codding in Driver program. This driver program is executing in update task.


Sequence of FM's Used:-


CALL FUNCTION 'CV115_DOC_OPEN_DISPLAY'

CALL FUNCTION 'CRM_EMAIL_SPLIT_FILENAME'

CALL FUNCTION 'CV120_FTP_OPEN'

CALL FUNCTION 'CV120_GET_FRONTEND_TYPE'

CALL FUNCTION 'CV120_DOC_CHECKOUT_VIEW

CALL FUNCTION 'GUI_UPLOAD'


For this i have created one stand alone FM.

Question :- While executing this FM stand alone through se37 all the steps are working fine.

Query :- While applying this FM in Driver program(which is executing in update task) CALL FUNCTION 'GUI_UPLOAD' is not reading file data 😔

Please help me ...

Code :-

CALL FUNCTION 'CV115_DOC_OPEN_DISPLAY'

EXPORTING

* PF_API_FLAG = ' '

pf_dokar = gse1_draw-dokar

pf_doknr = gse1_draw-doknr

pf_doktl = gse1_draw-doktl

pf_dokvr = gse1_draw-dokvr

pf_read_drat = 'X'

pf_read_drad = 'X'

pf_read_comp = 'X'

pf_read_kpro = 'X'

pf_read_drap = 'X'

IMPORTING

psx_draw = gse_draw

TABLES

ptx_drat = gte_drat

ptx_draz = gte_draz

ptx_drad = gte_drad

ptx_drap = gte_drap

ptx_files = gte_files.

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

LOOP AT gte_files INTO gse_file.

gse_dmsfiles-mark = 'X'.

gse_dmsfiles-lo_index = gse_file-lo_index. "file no. index

gte_phios = gse_file-tbl_phios. "file object numbers

READ TABLE gte_phios INTO gse_phios WITH KEY lo_index = gse_file-lo_index.

IF sy-subrc = 0.

IF gse_phios-filename IS NOT INITIAL.

CLEAR : iv_path, ev_filename, ev_extension.

iv_path = gse_phios-filename.

CALL FUNCTION 'CRM_EMAIL_SPLIT_FILENAME'

EXPORTING

iv_path = iv_path

IMPORTING

ev_filename = ev_filename

ev_extension = ev_extension.

gse_dmsfiles-filename = ev_filename.

gse_dmsfiles-file_type = ev_extension.

APPEND gse_dmsfiles TO gte_dmsfiles.

ENDIF.

ENDIF.

ENDLOOP.

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

LOOP AT gte_dmsfiles INTO gse_dmsfiles WHERE mark = 'X'.

CLEAR : gte_phios[].

READ TABLE gte_files INTO gse_file WITH KEY lo_index = gse_dmsfiles-lo_index.

IF sy-subrc = 0.

gte_phios = gse_file-tbl_phios. "file object numbers

READ TABLE gte_phios INTO gse_phios WITH KEY lo_index = gse_file-lo_index.

IF sy-subrc = 0.

CLEAR : gve_file,gse_phio,gse_doc_file,gse_cout_def.

gse_cout_def-kpro_use = 'X'.

gse_cout_def-comp_get = 'X'.

gse_doc_file-langu = 'EN'.

gse_doc_file-dappl = gse_file-dappl.

gse_phio-lo_index = gse_file-lo_index.

gse_phio-lo_objid = gse_file-lo_objid.

gse_phio-ph_objid = gse_phios-ph_objid.

gse_phio-ph_index = gse_phios-ph_index.

gse_phio-langu = gse_phios-langu.

gse_phio-status_nr = gse_phios-status_nr.

gse_phio-filename = gse_phios-filename.

gse_phio-active_version = gse_phios-active_version.

gse_phio-delete_flag = gse_phios-delete_flag.

gse_phio-protected = gse_phios-protected.

gse_phio-default_langu = gse_phios-default_langu.

gse_phio-file_id = gse_phios-file_id.

gse_phio-storage_cat = gse_phios-storage_cat.

gse_phio-created_by = gse_phios-created_by.

gse_phio-created_at = gse_phios-created_at.

gse_phio-changed_by = gse_phios-changed_by.

gse_phio-changed_at = gse_phios-changed_at.

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

CALL FUNCTION 'CV120_FTP_OPEN'

EXPORTING: pf_show_progress = ''

EXCEPTIONS: error = 1

OTHERS = 2.

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

CALL FUNCTION 'CV120_GET_FRONTEND_TYPE'

EXPORTING: pf_batch = c_x "'X'

pf_host = ' '

IMPORTING: pfx_frontend_type = gs_frontend-frontend_type

pfx_host = gs_frontend-hostname

pfx_winsys = gs_frontend-winsys.

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

"This FM will create a temporaray file at location GVE_FILE

CALL FUNCTION 'CV120_DOC_CHECKOUT_VIEW

EXPORTING

ps_cout_def = gse_cout_def

pf_tcode = 'CV03N'

ps_doc_file = gse_doc_file

ps_draw = gse1_draw

ps_phio = gse_phio

ps_frontend = gs_frontend

IMPORTING

pfx_file = gve_file

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

***upload the temp file in internal table

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_filename

filetype = 'BIN'

no_auth_check = 'X'

TABLES

data_tab = gte_solix

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4.

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

Exception is coming :- gui_refuse_filetransfer = 4.

Regards

Shashank Jain


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 10, 2015 at 06:18 AM

    It's done now.

    Approach

    Sequence of FM's Used


    CALL FUNCTION 'CV115_DOC_OPEN_DISPLAY'

    CALL FUNCTION 'CRM_EMAIL_SPLIT_FILENAME'

    CALL FUNCTION 'CV120_DOC_CHECKOUT_VIEW'

    CALL FUNCTION 'GUI_UPLOAD'

    Basically GUI_UPLOAD was failing since the driver program is running in update task.

    So i have used the Sequence of FM's in User exit of Sales order i.e MV45AFZZ

    After that Transporting the content in binary format to Driver program which is running in update task...

    Cheers 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2015 at 02:30 PM

    Hi Ashish/Shashank ,😕

    GUI_UPLOAD is a front end service and doesn't work in update task or background task.

    Use file from application server instead(AL11) and then retrieve using open data set and close data set commands.

    Cheers 😊

    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.