Skip to Content

Download Attached file from DMS Server(cv03n) to local system in webdynpro (ECC 7.4)

Hello All,

I'm currently working on an ECC (from release 4.3 to 7.4) upgrade project.

Please give me some suggestion for Downloading Attached file from DMS Server(cv03n) to local system in webdynpro.

I have attached a code snippet where I have used 2 FMs namely: CVAPI_DOC_CHECKOUTVIEW_DIALOG, SCMS_BINARY_TO_XSTRING and one class method cl_wd_runtime_services=>attach_file_to_response

This approach will download the file but when opened it gives an error saying: 'There was an error opening the document' but I'm able to view the pdf in CV03 without any issue. However the same code works for lower releases like ECC 4.3.

Kindly suggest as I have to complete it by tomorrow. Any suggestion will be really helpful.


Thanks and Best Regards,



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jun 15, 2017 at 05:32 PM

    Hi Everyone,

    After struggling for three days I finally found the solution for this and it is not because of any upgrade issue. The FM which I used is CVAPI_DOC_CHECKOUTVIEW_DIALOG. This FM returns a table PTX_CONTENT which consists of fields ORLN i.e., File length of original and ORBLK i.e., Data block for original data. Now, to convert these data blocks to XSTRING we use FM SCMS_BINARY_TO_XSTRING, here we capture these data blocks (ORBLK) in a separate internal table and assign this table to BINARY_TAB now once this is done we have to pass value to SIZE which we can get it from field ORLN (This size is very important). The FM will return BUFFER which we can use it in standard download module namely cl_wd_runtime_services=>attach_file_to_response.

    PFA. the attached code snippet. On this note I shall close this thread, thank you all and peace.



    Thanks and Best Regards,


    Add comment
    10|10000 characters needed characters exceeded

  • Jun 07, 2017 at 07:30 PM

    Have you debugged it? I'm always suspicious of any code that contains:

      IF sy-subrc <> 0.
    * Implement suitable error handling here
    Add comment
    10|10000 characters needed characters exceeded

    • Sorry am out of ideas here. If it was me I'd debug old and new systems side by side and compare the differences. Maybe include the primary ABAP Development tag where there's a lot more people reading it who could help. This doesn't seem like a Web Dynpro issue at all.

  • Jun 08, 2017 at 10:19 AM

    Hi Naresh,

    I don't have much experience on this topic but have tried to answer it.

    Reason which I suspect can cause the issue:

    • SIZE value passed while converting BINARY to XSTRING
    • DOKNR contains multiple files in it, what I can notice is that you are trying to read DOKNR content and not file

    I have tried to put some code snippet as attachment which might be helpful to solve your issue. Please refer to comments in the attached file to understand the flow.



    Add comment
    10|10000 characters needed characters exceeded

    • Thank you for your response Harish.

      I implemented the code on my system and found out that the condition w.r.t., the DB table i.e., "DMS_PH_CD1" will fail because the file_id is blank and due to which the size computation is done by statement 2550 * lines.

      And I'm still getting the same error when I open the pdf. I also noticed that the size is different when compared to the original document which I downloaded from CV03N.

      File Size when downloaded from CV03N is 2,896 KB

      File Size when downloaded from Webdynpro Application is 2,897 KB


      Best Regards,