Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Create a Document with an original file stored on application server

Hello,

I start with document managment system : i am able to create new document (CV01N) manually, add a local file and check-in this file.

Now we need to store file which are stored on the SAP Application Server.

Firstly, in the GUI of transaction CV01N, i don't know how to browse file on application server. All files i can't attach as original, are files i can access from my computer.

Is it possible to access also on application server files ?

Moreover, i have to define function module which have to

- Create a document (DMS)

- Attach an orginial file which is stored on application server

- Check-in the file

This function module will be called from a web application

I define this kind of function and run it correctly with a local file (stored on my computer) : i call BAPI "BAPI_DOCUMENT_CREATE2" and "BAPI_DOCUMENT_CHECKIN2"

But i don't how to do with a file stored on application server. I see also note 504692 and try a program like ZZUZTEST_TEST_CHECKIN which use FM CVAPI_DOC_CHECKIN but it return an error Error uploading E:\usr\sap\TD1\DVEBMGS00\data\FACTURE.txt" (this path and file exist on application server and is really the file i want to checkin)

Please could you confirm what i search, is possible or not.

If possible, could help me with some explanations and guidelines and perhaps a sample ?

Thank you very much.

Regards,

Eric

The function used

-


FUNCTION Z_TEST_CHECKIN.

***********************************************************************

  • Checkin the first original of a document info record *

  • from the application server and/or in the background *

***********************************************************************

data : w_host like BAPI_DOC_AUX-HOSTNAME.

data: lf_line(255).

data: ls_draw like DRAW,

ls_message_cvapi like messages,

lt_files_cvapi type standard table of CVAPI_DOC_FILE,

lt_files_cvapi_header like CVAPI_DOC_FILE.

data: lt_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE,

vo_originals LIKE cvapi_doc_file OCCURS 0 WITH HEADER LINE.

ls_draw-dokar = 'ZFT'.

ls_Draw-doknr = '0000000000000004500000032'.

ls_Draw-dokvr = '00'.

ls_Draw-doktl = '000'.

  • Read Originals contained in the document info record

CALL FUNCTION 'CVAPI_DOC_GETDETAIL'

EXPORTING

pf_batchmode = 'X'

pf_hostname = ' '

pf_dokar = ls_draw-dokar

pf_doknr = ls_draw-doknr

pf_dokvr = ls_draw-dokvr

pf_doktl = ls_draw-doktl

pf_active_files = 'X'

IMPORTING

psx_draw = ls_draw

TABLES

pt_files = vo_originals

EXCEPTIONS

not_found = 1

no_auth = 2

error = 3

OTHERS = 4.

IF sy-subrc <> 0.

WRITE 'Error returned by CVAPI_DOC_GETDETAIL'. "#EC NOTEXT

EXIT.

ENDIF.

  • Check if we can really access the file from the application server

read table vo_originals index 1.

open dataset vo_originals-filename for input in text mode ENCODING DEFAULT.

if not sy-subrc is initial.

message e500(26) with vo_originals-filename 'not found'.

endif.

read dataset vo_originals-filename into lf_line.

if not sy-subrc is initial.

message e500(26) with vo_originals-filename 'read error'.

endif.

lt_originals = vo_originals.

lt_originals-STORAGE_CAT = 'SAP-SYSTEM'.

append lt_originals.

w_host = sy-host.

CALL FUNCTION 'CVAPI_DOC_CHECKIN'

EXPORTING

PF_DOKAR = ls_draw-dokar

PF_DOKNR = ls_draw-doknr

PF_DOKVR = ls_draw-dokvr

PF_DOKTL = ls_draw-doktl

  • PS_DOC_STATUS =

PF_FTP_DEST = 'SAPFTPA'

PF_HTTP_DEST = 'SAPHTTPA'

*PF_HOSTNAME = w_host

  • PS_API_CONTROL =

  • PF_REPLACE = ' '

  • PF_CONTENT_PROVIDE = 'SRV'

IMPORTING

PSX_MESSAGE = ls_message_cvapi

TABLES

PT_FILES_X = lt_originals

  • PT_COMP_X =

  • PT_CONTENT =

.

IF ls_message_cvapi-msg_type CA 'EA'.

ROLLBACK WORK.

MESSAGE ID '26' TYPE 'I' NUMBER '000'

WITH ls_message_cvapi-msg_txt.

ELSE.

COMMIT WORK and wait.

ENDIF.

ENDFUNCTION.

Not what you were looking for? View more on this topic or Ask a question