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: 

BAPI_DOCUMENT_CREATE2 - Copy Attached file issue

Former Member
0 Kudos

Hi,

I am trying to create a document with attachment in CV01 using the BAPI BAPI_DOCUMENT_CREATE2.

Here my requirement is to copy the attached files from a document to another document (which I will be creating newly).

I mean attachments from document 1 to document 2.

When I try using this bapi BAPI BAPI_DOCUMENT_CREATE2, what should I give in the docpath parameter.

I have storage category to maintain.

Even though if I pass storage category, the parameter is not checked in. So, it is throwing with error as “Error while checking and sorting”.

So, In debugging , I set to checked in again and ran successfully.

   

But, when I try to open the attached file in newly created document 2.  Getting error as could not be accessed.

Adding one more point is that, the fiel might have been uploaded from application server earlier and they might have removed that file from the application server. So, i should not access this file again trough application server.

Please suggest if I am doing anything wrong.

   

Thanks,

Prabu

Message was edited by: prabu kailasam

3 REPLIES 3

Former Member
0 Kudos

Hi,

Is it possible to handle this directly using this BAPI_DOCUMENT_CREATE2 or should i proceed the following approach.

1) Get the document file content using SCMS_DOCUMENT_READ

2) Use write dataset to write in the application server.

3) Then use the  BAPI_DOCUMENT_CREATE2 to attach that file updated in step 2 in the document in cv01.

Please suggest.

Thanks,

Prabu

0 Kudos

Hi Prabhu,

                 Obviously this FM checks the storage category and file location in database so if it does not exist it will give you an error so your above approach will be a correct approach.

Check it like this

** Check in original 1 simultaneously in the SAP Database

REFRESH lt_files.

CLEAR lt_files.

lt_files-storagecategory = 'SAP-SYSTEM'.

lt_files-docfile      = 'c:\temp\drawing.txt'.

lt_wsapplication = 'TXT'.

APPEND lt_files.

Thanks

Former Member
0 Kudos


Hi All,

Thanks for your response. I found the solution. Used the FM CV120_KPRO_LOIO_COPY  to solve this issue.

Thanks,

Prabu