Skip to Content
0

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

Jun 07, 2017 at 03:40 PM

523

avatar image
Former Member

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,

Naresh

onactionlink-to-manual.txt

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Jun 15, 2017 at 05:32 PM
1

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.

download-file-from-dms.txt

-

Thanks and Best Regards,

Naresh


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for sharing the resolution.

0
Mike Pokraka Jun 07, 2017 at 07:30 PM
0

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

  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
Show 6 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Mike,

Yes, I have debugged the code and the sy-subrc value is 0.

-

Best Regards,

Naresh

0

OK, next step I'd suggest comparing the real PDF from CV03 with the one you downloaded. Are they the same size? Open the contents with a hex editor and compare.

0
Former Member

Hi Mike,

File Size when downloaded from CV03N is 2,896 KB

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

As suggested, I downloaded and compared both the version using HxD and found out that there is a mismatch (PFA).

Please let me know how to resolve this issue.

-

Thanks and Best Regards,

Naresh

hxd-compare.jpg

hxd-compare.jpg (568.7 kB)
0

Uff, that's just odd. Would expect a difference to be at a numeric boundary that corresponds to some data structure, such as 2550. And then either a character missing or extra, but changing a 4 into a 2 at position 51 is very strange. I must admit I'm running out of ideas. Perhaps debug the CV03N download and see how that's done?

Just to ask the obvious: are you sure you're downloading the same file.

0
Former Member

Hi, I debugged the T-Code CV03N and found out another FM CV120_DOC_CHECKOUT_VIEW but this function internally uses FM GUI_DOWNLOAD which doesn't work in Webdynpro :(

Yes I'm downloading the same file. Please suggest.

0

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.

0
harish vyas Jun 08, 2017 at 10:19 AM
0

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.

Regards,

Harish


sdn-query.txt (4.2 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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,

Naresh

0