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

File Attachment

Former Member
0 Likes
1,110

i have made the dialog program i want to attach some file like excel or word with every save howe can i attach and save the file and also if i open that particular record again for view then alo i am able to view the attached files.

abhishek suppal

i have made the dialog program i want to attach some file like excel or word with every save howe can i attach and save the file and also if i open that particular record again for view then alo i am able to view the attached files.

abhishek suppal

8 REPLIES 8
Read only

Former Member
0 Likes
944

Hello,

When Pressing the Save Button.

Call the FM WS_DOWNLOAD or GUI_DOWNLOAD.

If useful reward points.

Regards,

Vasanth

Read only

0 Likes
944
Read only

Former Member
0 Likes
944

No idea as to what are you looking for....can you be a bit more descriptive....

Srikanth

Read only

Former Member
0 Likes
944

Hi,

DATA method1 LIKE sy-ucomm.

DATA g_user LIKE soudnamei1.

DATA g_user_data LIKE soudatai1.

DATA g_owner LIKE soud-usrnam.

DATA g_receipients LIKE soos1 OCCURS 0 WITH HEADER LINE.

DATA g_document LIKE sood4 .

DATA g_header LIKE sood2.

DATA g_folmam LIKE sofm2.

DATA g_objcnt LIKE soli OCCURS 0 WITH HEADER LINE.

DATA g_objhead LIKE soli OCCURS 0 WITH HEADER LINE.

DATA g_objpara LIKE selc OCCURS 0 WITH HEADER LINE.

DATA g_objparb LIKE soop1 OCCURS 0 WITH HEADER LINE.

DATA g_attachments LIKE sood5 OCCURS 0 WITH HEADER LINE.

DATA g_references LIKE soxrl OCCURS 0 WITH HEADER LINE.

DATA g_authority LIKE sofa-usracc.

DATA g_ref_document LIKE sood4.

DATA g_new_parent LIKE soodk.

DATA: BEGIN OF g_files OCCURS 10 ,

text(4096) TYPE c,

END OF g_files.

DATA: fold_number(12) TYPE c,

fold_yr(2) TYPE c,

fold_type(3) TYPE c.

PARAMETERS ws_file(4096) TYPE c DEFAULT 'c:\ Vikalp Solutions'.

  • Can be any file from your pc....either xls or word or ppt etc...

g_user-sapname = sy-uname.

CALL FUNCTION 'SO_USER_READ_API1'

EXPORTING

user = g_user

  • PREPARE_FOR_FOLDER_ACCESS = ' '

IMPORTING

user_data = g_user_data

  • EXCEPTIONS

  • USER_NOT_EXIST = 1

  • PARAMETER_ERROR = 2

  • X_ERROR = 3

  • OTHERS = 4

.

IF sy-subrc <> 0.

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

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

ENDIF.

fold_type = g_user_data-outboxfol+0(3).

fold_yr = g_user_data-outboxfol+3(2).

fold_number = g_user_data-outboxfol+5(12).

CLEAR g_files.

REFRESH : g_objcnt,

g_objhead,

g_objpara,

g_objparb,

g_receipients,

g_attachments,

g_references,

g_files.

method1 = 'SAVE'.

g_document-foltp = fold_type.

g_document-folyr = fold_yr.

g_document-folno = fold_number.

g_document-objtp = g_user_data-object_typ.

.

g_document-objdes = 'testing by program'.

g_document-folrg = 'O'.

g_document-objlen = '0'.

g_document-file_ext = 'TXT'.

g_header-objdes = 'testing by program'.

g_header-file_ext = 'TXT'.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

method = method1

office_user = sy-uname

ref_document = g_ref_document

new_parent = g_new_parent

IMPORTING

authority = g_authority

TABLES

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

CHANGING

document = g_document

header_data = g_header

  • FOLMEM_DATA =

  • RECEIVE_DATA =

.

  • File from the pc to send...

method1 = 'ATTCREATEFROMPC'.

g_files-text = ws_file.

APPEND g_files.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

method = method1

office_user = g_owner

ref_document = g_ref_document

new_parent = g_new_parent

IMPORTING

authority = g_authority

TABLES

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

CHANGING

document = g_document

header_data = g_header.

method1 = 'SEND'.

g_receipients-recnam = 'MK085'.

g_receipients-recesc = 'B'.

g_receipients-sndex = 'X'.

APPEND g_receipients.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

method = method1

office_user = g_owner

ref_document = g_ref_document

new_parent = g_new_parent

IMPORTING

authority = g_authority

TABLES

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

CHANGING

document = g_document

header_data = g_header.

Try this,

Hope this helps u.

Regds.

Seema.

Read only

0 Likes
944

dear seema,

by this i am able to send the file to e-mail id,

my requirement is that the user will choose any file from his machine and then that fiel will be save in SAP server (i don't know its possible or not) and when the user opens that programme than he will able to see all the files he has attached and saved and will also open to see those files.

i hope u are clear with my requirement.

abhishek

Read only

0 Likes
944

This is a custom program? If so, you may be able to implement GOS(Generic Object Services). You know the icon in the Title Bar of some transactions like VA02? This is the GOS. Here this allows you do attach files to the object. This needs to be a business object, so you may need to create one in the BOR.

REgards,

Rich Heilman

Read only

0 Likes
944

Dear Rich,

I am not able to get this GOS i haven't done that can you tell me in detail.

abhishek

Read only

0 Likes
944

Hi Abhishek,

To attach documents this is the flow.

You must be saving the transaction no in a table.

This transaction no. must be a key field there. If not make it as key field.

After that, define a new business object using SWO1 transaction. Accept what ever it proposes and sounds correct.

Create table key field(your transaction no field) as Key field in this business object.

Now go to OAOR transaction and execute, enter the business object you created in class name, BO in class type and a transaction no. already existing in your table.

In the next popup say Ok.

Here you can add attachments in the create attachments on the lower left tab.

Now go to FM GOS_EXECUTE_SERVICE in R/3 and execute with this details..you can see what you have attached.

If you are in Solution Manager or CRM system then you have different FM which is better. Unfortunately that is not there in R/3.

what you can do is make a BDC recording such that it takes the transaction no. from your module pool and lands directly in attachment screen where user can attach attachments directly.

Now go to FM GOS_EXECUTE_SERVICE in R/3 and execute using same transaction no. you will get to see the attachments.

Let me know if its not clear.

Hope this helps. If so, thank me with points.

Kalyan Prathap.