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: 

Add an attachment to Fi document via abap program and display it.

Akshayvjd07
Explorer
0 Kudos

Hi experts,

My requirement is to add a document as attachment into a FI document using program and on the next step on clicking a button i need to display that particular attachment. I used FM "BDS_BUSINESSDOCUMENT_CREA_TAB" and i was able to add the document to the attachment list with a new description. But I'm not able to display it. But when i add the attachment using fb03 directly the same code worked. So any suggestions will be appreciated.

Note: When i using the method cl_binary_relation=>read_links_of_binrels ,not able to get value in table int_links.

Also when we attaching the document via program that details not saving in table SRGBTBREL which stores the attachments. so do i need to use any other functions for attaching the document instead of BDS_BUSINESSDOCUMENT_CREA_TAB

 wa_rel_options-low = 'ATTA'. "" Attachemnts
wa_rel_options-sign = 'I'.
wa_rel_options-option = 'EQ'.
APPEND wa_rel_options TO int_rel_options.
DATA: attlist LIKE soattlsti1 OCCURS 1 WITH HEADER LINE.
TRY.
CALL METHOD cl_binary_relation=>read_links_of_binrels
EXPORTING
is_object = wa_object " Start object
it_relation_options = int_rel_options " Link Types
ip_role = 'GOSAPPLOBJ' " Role type
IMPORTING
et_links = int_links. " Table with Relationship Records

CATCH cx_obl_parameter_error. " Incorrect Calling of Interface
CATCH cx_obl_internal_error. " Internal Error of Relationship Service
CATCH cx_obl_model_error. " Error with Model Roles
ENDTRY.
IF int_links[] IS NOT INITIAL.
LOOP AT int_links INTO wa_links.
CLEAR : lv_doc_id, wa_doc_data.
lv_doc_id = wa_links-instid_b.
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_doc_id
* FILTER = 'X'
IMPORTING
document_data = wa_doc_data
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
IF wa_doc_data-obj_descr = 'Wire Instructions' .

lv_img_exist = abap_true.
CREATE OBJECT lo_gos_service.
CALL METHOD lo_gos_service->display_attachment
EXPORTING
* is_object =
ip_attachment = wa_links-instid_b.
ENDIF.
CLEAR wa_links.
ENDLOOP.
4 REPLIES 4

Akshayvjd07
Explorer
0 Kudos

Edited Thank you

Akshayvjd07
Explorer
0 Kudos

Hi every one , I was able to solve the issue.

Thanks to this blog This.

priyankaa_007
Explorer
0 Kudos

Hi Akshay,

Could you please let me know how did you solve it?

0 Kudos

Did you look at the blog post that Akshay mentioned as being the solution? Please explain why it doesn't help you and clarify precisely what is your exact issue.