Application Development 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: 

FM/BAPI to upload attachment in Service for Object

Former Member
0 Kudos

Hello,

Does anyone know a FM/BAPI to upload attachment in Service for Object?

In SAP transaction in my case MM02, I can add the attachment in the material master from the menu System -> Service for Object -> Create attachment.

What I'm trying to do is that I want to upload one document to many materials automatically by a program. Is there a way to do this?

Thanks in advance,

Joe

5 REPLIES 5

Former Member
0 Kudos

hi,

can u brief the question so that in can help ... or u can check the in tcode BAPI if the Fm is aviable or not.

Thank You,

Santhosh

Bharathi_j
Explorer
0 Kudos

Hi,

Did u got a solution for your query...

even i luking for a solution exactly to the same problem u have....

can u please share me if u got to know how to create attachment dynamically.

Bharathi.

Former Member
0 Kudos

Hi Lucky,

Am looking for the same solution, could you please care to share the solution, Thanks.

0 Kudos

Hi friends , sorry for Late reply , But try the below code it really works .

Reard points if u found helpful .

PARAMETERS:

p_kunnr TYPE kunnr.

DATA:

ls_object_identity TYPE borident,

lo_gos TYPE REF TO cl_gos_document_service.

ls_object_identity-objkey = p_kunnr. "e.g. '0000954410'.

ls_object_identity-objtype = 'KNA1'.

CREATE OBJECT lo_gos.

CALL METHOD lo_gos->create_attachment

EXPORTING

is_object = ls_object_identity

IMPORTING

ep_attachment = ls_object_identity-objkey.

COMMIT WORK.

0 Kudos

Hi Ajay,

Is there a way to do this without using the CREATE_ATTACHMENT method.

By using this method, it opens a window to allow user to browse and select the attachment.

I do not want a window to appear. Instead, I want to hard code the attachment address path in the code itself.

So when I execute my program, it does not show any pop up and straight away it uploads the attachment using my address path that I coded in.

Thanks.