SAP Fiori - transfer graphic image
Tags:
This is an example how to transfer graphic images in "Approve Purchase Order".
You can display supplier logo, supplier contact person and users who created the PO.
Challenge:
Challenge is that each customer stores images in somewhere like DB or external storage. You have to write a small code to read the image file from image store. File name should have naming convention like file name is same as user ID.
Step.1 : Find the image storage
This is just an example case that images are stored in the BDS. Business Document Service in ERP.
Transaction SE78. Images are stored with same name with supplier_id or user_name.
Each customer stores images somewhere.
Step.2 : Specify the MIME type
Transaction SE18:
Enhancement spot: GBAPP_APV_PO
BADI Definition: GBAPP_APV_PO_RDP
Method: IF_GBAPP_EX_APV_PO_RDP~CHANGE_SUPPLIER_INFO_API
-------------
method IF_GBAPP_EX_APV_PO_RDP~CHANGE_SUPPLIER_INFO_API.
FIELD-SYMBOLS <ls_contact_details> TYPE gbapps_contact_details.
* Vendor Binary available ...
cs_po_supplier_data_x-mime_type = 'image/bmp'.
* Vendor Contact Binary available ...
LOOP AT cs_po_supplier_data_x-suppliercontacts ASSIGNING <ls_contact_details>.
<ls_contact_details>-mime_type = 'image/bmp'
ENDLOOP.
endmethod.
------------
Method: IF_GBAPP_EX_APV_PO_RDP~CHANGE_USER_DETAILS_API
-----------
method IF_GBAPP_EX_APV_PO_RDP~CHANGE_USER_DETAILS_API.
FIELD-SYMBOLS <ls_user_details> LIKE LINE OF ct_user_details.
LOOP AT ct_user_details ASSIGNING <ls_user_details>.
<ls_user_details>-mime_type = 'image/bmp'.
ENDLOOP.
endmethod.
-----------
Step.3 : Transfer binary
Transaction SE18:
Enhancement spot: GBAPP_APV_PO
BADI Definition: GBAPP_APV_PO_RDP
Method: IF_GBAPP_EX_APV_PO_RDP~GET_IMAGE_BINARY_FILE
-------------
method IF_GBAPP_EX_APV_PO_RDP~GET_IMAGE_BINARY_FILE.
TYPES:
BEGIN OF ty_bitmap_file,
line(255) TYPE x,
END OF ty_bitmap_file.
TYPES: tt_bitmap_file TYPE TABLE OF ty_bitmap_file.
DATA: lt_content TYPE TABLE OF bapiconten,
lt_bitmap_file TYPE tt_bitmap_file .
DATA: lv_bytecount TYPE i,
lv_file_bytecount TYPE i,
lv_name TYPE stxbitmaps-tdname.
FIELD-SYMBOLS:
<fs_bitmap_file> TYPE ty_bitmap_file.
if iv_contact_id IS NOT INITIAL.
lv_name = iv_contact_id.
endif.
if iv_supplier_id IS NOT INITIAL.
lv_name = iv_supplier_id.
endif.
if iv_user_name IS NOT INITIAL.
lv_name = iv_user_name.
endif.
CHECK lv_name IS NOT INITIAL.
CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
EXPORTING
i_object = 'GRAPHICS'
i_name = lv_name
i_id = 'BMAP'
i_btype = 'BCOL'
IMPORTING
e_bytecount = lv_bytecount
TABLES
content = lt_content.
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
EXPORTING
old_format = 'BDS'
new_format = 'BMP'
bitmap_file_bytecount_in = lv_bytecount
IMPORTING
bitmap_file_bytecount = lv_file_bytecount
TABLES
bitmap_file = lt_bitmap_file
bds_bitmap_file = lt_content.
LOOP AT lt_bitmap_file ASSIGNING <fs_bitmap_file> .
CONCATENATE es_binary_stream-value <fs_bitmap_file>-line INTO es_binary_stream-value IN BYTE MODE.
ENDLOOP.
es_binary_stream-mime_type = 'BMP'.
endmethod.
-------------
Step.4 : Test OData in Gateway client
Transaction: /IWFND/GW_CLIENT
Supplier: /sap/opu/odata/sap/GBAPP_POAPPROVAL/SupplierDetailCollection('0000001000')/$value
Contact: /sap/opu/odata/sap/GBAPP_POAPPROVAL/SupplierContactCollection(SupplierID='0000001000',ContactID='0000152786')/$value
User: /sap/opu/odata/sap/gbapp_poapproval/UserDetailsCollection('MASA')/$value
Regards,
Masa
SAP Rapid Innovation Group - RIG