如何使用ABAP程式碼建立SAP Product Category
In ERP we can create new material type by copying from existing one using tcode OMS2:
This new type could be downloaded into CRM system via customizing download. A product category with prefix MAT_ will be automatically created.
And here below is source code to create new product category using MAT_ as parent category by ABAP code.
METHOD replicate_category.
CONSTANTS:
BEGIN OF gc_application,
sales TYPE comt_application VALUE '01', "r3-produkthier purchasing TYPE comt_application VALUE '02', "r3 mat class product TYPE comt_application VALUE '03', "r3 mat types config TYPE comt_application VALUE '04',
internet TYPE comt_application VALUE '05',
END OF gc_application.
CONSTANTS:
BEGIN OF gc_product_type,
material TYPE comt_product_type VALUE '01',
service TYPE comt_product_type VALUE '02',
finance TYPE comt_product_type VALUE '03',
ip_prod TYPE comt_product_type VALUE '04',
warranty TYPE comt_product_type VALUE '05',
tradeitem TYPE comt_product_type VALUE '06',
fs_prod TYPE comt_product_type VALUE '07',
END OF gc_product_type.
rv_success = abap_false.
DATA: lv_hierarchy_guid TYPE comt_hierarchy_guid,
lv_parent_guid TYPE comt_category_guid,
lt_categoryt TYPE comt_categoryt_tab.* Prerequisite: the corresponding hierarchy is already downloaded from ERP* Read the hierarchy which is assigned to application 03* (product type material) in transaction COMM_PRAPPLCAT
CALL FUNCTION 'COM_HIERARCHY_READ_WITH_APPL'
EXPORTING
iv_application = gc_application-product
iv_product_type = gc_product_type-material
IMPORTING
ev_hierarchy_guid = lv_hierarchy_guid
EXCEPTIONS
not_found = 1
OTHERS = 2.
CHECK sy-subrc = 0.
DATA(ls_cat_text) = VALUE comt_categoryt( langu = sy-langu category_text = iv_text
text_upper_case = iv_text ).
TRANSLATE ls_cat_text-text_upper_case TO UPPER CASE.
APPEND ls_cat_text TO lt_categoryt.
select single category_guid into lv_parent_guid FROM comm_category
where category_id = 'MAT_'.
CALL FUNCTION 'COM_PRODCAT_API_CREATE_CAT'
EXPORTING
iv_category_id = iv_cat_id
iv_hierarchy_guid = lv_hierarchy_guid
iv_parent_guid = lv_parent_guid
iv_product_type = gc_product_type-material
it_categoryt = lt_categoryt
iv_logsys = iv_log_sys " 'QI3CLNT502' iv_non_assignable = abap_false
EXCEPTIONS
hierarchy_not_maintained = 1
wrong_call = 2
category_id_exists = 3
id_scheme_error = 4
error = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'X' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
RETURN.
ENDIF.
CALL FUNCTION 'COM_PRODUCT_CATEGORY_SAVE_ALL'
EXPORTING
iv_update_task = ' '
iv_update_pme = ' '
iv_hierarchy_guid = lv_hierarchy_guid
EXCEPTIONS
internal_error = 1
OTHERS = 2.
ASSERT sy-subrc = 0.
COMMIT WORK AND WAIT.
rv_success = abap_true.
ENDMETHOD.
Method signature:
How to use this code
Run method in SE24, specify new product category id via parameter iv_cat_id:
Execute method, ensure ev_success equals to abap_true.
Once created, the category could be searched via tcode COMM_HIERARCHY:
And the category could be used to create new product in WebUI:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2723618/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用ABAP程式碼給SAP CRM Business object建立附件AttachmentObject
- SAP CRM Product category的決定邏輯Go
- SAP CRM Product hierarchy,Category和Application三個問題GoAPP
- 如何使用 ABAP 程式消費 SAP ABAP OData 服務
- SAP Retail 事務程式碼WSOA1建立Assortment不能選Assortment Category !AIGo
- SAP 電商雲 Spartacus UI 的 Product Category Navigation UI 實現UIGoNavigation
- 如何在SAP Cloud for Customer中建立基於Opportunity的Registered ProductCloudUnity
- 使用ABAP程式碼提交SAP CRM Survey調查問卷
- 兩種使用程式碼獲得SAP CRM product sales status的辦法
- 無法新增某個relationship給SAP CRM Product category的一個可能原因Go
- 如何使用 ABAP 程式碼解析 XML 檔案XML
- 如何在SAP Cloud Platform ABAP程式設計環境裡建立一個employeeCloudPlatform程式設計
- 使用ABAP建立QR Code(二維碼)
- 使用ABAP程式碼建立S/4HANA裡的Sales Order
- 使用 Prometheus 監控 SAP ABAP 應用程式Prometheus
- 如何使用 JavaScript 程式碼連線部署在 SAP ABAP 伺服器上的 OData 服務JavaScript伺服器
- 如何使用ABAP程式碼反序列化JSON字串成ABAP結構JSON字串
- 如何使用程式碼建立和讀取 SAP CRM 訂單的 Text 資料
- 如何在 SAP ABAP 系統中使用 Adobe FormORM
- 如何在SAP Spartacus category 頁面裡拿到當前的category資訊Go
- SAP ABAP OData 服務如何支援建立(Create)操作試讀版
- 使用Java程式碼在SAP Marketing Cloud上建立Contact資料JavaCloud
- 使用 ABAP 程式碼刪除指定 SAP CRM 系統裡 Opportunity 訂單的文字Unity
- SAP EPD - Enterprise Product Developmentdev
- 如何使用 API 的方式給 SAP service cloud Registered product 上傳圖片APICloud
- 一些通過SAP ABAP程式碼審查得出的ABAP程式設計最佳實踐程式設計
- 如何使用ABAP Restful API進行程式碼的全文搜尋RESTAPI行程
- 如何查詢Authorization object在哪些ABAP程式碼裡使用到Object
- SAP ABAP 程式之間的呼叫
- 使用ABAP程式碼生成二維碼(QR Code)
- SAP ABAP關鍵字語法圖和ABAP程式碼自動生成工具Code Composer
- SAP MM Purchase Order History CategoryGo
- 使用nodejs程式碼在SAP C4C裡建立Individual customerNodeJS
- 如何用Java程式碼在SAP Marketing Cloud裡建立contact資料JavaCloud
- SAP SEGW 事物碼裡的 ABAP Editor
- SAP ABAP Application Log 的使用方法APP
- 如何透過 ABAP 程式碼給 SAP OData 後設資料增添註解試讀版
- 如何用SAP WebIDE的Fiori建立嚮導基於ABAP OData service快速建立UI5應用WebIDEUI