Application Development 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: 

Issue with retrieving GOS attachment

Thiruvengadam
Explorer
0 Kudos

Hi,

My requirement is to create a Web service to retrieve the contents of an attachment which was uploaded via GOS.toolbar in Purchase Requisition. I am able to retrieve the list of attachments and get the content of the particular attachment, but after I save the file to my PC I am unable to open the file. It seems to be corrupt.

Following is the logic I have used:

1. Call  BDS_GOS_CONNECTIONS_GET with CLASSNAME =  'BUS2105' and objkey = <PR Number>. I am able to retrieve the list of attachments in gos_connections.

2. Then call  SO_DOCUMENT_READ_API1 to read the contents_hex into LT_HEX_CONT.

3. Convert the table contents into Binary string LV_BINFILE using the folowing code

CLEAR lv_binfile.
   LOOP AT lt_hex_cont INTO ls_hex_cont.
     ASSIGN ls_hex_cont TO <p> CASTING.
     CONCATENATE lv_binfile <p> INTO lv_binfile IN BYTE MODE.
   ENDLOOP.


4.return the contents of the lv_binfile as the export parameter for the FM


The Java program that consumes the web service downloads the contents to a file on the PC, but we are unable to open the file.


I tried the following also:

1. Call  BDS_GOS_CONNECTIONS_GET with CLASSNAME =  'BUS2105' and objkey = <PR Number>. I am able to retrieve the list of attachments in gos_connections.

2. Then call  SO_DOCUMENT_READ_API1 to read the OBJECT_CONTENT and download to PC using GUI_DOWNLOAD in ASC mode. Still the same issue.

One thing I noticed is that the size of the actual file is 103kb, whereas the downloaded file is about 208kb.

Not sure where I went wrong. Pls help

Regds

Thiru

1 ACCEPTED SOLUTION

former_member195402
Active Contributor
0 Kudos

Hi Thiru,

I see your issue, but I don't understand, why you want so save the attachment to a local PC file, if you want to create a webservice.

I think, in a webservice you won't have access to a local file, because the provider of the webservice will have no SAPGUI running.

Please tell us, what the consumer of the webservice wants to do with the attachment:

Display/Save local/Something else

Regards:

Klaus

4 REPLIES 4

former_member195402
Active Contributor
0 Kudos

Hi Thiru,

I see your issue, but I don't understand, why you want so save the attachment to a local PC file, if you want to create a webservice.

I think, in a webservice you won't have access to a local file, because the provider of the webservice will have no SAPGUI running.

Please tell us, what the consumer of the webservice wants to do with the attachment:

Display/Save local/Something else

Regards:

Klaus

0 Kudos

Hi Klaus,

The actual requirement is to provide the content via a web service, which the java consumer will download to a file on its App server and send a link to the end user . The java programmer who wrote the app to consume this Webservice complained that the file couldn't be opened. So I copied the ABAP FM and modified it to download the content to my PC to check if it works. Hope this explains.

Regds

Thiru

0 Kudos

Hi Thiru,

from

http://wiki.scn.sap.com/wiki/display/ABAP/Reading+PDF+attachment+from+sap+inbox+through+ABAP?origina...

I've got one idea to use fm SCMS_BINARY_TO_XSTRING for xstring creation. But the parameter input_length is needed.

Maybe you can get it from fm SO_DOCUMENT_READ_API1 in table ATTACHMENT_LIST.

Please try that.

Regards,

Klaus

0 Kudos

Hi Klaus,

I have partly solved with help from this link http://scn.sap.com/docs/DOC-32708.

The FM  SDOK_PHIO_LOAD_CONTENT provides the binary content which I then convert to XSTRING using the FM  SCMS_BINARY_TO_XSTRING.

Now I need to get the LOIO_ID or PHIO_ID for the attachment in order to call the SDOK_PHIO_LOAD_CONTENT.

The LOIO ID for each attachment can be retrieved by calling FM SO_OBJECT_READ. The first line of the parameter OBJCONT contains the LOIO_ID based on which we can get the PHIO ID from SOFFPHIO.

Problem solved. Thanks Klaus.

Regds

Thiru


Message was edited by: Thiru Dorairaj