These are some codes to simulate Pricing Conditions upload using IDOC
*&------------------------------------------------------------------------
*& Form map_idoc_structure
*&------------------------------------------------------------------------
* Map E1KOMG, E1KONH, E1KONP segment fields
*-------------------------------------------------------------------------
FORM map_idoc_structure
USING fp_condition_table TYPE kotabnr
fp_rate TYPE z_cs_cpp_rate
fp_condition_type TYPE kschl
fp_rate_type TYPE z_cs_file_type.
*-- Local Data Declaration
DATA: lw_e1komg TYPE e1komg, "Filter seg. with separated condition key
lw_e1konh TYPE e1konh, "Data from condition header
lw_e1konp TYPE e1konp, "Conditions Items
lv_delete TYPE konp-loevm_ko. " Delete Indicator
*-- IDoc data internal table
DATA: i_idoc_data TYPE TABLE OF edidd
INITIAL SIZE 0
WITH HEADER LINE.
CLEAR: lw_e1komg,
lw_e1konh,
lw_e1konp,
lv_delete,
v_segnum,
w_e1komg,
v_rate_type.
REFRESH i_idoc_data.
v_rate_type = fp_rate_type.
PERFORM conversion_alpha_input
USING w_crp_data-kunnr CHANGING w_crp_data-kunnr.
PERFORM conversion_matn1_input
USING w_crp_data-matnr CHANGING w_crp_data-matnr.
*E1KOMG: Filter segment with separated condition key
i_idoc_data-segnam = 'E1KOMG'.
lw_e1komg-kvewe = c_usage_cond_tab.
lw_e1komg-kotabnr = fp_condition_table.
lw_e1komg-kappl = c_cond_type.
lw_e1komg-kschl = fp_condition_type.
CONCATENATE p_vkorg p_vtweg p_spart p_hienr p_matnr.
CONCATENATE w_crp_data-vkorg w_crp_data-vtweg
w_crp_data-kunnr w_crp_data-matnr
INTO lw_e1komg-vakey.
lw_e1komg-vakey_long = lw_e1komg-vakey.
lw_e1komg-vkorg = w_crp_data-vkorg.
lw_e1komg-vtweg = w_crp_data-vtweg.
lw_e1komg-spart = w_crp_data-spart.
lw_e1komg-kunnr = w_crp_data-kunnr.
lw_e1komg-matnr = w_crp_data-matnr.
i_idoc_data-sdata = lw_e1komg.
APPEND i_idoc_data TO i_idoc_data.
*Segment E1KONH - condition header
i_idoc_data-segnam = 'E1KONH'.
lw_e1konh-datab = w_crp_data-datab.
lw_e1konh-datbi = w_crp_data-datbi.
lw_e1konh-knuma_pi = v_promotion.
lw_e1konh-knuma_ag = v_sales_deal.
i_idoc_data-sdata = lw_e1konh.
APPEND i_idoc_data TO i_idoc_data.
IF fm_process_type EQ c_pt_dep.
lv_delete = c_x. " Deletion Indicator
ENDIF.
*Segment E1KONP - condition items
i_idoc_data-segnam = 'E1KONP'.
lw_e1konp-kschl = fp_condition_type.
lw_e1konp-kbetr = fp_rate.
lw_e1konp-konwa = w_crp_data-waers.
lw_e1konp-kpein = v_cond_pric.
lw_e1konp-kmein = v_cond_unit.
lw_e1konp-knuma_pi = v_promotion.
lw_e1konp-knuma_ag = v_sales_deal.
lw_e1konp-loevm_ko = lv_delete.
i_idoc_data-sdata = lw_e1konp.
APPEND i_idoc_data TO i_idoc_data.
*-- Post Idoc for Creating Pricing Condition
PERFORM post_idoc
TABLES i_idoc_data.
ENDFORM. " map_idoc_structure
*&------------------------------------------------------------------------
*& Form post_idoc TABLES i_idoc_data.
*&------------------------------------------------------------------------
* Post Idoc for Creating Pricing Condition
*------------------------------------------------------------------------
FORM post_idoc
TABLES i_idoc_data STRUCTURE edidd.
*-- Local data declaration
DATA: lv_komg LIKE komg, " Condition Structures
lv_subrc LIKE sy-subrc, " Sy-subrc
lw_messages TYPE rsuvm_msg, " Message Description
lw_idoc_status TYPE bdidocstat. " ALE IDoc status
DATA: idoc_contrl " IDoc Control data
LIKE edidc OCCURS 1 WITH HEADER LINE.
*-- Initialize Internal Tables
CLEAR: t_konh,
t_konp,
t_konm,
t_konw,
i_idoc_status,
t_kona.
REFRESH: t_konh,
t_konp,
t_konm,
t_konw,
i_idoc_status,
t_kona,
i_messages.
************************************************************************
*This code is taken from IDOC_INPUT_COND_A
************************************************************************
PERFORM fill_appl_structures(saplvkoi)
TABLES i_idoc_data
t_konh
t_konp
t_konm
t_konw
i_idoc_status
t_kona
USING lv_komg
lv_subrc
idoc_contrl-docnum
idoc_contrl-mestyp.
IF lv_subrc = 0.
************************************************************************
*This code is taken from IDOC_INPUT_COND_A
************************************************************************
PERFORM idoc_in_datenbank(saplvkoi)
TABLES idoc_contrl
t_konh
t_konp
t_konm
t_konw
i_idoc_status
t_kona
USING lv_komg
lv_subrc
idoc_contrl-docnum.
IF lv_subrc = 0.
COMMIT WORK AND WAIT.
Endif.
No comments :
Post a Comment