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

Problem with BAPI_DOCUMENT_CREATE2

Former Member
0 Likes
4,934

Hi experts !!

I have a problem with this Bapi "BAPI_DOCUMENT_CREATE2". I can create the document using a local file but can't use a file stored in other server.

These are my fm parameters

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = it_documentdata

hostname = w_hostname " SAMBA

pf_ftp_dest = 'SAPFTPA'

IMPORTING

return = it_return

documentnumber = w_docnumber

TABLES

documentfiles = it_documentfiles.

And return this error

Error while checking in and storing: \portaldesa\archivos\PM\imagenes\TIE2301-08-A\prueba.JPG

Message ID 26

Message Number 253

Please I need help. !!

Thanks

Jose.

15 REPLIES 15
Read only

Former Member
0 Likes
3,196

any idea ???

thanks

Read only

Former Member
0 Likes
3,196

Solved.. !!

Read only

0 Likes
3,196

Hi,

How did you solve this problem

cheers

Santosh

Read only

0 Likes
3,196

Hi.!!

I solved my problem with this :

With this code we get the hostname

CALL 'SAPCORE' ID 'ID' FIELD 'VERSION'

ID 'TABLE' FIELD kernel_version-sys.

READ TABLE kernel_version INDEX 11.

w_hostname = kernel_version-data.

LOOP AT it_img.

it_documentfiles-wsapplication = it_img-extension.

it_documentfiles-docfile = '/R3/file/test.JPG'. "In this field Put the comple path from your server

it_documentfiles-storagecategory = 'ZDMS'.

it_documentfiles-checkedin = 'X'.

it_documentfiles-description = w_text.

it_documentfiles-documenttype = w_clase.

it_documentfiles-documentversion = w_version.

it_documentfiles-documentpart = w_part.

APPEND it_documentfiles.

ENDLOOP.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = it_documentdata

hostname = w_hostname "R/3 SERVER

pf_ftp_dest = 'SAPFTPA'

pf_http_dest = 'SAPHTTPA'

IMPORTING

return = it_return

documentnumber = w_docnumber

TABLES

documentfiles = it_documentfiles.

Read only

0 Likes
3,196

Hi,

thanks in advance for your information. I have used your suggestions but I have the problem again.

I try to explain you:

We have a PDM system ( Windchill-PDMlink) that through a u201Cstartrfcu201D sends

an input file to Sap system putting the file into a directory (AL11 example /usr/abssvil..) .

Sap reads this file input and

Create a material (ok)

Create a file_batch_XX.bat (ok)

then

Create a document with this attach (file_batch_XX.bat) (error!)

We have use the bapi create2 but SAP doesnu2019t create info record because it isnu2019t able to check in the file.

The error is about SDOK_PHIOS_CHECKIN error 1.

I write you a part of our code:

CALL 'SAPCORE' ID 'ID' FIELD 'VERSION'

ID 'TABLE' FIELD kernel_version-sys.

READ TABLE kernel_version INDEX 11.

w_hostname = kernel_version-data.

CLEAR lt_docfiles.

REFRESH lt_docfiles.

lt_docfiles-documenttype = 'DOC'.

lt_docfiles-documentnumber = l_doc_bapi.

lt_docfiles-documentpart = '000'.

lt_docfiles-documentversion = mara-zeivr. "'00'. R.V 30.06.08

lt_docfiles-storagecategory = 'DMS_C1_ST'.

lt_docfiles-docfile = l_perc_bat.

lt_docfiles-wsapplication = 'BAT'.

APPEND lt_docfiles.

CLEAR dms_doc_files.

SELECT SINGLE doknr FROM dms_doc_files INTO dms_doc_files-doknr

WHERE dokar EQ 'DOC'

AND doknr EQ l_doc_bapi

AND dokvr EQ mara-zeivr.

DATA: i_ok(1) VALUE space.

PERFORM check_dok USING i_ok

ls_datidoc-documenttype

ls_datidoc-documentnumber

ls_datidoc-documentpart

ls_datidoc-documentversion.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = ls_datidoc

hostname = w_hostname

pf_ftp_dest = 'SAPFTPA'

