Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Attaching attachments in custom module pool program

former_member216611
Participant
0 Likes
4,546

Hi All,

I have created module pool program to send email . In the popup I have created a button name as "Select Attachment" .

When user clicks on that button we need to attach attachments in the popup. Please advise me on this how to attach files.

Regards,

Siva

8 REPLIES 8
Read only

omer_sakar
Participant
0 Likes
3,065
Read only

0 Likes
3,065

Hi Omer Sakar,

Thank you very much for your helpful answer, actually my requirement is bit different . Please find the below screen shot for more details.

( the above screen shot is from outlook )

In module pool program I want to attach files like as same and user has able to see the attached files, by clicking on single click or double click on attached files.

Regards,

Siva

Read only

Former Member
0 Likes
3,065

Hi Siva ;

Please examine below the link , its already answered .

Attaching file in module pool | SCN

Regards

Özgün

Read only

0 Likes
3,065

Hi EFE,

I have inserted the GOS object in my module pool program, here my goal to add GOS object in module pool program not in Application Bar.

1) By adding GOS object to tool bar I am getting it in module pool Application tool bar like below.

2) in my case I want the same button in middle of the Module pool program like below.

Regards,

Siva

Read only

FredericGirod
Active Contributor
0 Likes
3,065

hi

regards

Fred

Read only

former_member235395
Contributor
0 Likes
3,065

Hi Siva,

First, when you work with attach document, we are talking about GOS Service, so, all document saved in SAP that use GOS service is stored in SRGBTBREL table.

For do your goal, try to do this:

1.- Use GUI_UPLOAD FM like this:

    CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING

        filename                = g_filename

        filetype                = 'BIN'

      IMPORTING

        filelength              = g_attsize

      TABLES

        data_tab                = gt_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.

The goal here, is just upload the file.

2.- Use macro and BINARY_RELATION_CREATE_COMMIT FM, like this

      swc_container lt_message_container.

      swc_container l_cont.

      swc_create_object  l_obj  'MESSAGE'       ''.

      swc_set_element    l_cont 'NO_DIALOG'     'X'.

      swc_set_element    l_cont 'DOCUMENTTITLE' g_filename.

      swc_set_table      l_cont 'Content_Hex'   gt_bin.

      swc_set_element    l_cont 'DOCUMENTTYPE'  lv_ext.

      swc_set_element    l_cont 'DOCUMENTSIZE'  g_attsize.

      swc_refresh_object l_obj.

      swc_call_method    l_obj  'CREATE'        l_cont.

      swc_get_object_key l_obj  gs_objb-objkey.

      gs_objb-objtype = gc_msg.

      gs_obja-objtype = gc_bus.

      gs_obja-objkey  = p_ebeln.

      CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'

        EXPORTING

          obj_rolea      = gs_obja

          obj_roleb      = gs_objb

          relationtype   = 'ATTA'

        IMPORTING

          binrel         = gs_binrel

        TABLES

          binrel_attrib  = gt_binatt

        EXCEPTIONS

          no_model       = 1

          internal_error = 2

          unknown        = 3

          OTHERS         = 4.

The goal here, is store the document in SAP, so, check SRGBTBREL table and find your document. It's important store the values(INSTID_B, TYPEID_B, CATID_B) in Z table, because after that the user will check the file again.

3.- If you want display the file attached doing click or double click

DATA: obj_display TYPE REF TO cl_gos_document_service.

  READ TABLE git_addoc INTO gst_addoc WITH KEY flag = gc_x.

  IF sy-subrc = 0.

    CREATE OBJECT obj_display.

    CALL METHOD obj_display->display_attachment

      EXPORTING

        ip_attachment = gst_addoc-instid_b.

    FREE obj_display.

I hope will be useful for you.

Regards,

Read only

0 Likes
3,063

Hi Thanks for your reply,

I have created a custom module pool program like below.

When user clicks on select attachment I am calling below method for popup.

CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title           
= 'Choose Input File'
initial_directory      
= 'C:/'
CHANGING
file_table             
= lt_files
rc                     
= l_rc
EXCEPTIONS
file_open_dialog_failed
= 1
cntl_error             
= 2
error_no_gui           
= 3
not_supported_by_gui   
= 4
OTHERS                  = 5.

After user selecting document by using below FM I am uploading the document

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename               
= l_file
filetype               
= 'BIN'
TABLES
data_tab               
= t_mailhex
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.

After that I want to attach this file in the above screen and user can be able to see what file he has attached by clicking on it.

Question 1) How to display that selected file in module pool screen after select attachment button? Or we have to send that link to below text message area? 


Regards,

Siva

Read only

0 Likes
3,063

Hi Siva,

Respect your question... I think, is depend of your scenario.

i.e. If you check the GOS Services in "Attachment List" option, you check all documents attached in a list inside a new screen for every PO number.

So, for you module pool program, you can have some similar if the user will load several files, BUT DON'T FORGET that all files will exist in SAP, and they files will be exist in SRGBTBREL Table, you will need store the files on this table using the funtion in Step 2 mentioned.

Regards,