Application Development and Automation 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: 
Read only

a way to get attachment programmatically

Former Member
0 Likes
3,008

Hi experts, i'm new in ABAP development and I have a problem.

I looked for solution in this forum but i didn't find anything to help me.

In the CRM COMMPR01 transaction, for a specific product, i uploaded an attachment (a jpg image); now i have to develop a FM to get this file in any way (such as providing me a URL to download it or giving me the binary code of my file).

Using debug and stuff like this, i found that my image is stored (clustered) in the SOFFCONT1 table and I found the correct procedure to identify all the rows of this table which contain my image... the problem is that i can't read this image because of the rappresentation format of field CLUSTD wich contains the image code.

I've read that i may use the instruction IMPORT ... FROM DATABASE but i didn't understand how to use it, so:

- in general, is there any way to get access at the attachment (FM, class or something to get URL or binary code)?

          - if not, how can i get binary code of my image starting from the sum of all CLUSTD field of all the rows of SOFFCONT1 associated to my image?

Thank you so much

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,949

Hello you both and thank you for your answer...

FM BDS_BUSINESSDOCUMENT_GET_C_URL is not so easy to use because you have to search many parameters, even if it makes the whole process simplier. Anyway, i found a way to get simply the attached documents using the FM SO_DOCUMENT_READ_API1 as explained in the 3d http://scn.sap.com/thread/1450845.

so...

  • starting by PRODUCT_GUID
  • select * FROM SRGBTBREL into lt_SRGBTBREL where INSTID_A = line_return-PRODUCT_GUID.
  • call function 'SO_DOCUMENT_READ_API1'

          exporting

            DOCUMENT_ID = lt_SRGBTBREL-INSTID_B

          tables

            CONTENTS_HEX = lt_CONTENTS_HEX.

lt_CONTENTS_HEX is a table which contains the binary code of the attachment divided in rows.

Thank you, see you soon.

3 REPLIES 3
Read only

Former Member
0 Likes
1,949

Hi,

Please check the thread.

<< Link Farming Removed & points unassigned >>

Cheers

~Niranjan

Message was edited by: Kesavadas Thekkillath

Read only

Former Member
0 Likes
1,949

Hi,

Have a look at function modules starting with BDS_BUSINESSDOCUMENT*

I have used fm BDS_BUSINESSDOCUMENT_CREATEF to add an attachment to a purchase requisition and it works fine.

Maybe FM BDS_BUSINESSDOCUMENT_GET_C_URL will do the trick ?

Regards,

Dirk.

Read only

Former Member
0 Likes
1,950

Hello you both and thank you for your answer...

FM BDS_BUSINESSDOCUMENT_GET_C_URL is not so easy to use because you have to search many parameters, even if it makes the whole process simplier. Anyway, i found a way to get simply the attached documents using the FM SO_DOCUMENT_READ_API1 as explained in the 3d http://scn.sap.com/thread/1450845.

so...

  • starting by PRODUCT_GUID
  • select * FROM SRGBTBREL into lt_SRGBTBREL where INSTID_A = line_return-PRODUCT_GUID.
  • call function 'SO_DOCUMENT_READ_API1'

          exporting

            DOCUMENT_ID = lt_SRGBTBREL-INSTID_B

          tables

            CONTENTS_HEX = lt_CONTENTS_HEX.

lt_CONTENTS_HEX is a table which contains the binary code of the attachment divided in rows.

Thank you, see you soon.