pf_http_dest = 'SAPHTTPA'

IMPORTING

documenttype = ls_datidoc-documenttype

documentnumber = ls_datidoc-documentnumber

documentpart = ls_datidoc-documentpart

documentversion = ls_datidoc-documentversion

return = gs_esito_bapi

TABLES

documentfiles = lt_docfiles

objectlinks = lt_objectlinks.

Could you help me?

Thanks

Vanessa

Read only

0 Likes
3,196

Hi Jose,

I am having similar issue. I am trying to create an attachment into DMS from our application server. The file is in DIR_TEMP directory. The file path is /tmp/test.pdf. But it doesn't work, Could you please tell me if i have to specify the full file path like
<servername>\<directory>\filename.

At the moment i am passing the file path as \tmp\test.pdf. I am getting an error message "Error uploading /TMP/TEST.PDF"

Please suggest me if i havet o use the full file path.

Thanks in advance,

Rajesh Tummala.

Read only

0 Likes
3,196

Hi,

I have a requirement to attach a PDF document to the Purchase Requisition number in DMS.

I am using the Same BAPI "BAPI_DOCUMENT_CREATE2". The document with attachment is gettig created, but we have an issue with document Check-in.

The PDF document is placed in the Local Desktop, and we are trying to attache the document thru Adobe form.

We have configured two RFC connection "SAPHTTPA" and "SAPFTPA".

Hence it is run thru Adobe, the document is try to load thru SAPFTPA and when it try to Open using "Open Dataset" query, it throws the error. "No such file or Directory".

Could you please let me know what could be the cause, how to resolve this issue.

Thanks,

Vinod

Read only

0 Likes
3,196

Hi friend,

i saw your Message and i want know how can i archive a document in Sap-system , sure you know that, would you please help me, i want archive my document as archivlink, i want know how to do that, and which FM module shall i use, after uploading my document from PC shall i start with converting to string or to xstring and what about content repository ID?

thank you very much

Sharl

Read only

Former Member
0 Likes
3,196

Hi Vanessa, could you show me the value of this var " l_perc_bat "

maybe the path is not good.

Jose

Read only

0 Likes
3,195

Hi Jose

the value is:

/usr/sap/users/abssvil/File_batch_LV03N000001B.bat

Thanks in advance,

ciao

Vanessa

Read only

0 Likes
3,195

Hi Vanessa.

I have some questions :

a) Can you create a document with the transaction CV01N ???

b) The file "File_batch_LV03N000001B.bat " exits in the server ??

c) The file extension it does not have to go '.BAT' ??

With this questions i can help you more.

Jose

Read only

0 Likes
3,195

Hi Jose

With Cv01n I create a document correctly attach file .bat

the file.bat is on the server correctly

and I use BAT like workstation application in which I define extension .bat

Now with many test

We able to create a document and the file but We have to force a return of the bapi to 0.

The function give us the error is :Y_FTP_Client_to_r3, this function give us return code =1 we have to force = 0 . We don't understand because give us 1 as error.

Thanks in advance

Cheer

Vanessa

Read only

0 Likes
3,195

Hi Vanessa.. your DMS Server is independent from R3 Server ???

Maybe the RFC is not working fine.. try with this RFC "SAPFTP" and "SAPHTTP"

Read only

0 Likes
3,195

Hi

I try to explain the process. We have widchill pdm system that put the input file (T901)

with a call 'startrfc' in sap system in a directory (AL11--> usr\sap\users\...)

then our program in sap read the input file create a material master ok

create a file.bat and put on the directory, then the programm create a info record and

attach the file bat. So the program gets the file.bat and create a document with bapicreate2 or change2 with sapftpa, saphhtpa and w_hostname (the code written in previous message..). The file.bat is archived in sap dms in repository DMS_C1_ST that is r3 database. We have not a content server...

So for you we have to use sapftp ? But sapftpa not is correct for get file from another server or a directory that is not a client ( front end)?

thanks

Vanessa

Read only

former_member183924
Active Participant
0 Likes
3,195

please see note 504692:

[https://service.sap.com/sap/support/notes/504692|https://service.sap.com/sap/support/notes/504692]

- Steffen