【ABAP】BAPI_PRICES_CONDITIONS SAMPLE CODE
条件マスタの内容を登録更新を行うBAPI, BAPI_PRICES_CONDITIONSの動作検証をしていたところ、 過去のSAP COMMUNITYのコードを見つけて試したものの動かず。
さらに検索したところやっと動くコードを見つけて動作させることができました。 ※詳細はQiitaに掲載します。記事はこれから書くので後でリンクを張っておきます。
※条件タイプPR00、条件テーブルA304でのサンプルです。
参考先
サンプルコード
TYPES: tt_bapicondct TYPE TABLE OF bapicondct, tt_bapicondhd TYPE TABLE OF bapicondhd, tt_bapicondit TYPE TABLE OF bapicondit, tt_bapicondqs TYPE TABLE OF bapicondqs, tt_bapicondvs TYPE TABLE OF bapicondvs, tt_bapiret2 TYPE TABLE OF bapiret2, tt_bapiknumhs TYPE TABLE OF bapiknumhs, tt_mem_initial TYPE TABLE OF cnd_mem_initial. DATA: it_bapicondct TYPE tt_bapicondct, it_bapicondhd TYPE tt_bapicondhd, it_bapicondit TYPE tt_bapicondit, it_bapicondqs TYPE tt_bapicondqs, it_bapicondvs TYPE tt_bapicondvs, it_bapiret2 TYPE tt_bapiret2, it_bapiknumhs TYPE tt_bapiknumhs, it_men_initial TYPE tt_mem_initial. DATA: l_a304 TYPE a304. l_a304-vkorg = '1510'. l_a304-vtweg = '10'. l_a304-matnr = 'FG126'. l_a304-kfrst = space. it_bapicondct = VALUE #( ( operation = '009' cond_usage = 'A' table_no = '304' applicatio = 'V' cond_type = 'PR00' varkey = |{ l_a304-vkorg }{ l_a304-vtweg }{ l_a304-matnr }{ l_a304-kfrst }| valid_to = '99991231' valid_from = '20230101' cond_no = '$000000001' ) ). it_bapicondhd = VALUE #( ( operation = '009' cond_no = '$000000001' created_by = sy-uname creat_date = '20200909' cond_usage = 'A' table_no = '304' applicatio = 'V' cond_type = 'PR00' varkey = |{ l_a304-vkorg }{ l_a304-vtweg }{ l_a304-matnr }{ l_a304-kfrst }| valid_from = '20230101' valid_to = '99991231') ). it_bapicondit = VALUE #( ( operation = '009' cond_no = '$000000001' cond_count = '01' applicatio = 'V' cond_type = 'PR00' * scaletype = '' * scalebasin = '' * scale_qty = '0' cond_p_unt = '1' cond_unit = 'ST' "NOT PC calctypcon = 'C' cond_value = '800' condcurr = 'JPY' ) ). CALL FUNCTION 'BAPI_PRICES_CONDITIONS' * EXPORTING * pi_initialmode = 'X' **PI_BLOCKNUMBER = TABLES ti_bapicondct = it_bapicondct ti_bapicondhd = it_bapicondhd ti_bapicondit = it_bapicondit ti_bapicondqs = it_bapicondqs ti_bapicondvs = it_bapicondvs to_bapiret2 = it_bapiret2 to_bapiknumhs = it_bapiknumhs to_mem_initial = it_men_initial EXCEPTIONS update_error = 1 OTHERS = 2. cl_demo_output=>write( sy-subrc ). cl_demo_output=>write( it_bapiret2 ). IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. * IMPORTING * RETURN = . ELSE. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. cl_demo_output=>display( ).