使用ABAP代码返回S/4HANA Material上维护的Attachment明细
Posted sap-jerry
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用ABAP代码返回S/4HANA Material上维护的Attachment明细相关的知识,希望对你有一定的参考价值。
在事务码 MM02里为ID为16的material维护附件:
如何使用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.
执行结果:
要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:
以上是关于使用ABAP代码返回S/4HANA Material上维护的Attachment明细的主要内容,如果未能解决你的问题,请参考以下文章
ABAP系列SAP S/4 HANA的SMARTFORMS如何切换到非word编辑器
如何将S/4HANA系统存储的图片文件用Java程序保存到本地