使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細

i042416發表於2018-06-23

在事務碼 MM02裡為ID為16的material維護附件:

使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細
使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細

如何使用ABAP程式碼獲得如下附件的名稱和檔案內容?

 REPORT zgos_api.

DATA ls_appl_object     TYPE gos_s_obj.

DATA lo_gos_api         TYPE REF TO cl_gos_api.

DATA lt_attachment_list TYPE gos_t_atta.

DATA lt_role_filter     TYPE gos_t_rol.

DATA ls_attachment   TYPE gos_s_atta.

DATA ls_attachm_cont TYPE gos_s_attcont.

DATA ls_atta_key     TYPE gos_s_attkey.

DATA: lv_id  TYPE matnr VALUE '16',

      lt_att TYPE TABLE OF sibflporb.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = lv_id IMPORTING output = lv_id. ls_appl_object-typeid = 'BUS1001006'. ls_appl_object-instid = lv_id. ls_appl_object-catid = 'BO'. START-OF-SELECTION. TRY. lo_gos_api = cl_gos_api=>create_instance( ls_appl_object ). APPEND cl_gos_api=>c_attachment TO lt_role_filter. lt_attachment_list = lo_gos_api->get_atta_list( lt_role_filter ). CATCH cx_gos_api INTO DATA(error). WRITE:/ error->get_text( ). RETURN. ENDTRY. DATA: ls_key TYPE gos_s_attkey. LOOP AT lt_attachment_list ASSIGNING FIELD-SYMBOL(<id>). ls_key-atta_id = <id>-atta_id. ls_key-atta_cat = <id>-atta_cat. DATA(ls) = lo_gos_api->get_al_item( ls_key ). ENDLOOP. 

執行結果:

使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細

要獲取更多Jerry的原創技術文章,請關注公眾號"汪子熙"或者掃描下面二維碼:

使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細
使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2156567/,如需轉載,請註明出處,否則將追究法律責任。

相關文章