cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with ZZUZEST_TEST_CHECKIN2

ged_hurst
Participant
0 Kudos

Hello everyone,

I've been following the note 504692 and created the report ZZUZEST_TEST_CHECKIN2 passing on a document number I created beforehand (and for which I also uploaded an attachment in the category).

When the BAPI BAPI_DOCUMENT_GETDETAIL2 is executed, it returns a table of files: lt_documentfiles.

However when it executes:

open dataset lt_documentfiles-docfile for input in BINARY MODE or

open dataset lt_documentfiles-docfile for input in text mode encode utf-8

it returns a file not found error (but the file is correctly visible from within CV03N).

Where could the problem be?

I'm trying to set up this simple scenario because I then want to implement a file upload into DMS from WebDynpro. But I'd like to have this working first.

Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

christoph_hopf
Advisor
Advisor
0 Kudos

Hi,

I think it would be a real help for the colleagues here in the forum to have the complete coding of the BAPI call or the coding part your question is related to. So could you please post as this coding?

Best regards,

Christoph

ged_hurst
Participant
0 Kudos

REPORT  ZZUZEST_TEST_CHECKIN2.

*data: '\\hs2080.wdf.sap-ag.de\a\hw1372\U9C\b\Zoltan\main1.doc'.

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.

data: ls_return like BAPIRET2,
      lt_documentfiles like BAPI_DOC_FILES2 occurs 0 with header line,
      lt_documentfiles_new like BAPI_DOC_FILES2 occurs 0 with header
line,
      ls_doc like BAPI_DOC_DRAW2,
      ls_docx like BAPI_DOC_DRAWX2.



*************** Start-of-selection *****************

start-of-selection.

ls_draw-dokar = 'ZDD'.
ls_Draw-doknr = '0000000000000000000010092'.
ls_Draw-dokvr = '01'.
ls_Draw-doktl = '000'.

CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
  EXPORTING
    DOCUMENTTYPE              = ls_draw-dokar
    DOCUMENTNUMBER            = ls_draw-doknr
    DOCUMENTPART              = ls_draw-doktl
    DOCUMENTVERSION            = ls_draw-dokvr
*   GETOBJECTLINKS            = ' '
*   GETCOMPONENTS              = ' '
*   GETSTATUSLOG              = ' '
*   GETLONGTEXTS              = ' '
    GETACTIVEFILES            = 'X'
*   GETCLASSIFICATION          = ' '
*   GETSTRUCTURE              = ' '
*   GETWHEREUSED               = ' '
*  HOSTNAME                  = ' '
  IMPORTING
    DOCUMENTDATA               = ls_doc
    RETURN                    = ls_return
  TABLES
*  OBJECTLINKS                =
*  DOCUMENTDESCRIPTIONS       =
*  LONGTEXTS                  =
*  STATUSLOG                  =
    DOCUMENTFILES              = lt_documentfiles
*  COMPONENTS                =
*   CHARACTERISTICVALUES      =
*   CLASSALLOCATIONS          =
*   DOCUMENTSTRUCTURE          =
*  WHEREUSEDLIST              =
          .

IF ls_return-type ca 'EA'.
  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 lt_documentfiles index 1.
open dataset lt_documentfiles-docfile for input in TEXT MODE ENCODING utf-8.

if not sy-subrc is initial.
  message e500(26) with lt_documentfiles-docfile 'not found'.
endif.

read dataset lt_documentfiles-docfile into lf_line.

if not sy-subrc is initial.
  message e500(26) with lt_documentfiles-docfile 'read error'.
endif.

lt_documentfiles_new = lt_documentfiles.
lt_documentfiles_new-STORAGECATegory = 'DMS_C1_ST'.
append lt_documentfiles_new.

CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
  EXPORTING
    DOCUMENTTYPE              = ls_draw-dokar
    DOCUMENTNUMBER            = ls_draw-doknr
    DOCUMENTPART              = ls_draw-doktl
    DOCUMENTVERSION            = ls_draw-dokvr
    DOCUMENTDATA               = ls_Doc
    DOCUMENTDATAX              = ls_docx
*  HOSTNAME                  =
*   DOCBOMCHANGENUMBER        =
*   DOCBOMVALIDFROM            =
*  DOCBOMREVISIONLEVEL        =
*  SENDCOMPLETEBOM            = ' '
    PF_FTP_DEST                = 'SAPFTPA'
    PF_HTTP_DEST               = 'SAPHTTPA'
*  CAD_MODE                  = ' '
  IMPORTING
    RETURN                    = ls_return
  TABLES
*   CHARACTERISTICVALUES      =
*   CLASSALLOCATIONS          =
*   DOCUMENTDESCRIPTIONS      =
*  OBJECTLINKS                =
*  DOCUMENTSTRUCTURE          =
    DOCUMENTFILES              = lt_documentfiles_new
*  LONGTEXTS                  =
*  COMPONENTS                =
          .


IF ls_return-type CA 'EA'.
    ROLLBACK WORK.
    MESSAGE ID '26' TYPE 'I' NUMBER '000'
    WITH ls_return-message.
  ELSE.
    COMMIT WORK and wait.
  ENDIF.

The referred to document is retrieved and it's attachments are stored in lt_documentfiles. However when the lines


read table lt_documentfiles index 1.
open dataset lt_documentfiles-docfile for input in TEXT MODE ENCODING utf-8.
if not sy-subrc is initial.
  message e500(26) with lt_documentfiles-docfile 'not found'.
endif.

are executed the system raises a message saying:

"c:\users\myuser\Desktop\test2.txt not found"

But the file has been checked into the storage category and it's on the application server and correctly available within CV03N.

Thank you for your help?