1.1 创建、修改客户主数据
*该函数更新所有字段,X表为原表,Y表为更新表
CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
EXPORTING
i_kna1 = is_kna1
i_knb1 = is_knb1
i_knvv = is_knvv
i_bapiaddr1 = is_bapiaddr1
i_maintain_address_by_kna1 = 'X'
pi_postflag = 'X'
i_from_customermaster = 'X'
IMPORTING
e_kunnr = op_kunnr
TABLES
t_xknbk = it_bank_new
t_xknvi = it_knvi
t_xknvp = it_knvp
t_xknvk = it_knvk
t_yknbk = it_yknbk
t_yknvi = it_yknvi
t_yknvp = it_yknvp
t_yknvk = it_yknvk
EXCEPTIONS
client_error = 1
kna1_incomplete = 2
knb1_incomplete = 3
knb5_incomplete = 4
knvv_incomplete = 5
kunnr_not_unique = 6
sales_area_not_unique = 7
sales_area_not_valid = 8
insert_update_conflict = 9
number_assignment_error = 10
number_not_in_range = 11
number_range_not_extern = 12
number_range_not_intern = 13
account_group_not_valid = 14
parnr_invalid = 15
bank_address_invalid = 16
tax_data_not_valid = 17
no_authority = 18
company_code_not_unique = 19
dunning_data_not_valid = 20
knb1_reference_invalid = 21
cam_error = 22
OTHERS = 23.
1.2 创建银行主数据
CALL FUNCTION 'BAPI_BANK_CREATE'
EXPORTING
bank_ctry = it_bank-banks
bank_key = it_bank-bankl
bank_address = bankaddress
i_xupdate = 'X'.
1.3 删除、解除删除、冻结、解除冻结客户主数据
CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
EXPORTING
i_kna1 = is_kna1
i_knb1 = is_knb1
i_knvv = is_knvv
i_maintain_address_by_kna1 = 'X'
pi_postflag = 'X'
i_from_customermaster = 'X'
IMPORTING
e_kunnr = op_kunnr.
1.4 显示客户主数据,可直接查询表 kna1 ,knb1, knvv , knvp , knvk
2 显示客户信贷主数据
CALL FUNCTION 'CREDIT_EXPOSURE'
EXPORTING
kkber = ip_kkber
kunnr = ip_kunnr
date_credit_exposure = '99991231'
IMPORTING
creditlimit = creditlimit
sum_opens = sum_opens.
3 客户物料
3.1 创建、修改客户物料
CALL FUNCTION 'ENQUEUE_EVKNMT'
EXPORTING
mode_knmt = 'E'
mandt = sy-mandt
vkorg = is_zrfc_s_sd024-vkorg
vtweg = is_zrfc_s_sd024-vtweg
kunnr = is_zrfc_s_sd024-kunnr
* MATNR =
x_vkorg = ' '
x_vtweg = ' '
x_kunnr = ' '
x_matnr = ' '
_scope = '2'
_wait = ' '
_collect = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
*在此添加必要的逻辑判断
CALL FUNCTION 'RV_CUSTOMER_MATERIAL_UPDATE' IN UPDATE TASK
TABLES
xknmt_tab = xknmt
yknmt_tab = yknmt
tcatalog_tab = lt_catalog.
CALL FUNCTION 'DEQUEUE_EVKNMT'
EXPORTING
mode_knmt = 'E'
mandt = sy-mandt
vkorg = is_zrfc_s_sd024-vkorg
vtweg = is_zrfc_s_sd024-vtweg
kunnr = is_zrfc_s_sd024-kunnr
* MATNR =
x_vkorg = ' '
x_vtweg = ' '
x_kunnr = ' '
x_matnr = ' '
_scope = '3'
_synchron = ' '
_collect = ' '.
3.2 显示客户物料,可直接查询表 knmt
4.订单价格条件
4.1 创建,修改条件记录,可使用BDC实现
4.2 显示条件记录,可直接查询表A305
5.销售订单
5.1创建销售订单
*凭证类型->凭证类别->对象类型
SELECT SINGLE VBTYP INTO VBTYP FROM TVAK WHERE AUART = IS_ZRFC_S_SD037-DOC_TYPE.
CALL FUNCTION 'SD_OBJECT_TYPE_DETERMINE'
EXPORTING
I_DOCUMENT_TYPE = VBTYP
IMPORTING
E_BUSINESS_OBJECT = OBJTYPE.
IF OBJTYPE = 'BUS2032'.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
ORDER_HEADER_IN = ORDER_HEADER_IN
ORDER_HEADER_INX = ORDER_HEADER_INX
LOGIC_SWITCH = LOGIC_SWITCH
TESTRUN = ' '
CONVERT = ' '
IMPORTING
SALESDOCUMENT = EP_VBELN
TABLES
RETURN = ET_LOG
ORDER_ITEMS_IN = ORDER_ITEMS_IN
ORDER_ITEMS_INX = ORDER_ITEMS_INX
ORDER_PARTNERS = ORDER_PARTNERS
ORDER_SCHEDULES_IN = ORDER_SCHEDULES_IN
ORDER_SCHEDULES_INX = ORDER_SCHEDULES_INX
ORDER_CONDITIONS_IN = ORDER_CONDITIONS_IN
ORDER_CONDITIONS_INX = ORDER_CONDITIONS_INX
ORDER_TEXT = IS_ORDER_TEXT.
ELSE.
fbgenmac 'BAPI_SALESORDER_CREATEFROMDAT2'.
* BAPIs run without dialog
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
* Set global Bapiflag for further background processing "1112263
CALL FUNCTION 'IBAPI_Z_SET_BAPI_FLAG' "1112263
EXPORTING "1112263
iv_flag = 'X'. "1112263
*ENHANCEMENT-SECTION BAPI_SALESORDER_CREATEFROMD_02 SPOTS ES_SAPL2032.
CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
EXPORTING
salesdocument = salesdocumentin
sales_header_in = order_header_in
sales_header_inx = order_header_inx
sender = sender
binary_relationshiptype = binary_relationshiptype
int_number_assignment = int_number_assignment
behave_when_error = behave_when_error
logic_switch = logic_switch
business_object = business_object
testrun = testrun
convert_parvw_auart = convert
IMPORTING
salesdocument_ex = salesdocument
TABLES
return = return
sales_items_in = order_items_in
sales_items_inx = order_items_inx
sales_partners = order_partners
sales_schedules_in = order_schedules_in
sales_schedules_inx = order_schedules_inx
sales_conditions_in = order_conditions_in
sales_conditions_inx = order_conditions_inx
sales_cfgs_ref = order_cfgs_ref
sales_cfgs_inst = order_cfgs_inst
sales_cfgs_part_of = order_cfgs_part_of
sales_cfgs_value = order_cfgs_value
sales_cfgs_blob = order_cfgs_blob
sales_cfgs_vk = order_cfgs_vk
sales_cfgs_refinst = order_cfgs_refinst
sales_ccard = order_ccard
sales_text = order_text
sales_keys = order_keys
extensionin = extensionin
partneraddresses = partneraddresses.
*END-ENHANCEMENT-SECTION.
* reset the dialogflag
CALL FUNCTION 'DIALOG_SET_WITH_DIALOG'.
ENDIF.
5.2 修改销售订单
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = IS_ZRFC_S_SD042-VBELN
ORDER_HEADER_IN = ORDER_HEADER_IN
ORDER_HEADER_INX = ORDER_HEADER_INX
LOGIC_SWITCH = LOGIC_SWITCH
TABLES
RETURN = ET_LOG
ORDER_ITEM_IN = ORDER_ITEM_IN
ORDER_ITEM_INX = ORDER_ITEM_INX
* partners = partners
PARTNERCHANGES = PARTNERCHANGES
SCHEDULE_LINES = SCHEDULE_LINES
SCHEDULE_LINESX = SCHEDULE_LINESX
ORDER_TEXT = IT_BAPISDTEXT
CONDITIONS_IN = CONDITIONS_IN
CONDITIONS_INX = CONDITIONS_INX.
5.3 显示销售订单
CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
EXPORTING
I_BAPI_VIEW = I_BAPI_VIEW
I_MEMORY_READ = SPACE
TABLES
SALES_DOCUMENTS = IT_SALES_KEY
ORDER_HEADERS_OUT = ORDER_HEADERS_OUT
ORDER_ITEMS_OUT = ORDER_ITEMS_OUT
ORDER_SCHEDULES_OUT = ORDER_SCHEDULES_OUT
ORDER_BUSINESS_OUT = ORDER_BUSINESS_OUT
ORDER_PARTNERS_OUT = ORDER_PARTNERS_OUT
ORDER_ADDRESS_OUT = ORDER_ADDRESS_OUT
ORDER_STATUSHEADERS_OUT = ORDER_STATUSHEADERS_OUT
ORDER_STATUSITEMS_OUT = ORDER_STATUSITEMS_OUT
ORDER_CONDITIONS_OUT = ORDER_CONDITIONS_OUT
ORDER_COND_HEAD = ORDER_COND_HEAD
ORDER_COND_ITEM = ORDER_COND_ITEM
ORDER_COND_QTY_SCALE = ORDER_COND_QTY_SCALE
ORDER_COND_VAL_SCALE = ORDER_COND_VAL_SCALE
ORDER_CONTRACTS_OUT = ORDER_CONTRACTS_OUT
ORDER_TEXTHEADERS_OUT = ORDER_TEXTHEADERS_OUT
ORDER_TEXTLINES_OUT = ORDER_TEXTLINES_OUT
ORDER_FLOWS_OUT = ORDER_FLOWS_OUT
ORDER_BILLINGPLANS_OUT = ORDER_BILLINGPLANS_OUT
ORDER_BILLINGDATES_OUT = ORDER_BILLINGDATES_OUT
ORDER_CREDITCARDS_OUT = ORDER_CREDITCARDS_OUT
EXTENSIONOUT = EXTENSIONOUT.
5.4 销售订单清单,可直接查询表VBAK,VBAP,VBUK,VBUK,VBEP,VBKD,KONV等
5.5 销售凭证审批(VKM1),可用EXPORT,IMPORT方法调用系统标准程序RVKRED01实现
5.5 销售订单在分配(VKM2,VKM3)
CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
CALL FUNCTION 'SD_ORDER_CREDIT_RECHECK'
EXPORTING
flg_update = 'X'
vbeln = it_zrfc_s_sd013-vbeln.
6 显示销售凭证流
CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
EXPORTING
* AUFBEREITUNG = '2'
* BELEGTYP = ' '
COMWA = COMWA
* NACHFOLGER = 'X'
* N_STUFEN = '50'
* VORGAENGER = 'X'
* V_STUFEN = '50'
* IMPORTING
* BELEGTYP_BACK = BELEGTYP_BACK
TABLES
VBFA_TAB = VBFA_TAB
* EXCEPTIONS
* NO_VBFA = 1
* NO_VBUK_FOUND = 2.
7 销售雇员
7.1 创建、修改销售雇员
*可根据实际需求创建试图
CALL FUNCTION 'BAPI_HRMASTER_SAVE_REPL_MULT'
TABLES
HR_OBJECT_HEADER = HR_OBJECT_HEADER
HR_INFOTYPE_HEADER = HR_INFOTYPE_HEADER
EMPLOYEE_PERSONNEL_ACTION = EMPLOYEE_PERSONNEL_ACTION
EMPLOYEE_ORG_ASSIGNMENT = EMPLOYEE_ORG_ASSIGNMENT
EMPLOYEE_PERSONAL_DATA = EMPLOYEE_PERSONAL_DATA
EMPLOYEE_SALES_ORG_ASSIGNMENT = EMPLOYEE_SALES_ORG_ASSIGNMENT
EMPLOYEE_PRIVATE_ADDRESS = EMPLOYEE_PRIVATE_ADDRESS
EMPLOYEE_COMMUNICATIONS = EMPLOYEE_COMMUNICATIONS
EMPLOYEE_PAYROLL_STATUS = EMPLOYEE_PAYROLL_STATUS
RETURN = RETURN.
7.2 显示销售雇员,可直接查询表 PA0001 , PA0002 ,PA0900等
注:以上RFC为项目中实际使用,读者可根据实际情况调整参数即可使用,此贴为长时间积累所得,转载请注明出处!
联系客服