In article Delete Routing - piece of cake I've shown you how to use FM from CEWB transaction to delete routings. If you go through all FM that are inside function groups of CEWB then you'll see that there is a lot of possibilities there. For example creation of a new routing, you can do it step by step or create a routing on a base of existing one. Today I'll show how to copy existing routing to new one with usage of FM CP_CC_S_LOAD_COMPLEX_BY_TSK to load source routing to memory , CP_CC_S_COPY_BY_TSK to copy areas we want and CP_CC_S_SAVE to save new routing to database. In my example I will copy completely source routing to target but in any case you can also omit some of the areas and create them after save (like material allocation or components assignment ).

form create_routing_by_copy_ewb using f_plnty_s
                                      f_plnnr_s
                                      f_plnal_s
                                      f_matnr_s
                                      f_werks_s
                                      f_vbeln_s
                                      f_posnr_s
                                
changing 
                                      f_plnty_t
                                      f_plnal_t
                                      f_plnnr_t
.
*This is the code from http://abapblog.com.
  datafs_copy_by_tsk type copy_by_tsk.
  dataf_classes_in_workarea like classes_in_workarea.
  dataf_tsk_plnty_selection type cpsc_plnty_type.
  dataf_tsk_plnnr_selection type cpsc_plnnr_type.
  dataf_tsk_plnal_selection type cpsc_plnal_type.
  dataf_tsk_selection type cpsc_tsk_sel_type.
  dataf_tsk_ident type  cpcl_tsk_ident_type.
  dataf_mtk_ident type czcl_mtk_type.
  dataft_capp_opr type standard table of capp_opr.
  datafs_opr_class_data type opr_class_data.
  dataf_error type cpcc_message_type.

* objects for loading source routing
  f_classes_in_workarea-mtk_inarea 'X'.
  f_classes_in_workarea-tsk_inarea 'X'.
  f_classes_in_workarea-seq_inarea 'X'.
  f_classes_in_workarea-opr_inarea 'X'.
  f_classes_in_workarea-suo_inarea 'X'.
  f_classes_in_workarea-prt_inarea 'X'.
  f_classes_in_workarea-com_inarea 'X'.
  f_classes_in_workarea-itm_inarea 'X'.
  f_classes_in_workarea-bom_inarea 'X'.

* fill selection conditions
  concatenate 'I' 'EQ' f_plnty_s into f_tsk_plnty_selection.
  append f_tsk_plnty_selection to f_tsk_selection-plnty.

  concatenate 'I' 'EQ' f_plnnr_s into f_tsk_plnnr_selection.
  append f_tsk_plnnr_selection to f_tsk_selection-plnnr.

  concatenate 'I' 'EQ' f_plnal_s into f_tsk_plnal_selection.
  append f_tsk_plnal_selection to f_tsk_selection-plnal.


* load source routing into EWB
  call function 'CP_CC_S_LOAD_COMPLEX_BY_TSK'
    exporting
      i_class                        'P'
      i_classes_in_workarea          f_classes_in_workarea
      i_cpsc_tsk_sel                 
f_tsk_selection
      i_date_from                    
sy-datum
      i_date_to                      sy-datum
    exceptions
      workarea_not_found             1
      workarea_wrong_type            2
      class_in_workarea_inconsistent 3
      workarea_not_specified         4
      opr_not_found                  5
      no_selection_criteria          6
      invalid_selection_period       7
      key_date_required_for_ecm      8
      others                         9.
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

* select areas that should be copied from our source routing
  fs_copy_by_tsk-seq_copy       'X'.
  fs_copy_by_tsk-cla_tsk_copy   'X'.
  fs_copy_by_tsk-odp_seq_copy   'X'.
  fs_copy_by_tsk-opr_copy       'X'.
  fs_copy_by_tsk-mtk_copy       'X'.
  fs_copy_by_tsk-odp_opr_copy   'X'.
  fs_copy_by_tsk-cla_opr_copy   'X'.
  fs_copy_by_tsk-suo_copy       'X'.
  fs_copy_by_tsk-odp_suo_copy   'X'.
  fs_copy_by_tsk-com_copy       'X'.
  fs_copy_by_tsk-prt_copy       'X'.
  fs_copy_by_tsk-odp_prt_copy   'X'.
  fs_copy_by_tsk-mst_copy       'X'.
  fs_copy_by_tsk-cha_copy       'X'.
  fs_copy_by_tsk-chv_copy       'X'.
  fs_copy_by_tsk-pac_copy       'X'.

* copy routing
  call function 'CP_CC_S_COPY_BY_TSK'
    exporting
*     I_ECN_SOURCE                   = ' '
*     I_KEY_DATE_SOURCE              = I_KEY_DATE_SOURCE
*     I_ECN_S                        = ' '
      i_key_date_s                   sy-datum
      i_plnty_source                 
f_plnty_s
      i_plnnr_source                 
f_plnnr_s
      i_plnal_source                 
f_plnal_s
      i_plnty_target                 
f_plnty_t
      i_plnnr_target                 
f_plnnr_t
      i_plnal_target                 
f_plnal_t
      i_plant_target                 
f_werks_s
      i_material_root_target         
f_matnr_s
      i_plant_root_target            
f_werks_s
      i_sales_order_root_target      
f_vbeln_s
      i_sales_order_item_root_target 
f_posnr_s
      i_material_root_source         
f_matnr_s
      i_plant_root_source            
f_werks_s
*     I_SALES_ORDER_ROOT_SOURCE      = I_SALES_ORDER_ROOT_SOURCE
*     I_SALES_ORDER_ITEM_ROOT_SOURCE = I_SALES_ORDER_ITEM_ROOT_SOURCE
      i_copy_objects_by_tsk          fs_copy_by_tsk
*     I_FLG_CONSISTENCY_CHECK        = 'X'
*     I_ITM_IDENT_MAPPING            = I_ITM_IDENT_MAPPING
*     I_FLG_ECM_RECALCULATION        = 'X'
    importing
      e_plnty_target                 f_plnty_t
      e_plnnr_target                 
f_plnnr_t
      e_plnal_target                 
f_plnal_t
*     E_PLANT_TARGET                 = E_PLANT_TARGET
*     E_HANDLE_TARGET                = E_HANDLE_TARGET
      e_ecm_data_error_type          f_error
    
exceptions
      path_source_incomplete         1
      path_target_incomplete         2
      no_valid_source_task           3
      task_not_copied                4
      ecm_evaluation_necessary       5
      others                         6.
  if sy-subrc eq 0.
*   save routing to database
    call function 'CP_CC_S_SAVE'
      exceptions
        error_at_save 1
        others        2.
    if sy-subrc <> 0.
      rollback work.
    else.
      commit work.
    endif.
  endif.
endform.                    "create_routing_by_cpy_ewb

Enjoy!