背景
在MM模块或MDG模块的开发中,经常出现BP客商批量下载或者分发的需求,对于选定的BP,有些ABAPer可能会通过ABAP SQL直接查询相关的表,但是这种方法需要开发者对后台表逻辑非常熟悉,且SQL数量相当大,不符合本人一直的简洁(偷懒)作风,采用几个简单的函数,只需要输入BP和客商编码,就能读取绝大多数的数据,相当哇噻。
相关函数
本文未读取BP联系人数据,大家可以通过where-used-list获取标准代码中对相关函数的具体用法
函数/类说明BUPA_OUTBOUND_GET_MAIN读取BP数据BUPA_OUTBOUND_GET_REL读取BP联系人数据VMD_EI_API_EXTRACT读取供应商数据CMD_EI_API_EXTRACT读取客户数据代码示例
类型&变量定义
点击查看代码- types:begin of ty_bp_general,
- bu_group type string,
- partner type string,
- bpext type string,
- mc_name1 type string,
- name_org1 type string,
- name_last type string,
- name_first type string,
- taxtype type string,
- taxnumxl type string,
- idnumber type string,
- street type string,
- post_code1 type string,
- city1 type string,
- country type string,
- region type string,
- langu type string,
- tel_number type string,
- mob_number type string,
- fax_number type string,
- smtp_addr type string,
- augrp type string,
- legal_org type string,
- found_dat type string,
- ind_sector type string,
- name_co type string,
- city2 type string,
- home_city type string,
- end of ty_bp_general,
- begin of ty_bp_identification,
- partner type string,
- type type but0id-type,
- idnumber type but0id-idnumber,
- end of ty_bp_identification,
- begin of ty_bp_role,
- partner type string,
- rltyp type bu_partnerrole,
- end of ty_bp_role,
- begin of ty_bp_bank,
- partner type string,
- banks type string,
- bankl type string,
- banka type string,
- bankn type string,
- bkref type string,
- koinh type string,
- bkont type string,
- end of ty_bp_bank,
- begin of ty_vendor_company,
- lifnr type string,
- bukrs type string,
- akont type string,
- zuawa type string,
- qsrec type string,
- frgrp type string,
- end of ty_vendor_company,
- begin of ty_vendor_porg,
- lifnr type string,
- ekorg type string,
- verkf type string,
- telf1 type string,
- waers type string,
- zterm type string,
- kalsk type string,
- kzaut type string,
- webre type string,
- end of ty_vendor_porg,
- begin of ty_customer_company,
- kunnr type string,
- bukrs type string,
- akont type string,
- zuawa type string,
- zterm type string,
- zwels type string,
- zgrup type string,
- end of ty_customer_company,
- begin of ty_customer_sorg,
- kunnr type string,
- vkorg type string,
- vtweg type string,
- spart type string,
- vkbur type string,
- vkgrp type string,
- bzirk type string,
- kdgrp type string,
- waers type string,
- kalks type string,
- vsbed type string,
- vwerk type string,
- podkz type string,
- ktgrd type string,
- taxkd type string,
- inco1 type string,
- inco2_l type string,
- inco3_l type string,
- zterm type string,
- kkber type string,
- kvgr1 type string,
- kvgr2 type string,
- end of ty_customer_sorg.
- data:mt_bp_general type table of ty_bp_general,
- mt_bp_id type table of ty_bp_identification,
- mt_bp_role type table of ty_bp_role,
- mt_bp_bank type table of ty_bp_bank,
- mt_vendor_company type table of ty_vendor_company,
- mt_vendor_porg type table of ty_vendor_porg,
- mt_customer_company type table of ty_customer_company,
- mt_customer_sorg type table of ty_customer_sorg.
复制代码 读取BP
点击查看代码读取客户
点击查看代码- data: ls_customer_in type cmds_ei_main,
- ls_customer_out type cmds_ei_main.
- ls_customer_in-customers = value #(
- for ls_bp in lt_business_partners
- (
- header-object_task = 'M'
- header-object_instance-kunnr = ls_bp
- )
- ).
- try.
- "Extract Customers w/ performance optimization
- cvi_cl_process_info=>set_process(
- exporting
- iv_process = 'MDG'
- ).
- cmd_ei_api_extract=>get_data(
- exporting
- is_master_data = ls_customer_in
- importing
- es_master_data = ls_customer_out
- exceptions
- others = 1 ).
- cvi_cl_process_info=>clear_process( ).
- catch cx_sy_dyn_call_illegal_method cx_sy_dyn_call_param_missing
- cx_sy_dyn_call_parameter_conv cx_sy_dyn_call_parameter_error.
- "Extract Customers w/o performance optimization
- cmd_ei_api_extract=>get_data(
- exporting
- is_master_data = ls_customer_in
- importing
- es_master_data = ls_customer_out
- exceptions
- others = 1 ).
- endtry.
- loop at ls_customer_out-customers into data(ls_customer).
- loop at ls_customer-company_data-company into data(ls_customer_company).
- append initial line to mt_customer_company assigning field-symbol(<customer_company>).
- <customer_company>-kunnr = ls_customer-header-object_instance-kunnr.
- <customer_company>-bukrs = ls_customer_company-data_key-bukrs.
- <customer_company>-akont = ls_customer_company-data-akont.
- <customer_company>-zuawa = ls_customer_company-data-zuawa.
- <customer_company>-zterm = ls_customer_company-data-zterm.
- <customer_company>-zwels = ls_customer_company-data-zwels.
- <customer_company>-zgrup = ls_customer_company-data-zgrup.
- endloop.
- loop at ls_customer-sales_data-sales into data(ls_customer_sales).
- append initial line to mt_customer_sorg assigning field-symbol(<customer_sorg>).
- <customer_sorg>-kunnr = ls_customer-header-object_instance-kunnr.
- <customer_sorg>-vkorg = ls_customer_sales-data_key-vkorg.
- <customer_sorg>-vtweg = ls_customer_sales-data_key-vtweg.
- <customer_sorg>-spart = ls_customer_sales-data_key-spart.
- <customer_sorg>-vkbur = ls_customer_sales-data-vkbur.
- <customer_sorg>-vkgrp = ls_customer_sales-data-vkgrp.
- <customer_sorg>-bzirk = ls_customer_sales-data-bzirk.
- <customer_sorg>-kdgrp = ls_customer_sales-data-kdgrp.
- <customer_sorg>-waers = ls_customer_sales-data-waers.
- <customer_sorg>-kalks = ls_customer_sales-data-kalks.
- <customer_sorg>-vsbed = ls_customer_sales-data-vsbed.
- <customer_sorg>-vwerk = ls_customer_sales-data-vwerk.
- <customer_sorg>-podkz = ls_customer_sales-data-podkz.
- <customer_sorg>-ktgrd = ls_customer_sales-data-ktgrd.
- " <customer_sorg>-taxkd = ls_customer_sales-data-taxkd.
- <customer_sorg>-inco1 = ls_customer_sales-data-inco1.
- <customer_sorg>-inco2_l = ls_customer_sales-data-inco2_l.
- <customer_sorg>-inco3_l = ls_customer_sales-data-inco3_l.
- <customer_sorg>-zterm = ls_customer_sales-data-zterm.
- <customer_sorg>-kkber = ls_customer_sales-data-kkber.
- <customer_sorg>-kvgr1 = ls_customer_sales-data-kvgr1.
- <customer_sorg>-kvgr2 = ls_customer_sales-data-kvgr2.
- endloop.
- endloop.
复制代码 读取供应商
点击查看代码- data:ls_supplier_in type vmds_ei_main,
- ls_supplier_out type vmds_ei_main.
- ls_supplier_in-vendors = value #(
- for ls_bp in lt_business_partners
- (
- header-object_task = 'M'
- header-object_instance-lifnr = ls_bp
- )
- ).
- try.
- "Extract Customers w/ performance optimization
- cvi_cl_process_info=>set_process(
- exporting
- iv_process = 'MDG'
- ).
- vmd_ei_api_extract=>get_data(
- exporting
- is_master_data = ls_supplier_in
- importing
- es_master_data = ls_supplier_out
- exceptions
- others = 1 ).
- cvi_cl_process_info=>clear_process( )..
- catch cx_sy_dyn_call_illegal_method cx_sy_dyn_call_param_missing
- cx_sy_dyn_call_parameter_conv cx_sy_dyn_call_parameter_error.
- "Extract Customers w/o performance optimization
- vmd_ei_api_extract=>get_data(
- exporting
- is_master_data = ls_supplier_in
- importing
- es_master_data = ls_supplier_out
- exceptions
- others = 1 ).
- endtry.
- loop at ls_supplier_out-vendors into data(ls_vendor).
- loop at ls_vendor-company_data-company into data(ls_vendor_company) .
- append initial line to mt_vendor_company assigning field-symbol(<vendor_company>).
- <vendor_company>-lifnr = ls_vendor-header-object_instance-lifnr.
- <vendor_company>-bukrs = ls_vendor_company-data_key-bukrs.
- <vendor_company>-akont = ls_vendor_company-data-akont.
- <vendor_company>-zuawa = ls_vendor_company-data-zuawa.
- <vendor_company>-qsrec = ls_vendor_company-data-qsrec.
- <vendor_company>-frgrp = ls_vendor_company-data-frgrp.
- endloop.
- loop at ls_vendor-purchasing_data-purchasing into data(ls_vendor_porg).
- append initial line to mt_vendor_porg assigning field-symbol(<vendor_porg>).
- <vendor_porg>-lifnr = ls_vendor-header-object_instance-lifnr.
- <vendor_porg>-ekorg = ls_vendor_porg-data_key-ekorg.
- <vendor_porg>-verkf = ls_vendor_porg-data-verkf.
- <vendor_porg>-telf1 = ls_vendor_porg-data-telf1.
- <vendor_porg>-waers = ls_vendor_porg-data-waers.
- <vendor_porg>-zterm = ls_vendor_porg-data-zterm.
- <vendor_porg>-kalsk = ls_vendor_porg-data-kalsk.
- <vendor_porg>-kzaut = ls_vendor_porg-data-kzaut.
- <vendor_porg>-webre = ls_vendor_porg-data-webre.
- endloop.
- endloop.
复制代码 来源:豆瓜网用户自行投稿发布,如果侵权,请联系站长删除 |