利用APIFOX对ABAP函数进行调用
1.安装APIFOX,当然也可以使用在线版,无需下载
官网地址:https://apifox.com/

2.新建项目

3.为项目起一个名称,为相关开发测试人员授权

4.在根目录新增子目录

5.编辑开发/测试/生产环境的地址信息以及默认全局变量

6.将SAP提供的ABAPAPI地址配置进APIFOX,有关ABAP提供的服务地址,请参考文章:
1.ABAP 功能模块的 JSON 适配器
2.RESTFUL方式

7.与前一篇文章有所不同的是,本次在ABAP类中增加了更新模块,如图,请见代码:

8.在APIFOX新建好服务URL后,可以在根目录设置用户密码,这样后面子节点就可以继承根目录的用户配置

9.新建调用接口[本例是SAP函数:BAPI_ACC_DOCUMENT_POST]
9.1在BODY页签,现在json格式,输入测试的报文

{
"documentheader": {
"obj_type": "",
"obj_key": "",
"obj_sys": "",
"bus_act": "",
"username": "CHENHUI",
"header_txt": "抬头文本",
"comp_code": "1710",
"doc_date": "2023-06-02",
"pstng_date": "2023-06-02",
"trans_date": "0000-00-00",
"fisc_year": 2023,
"fis_period": 6,
"doc_type": "SA",
"ref_doc_no": "参照字段",
"ac_doc_no": "",
"obj_key_r": "",
"reason_rev": "",
"compo_acc": "",
"ref_doc_no_long": "",
"acc_principle": "",
"neg_postng": "",
"obj_key_inv": "",
"bill_category": "",
"vatdate": "0000-00-00",
"invoice_rec_date": "0000-00-00",
"ecs_env": "",
"partial_rev": "",
"doc_status": ""
},
"customercpd": {
"name": "",
"name_2": "",
"name_3": "",
"name_4": "",
"postl_code": "",
"city": "",
"country": "",
"country_iso": "",
"street": "",
"po_box": "",
"pobx_pcd": "",
"pobk_curac": "",
"bank_acct": "",
"bank_no": "",
"bank_ctry": "",
"bank_ctry_iso": "",
"tax_no_1": "",
"tax_no_2": "",
"tax": "",
"equal_tax": "",
"region": "",
"ctrl_key": "",
"instr_key": "",
"dme_ind": "",
"langu_iso": "",
"iban": "",
"swift_code": "",
"tax_no_3": "",
"tax_no_4": "",
"title": "",
"tax_no_5": ""
},
"contractheader": {
"doc_no": "",
"doc_type_ca": "",
"res_key": "",
"fikey": "",
"payment_form_ref": ""
},
"accountgl": [
{
"itemno_acc": 1,
"gl_account": "0012121000",
"item_text": "",
"stat_con": "",
"log_proc": "",
"ac_doc_no": "",
"ref_key_1": "",
"ref_key_2": "",
"ref_key_3": "",
"acct_key": "",
"acct_type": "",
"doc_type": "",
"comp_code": "",
"bus_area": "",
"func_area": "",
"plant": "",
"fis_period": 0,
"fisc_year": 0,
"pstng_date": "0000-00-00",
"value_date": "2023-06-02",
"fm_area": "",
"customer": "",
"cshdis_ind": "",
"vendor_no": "",
"alloc_nmbr": "",
"tax_code": "",
"taxjurcode": "",
"ext_object_id": "",
"bus_scenario": "",
"costobject": "",
"costcenter": "",
"acttype": "",
"profit_ctr": "",
"part_prctr": "",
"network": "",
"wbs_element": "",
"orderid": "",
"order_itno": 0,
"routing_no": 0,
"activity": "",
"cond_type": "",
"cond_count": 0,
"cond_st_no": 0,
"fund": "",
"funds_ctr": "",
"cmmt_item": "",
"co_busproc": "",
"asset_no": "",
"sub_number": "",
"bill_type": "",
"sales_ord": "",
"s_ord_item": 0,
"distr_chan": "",
"division": "",
"salesorg": "",
"sales_grp": "",
"sales_off": "",
"sold_to": "",
"de_cre_ind": "",
"p_el_prctr": "",
"xmfrw": "",
"quantity": 0,
"base_uom": "",
"base_uom_iso": "",
"inv_qty": 0,
"inv_qty_su": 0,
"sales_unit": "",
"sales_unit_iso": "",
"po_pr_qnt": 0,
"po_pr_uom": "",
"po_pr_uom_iso": "",
"entry_qnt": 0,
"entry_uom": "",
"entry_uom_iso": "",
"volume": 0,
"volumeunit": "",
"volumeunit_iso": "",
"gross_wt": 0,
"net_weight": 0,
"unit_of_wt": "",
"unit_of_wt_iso": "",
"item_cat": "",
"material": "",
"matl_type": "",
"mvt_ind": "",
"reval_ind": "",
"orig_group": "",
"orig_mat": "",
"serial_no": 0,
"part_acct": "",
"tr_part_ba": "",
"trade_id": "",
"val_area": "",
"val_type": "",
"asval_date": "0000-00-00",
"po_number": "",
"po_item": 0,
"itm_number": 0,
"cond_category": "",
"func_area_long": "",
"cmmt_item_long": "",
"grant_nbr": "",
"cs_trans_t": "",
"measure": "",
"segment": "",
"partner_segment": "",
"res_doc": "",
"res_item": 0,
"billing_period_start_date": "0000-00-00",
"billing_period_end_date": "0000-00-00",
"ppa_ex_ind": "",
"fastpay": "",
"partner_grant_nbr": "",
"budget_period": "",
"partner_budget_period": "",
"partner_fund": "",
"itemno_tax": 0,
"payment_type": "",
"expense_type": "",
"program_profile": "",
"material_long": "",
"housebankid": "",
"housebankacctid": "",
"person_no": 0,
"acrobj_type": "",
"acrobj_id": "",
"acrsubobj_id": "",
"acritem_type": "",
"valobjtype": "",
"valobj_id": "",
"valsubobj_id": ""
},
{
"itemno_acc": 2,
"gl_account": "0012401100",
"item_text": "",
"stat_con": "",
"log_proc": "",
"ac_doc_no": "",
"ref_key_1": "",
"ref_key_2": "",
"ref_key_3": "",
"acct_key": "",
"acct_type": "",
"doc_type": "",
"comp_code": "",
"bus_area": "",
"func_area": "",
"plant": "",
"fis_period": 0,
"fisc_year": 0,
"pstng_date": "0000-00-00",
"value_date": "2023-06-02",
"fm_area": "",
"customer": "",
"cshdis_ind": "",
"vendor_no": "",
"alloc_nmbr": "",
"tax_code": "",
"taxjurcode": "",
"ext_object_id": "",
"bus_scenario": "",
"costobject": "",
"costcenter": "",
"acttype": "",
"profit_ctr": "",
"part_prctr": "",
"network": "",
"wbs_element": "",
"orderid": "",
"order_itno": 0,
"routing_no": 0,
"activity": "",
"cond_type": "",
"cond_count": 0,
"cond_st_no": 0,
"fund": "",
"funds_ctr": "",
"cmmt_item": "",
"co_busproc": "",
"asset_no": "",
"sub_number": "",
"bill_type": "",
"sales_ord": "",
"s_ord_item": 0,
"distr_chan": "",
"division": "",
"salesorg": "",
"sales_grp": "",
"sales_off": "",
"sold_to": "",
"de_cre_ind": "",
"p_el_prctr": "",
"xmfrw": "",
"quantity": 0,
"base_uom": "",
"base_uom_iso": "",
"inv_qty": 0,
"inv_qty_su": 0,
"sales_unit": "",
"sales_unit_iso": "",
"po_pr_qnt": 0,
"po_pr_uom": "",
"po_pr_uom_iso": "",
"entry_qnt": 0,
"entry_uom": "",
"entry_uom_iso": "",
"volume": 0,
"volumeunit": "",
"volumeunit_iso": "",
"gross_wt": 0,
"net_weight": 0,
"unit_of_wt": "",
"unit_of_wt_iso": "",
"item_cat": "",
"material": "",
"matl_type": "",
"mvt_ind": "",
"reval_ind": "",
"orig_group": "",
"orig_mat": "",
"serial_no": 0,
"part_acct": "",
"tr_part_ba": "",
"trade_id": "",
"val_area": "",
"val_type": "",
"asval_date": "0000-00-00",
"po_number": "",
"po_item": 0,
"itm_number": 0,
"cond_category": "",
"func_area_long": "",
"cmmt_item_long": "",
"grant_nbr": "",
"cs_trans_t": "",
"measure": "",
"segment": "",
"partner_segment": "",
"res_doc": "",
"res_item": 0,
"billing_period_start_date": "0000-00-00",
"billing_period_end_date": "0000-00-00",
"ppa_ex_ind": "",
"fastpay": "",
"partner_grant_nbr": "",
"budget_period": "",
"partner_budget_period": "",
"partner_fund": "",
"itemno_tax": 0,
"payment_type": "",
"expense_type": "",
"program_profile": "",
"material_long": "",
"housebankid": "",
"housebankacctid": "",
"person_no": 0,
"acrobj_type": "",
"acrobj_id": "",
"acrsubobj_id": "",
"acritem_type": "",
"valobjtype": "",
"valobj_id": "",
"valsubobj_id": ""
}
],
"accountreceivable": [],
"accountpayable": [],
"accounttax": [],
"currencyamount": [
{
"itemno_acc": 1,
"curr_type": "00",
"currency": "CNY",
"currency_iso": "",
"amt_doccur": 100.0000,
"exch_rate": 0,
"exch_rate_v": 0,
"amt_base": 0,
"disc_base": 0,
"disc_amt": 0,
"tax_amt": 0,
"amt_doccur_long": 0,
"amt_base_long": 0,
"disc_base_long": 0,
"disc_amt_long": 0,
"tax_amt_long": 0
},
{
"itemno_acc": 2,
"curr_type": "00",
"currency": "CNY",
"currency_iso": "",
"amt_doccur": -100.0000,
"exch_rate": 0,
"exch_rate_v": 0,
"amt_base": 0,
"disc_base": 0,
"disc_amt": 0,
"tax_amt": 0,
"amt_doccur_long": 0,
"amt_base_long": 0,
"disc_base_long": 0,
"disc_amt_long": 0,
"tax_amt_long": 0
}
],
"criteria": [],
"valuefield": [],
"extension1": [],
"return": [],
"paymentcard": [],
"contractitem": [],
"extension2": [
{
"structure": "ZSENBSEG",
"valuepart1": "000000000140 字段一 字段二 字段三 字段四 字段五",
"valuepart2": "",
"valuepart3": "",
"valuepart4": ""
},
{
"structure": "ZSENBSEG",
"valuepart1": "000000000250 字段一 字段二 字段三 字段四 字段五",
"valuepart2": "",
"valuepart3": "",
"valuepart4": ""
}
],
"realestate": [],
"accountwt": []
}
测试的报文是由ABAP测试生成而来:

*&---------------------------------------------------------------------*
*& Report Z3426008A
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z3426008a.
DATA:ls_header TYPE bapiache09,
lv_key TYPE bapiache09-obj_key,
lv_msg TYPE string,
ls_struct TYPE zsenbseg,
lv_posnr TYPE i.
DATA:lt_gl TYPE bapiacgl09 OCCURS 0 WITH HEADER LINE,
lt_cr TYPE bapiaccr09 OCCURS 0 WITH HEADER LINE,
lt_ex TYPE bapiparex OCCURS 0 WITH HEADER LINE,
lt_rt TYPE bapiret2 OCCURS 0 WITH HEADER LINE. *参考会计凭证 100000006 F011 2021
ls_header-header_txt = '抬头文本'.
ls_header-comp_code = '1710'.
ls_header-doc_type = 'SA'.
*ls_header-obj_type = 'BKPF'.
ls_header-username = sy-uname.
ls_header-doc_date = sy-datum.
ls_header-pstng_date = sy-datum.
ls_header-fisc_year = sy-datum+0(4).
ls_header-fis_period = sy-datum+4(2).
ls_header-ref_doc_no = '参照字段'. lv_posnr = lv_posnr + 1.
lt_gl-itemno_acc = lv_posnr.
lt_gl-gl_account = '0012121000'.
lt_gl-value_date = sy-datum.
APPEND lt_gl. lt_cr-itemno_acc = lv_posnr. " 会计凭证行项目编号
lt_cr-curr_type = '00'. " 货币和评估视图
lt_cr-currency = 'CNY'. " 货币码
lt_cr-amt_doccur = '100'.
APPEND lt_cr. ls_struct-posnr = lv_posnr.
ls_struct-bschl = '40'.
ls_struct-rstgr = ''.
ls_struct-zzfield1 = '字段一'.
ls_struct-zzfield2 = '字段二'.
ls_struct-zzfield3 = '字段三'.
ls_struct-zzfield4 = '字段四'.
ls_struct-zzfield5 = '字段五'.
lt_ex-structure = 'ZSENBSEG'.
lt_ex-valuepart1 = ls_struct.
APPEND lt_ex. lv_posnr = lv_posnr + 1.
lt_gl-itemno_acc = lv_posnr.
lt_gl-gl_account = '0012401100'.
lt_gl-value_date = sy-datum.
APPEND lt_gl. lt_cr-itemno_acc = lv_posnr. " 会计凭证行项目编号
lt_cr-curr_type = '00'. " 货币和评估视图
lt_cr-currency = 'CNY'. " 货币码
lt_cr-amt_doccur = '-100'.
APPEND lt_cr. ls_struct-posnr = lv_posnr.
ls_struct-bschl = '50'.
ls_struct-rstgr = ''.
ls_struct-zzfield1 = '字段一'.
ls_struct-zzfield2 = '字段二'.
ls_struct-zzfield3 = '字段三'.
ls_struct-zzfield4 = '字段四'.
ls_struct-zzfield5 = '字段五'.
lt_ex-structure = 'ZSENBSEG'.
lt_ex-valuepart1 = ls_struct.
APPEND lt_ex. DATA:BEGIN OF ls_request,
documentheader LIKE bapiache09,
customercpd LIKE bapiacpa09,
contractheader LIKE bapiaccahd,
accountgl LIKE TABLE OF bapiacgl09,
accountreceivable LIKE TABLE OF bapiacar09,
accountpayable LIKE TABLE OF bapiacap09,
accounttax LIKE TABLE OF bapiactx09,
currencyamount LIKE TABLE OF bapiaccr09,
criteria LIKE TABLE OF bapiackec9,
valuefield LIKE TABLE OF bapiackev9,
extension1 LIKE TABLE OF bapiacextc,
return LIKE TABLE OF bapiret2,
paymentcard LIKE TABLE OF bapiacpc09,
contractitem LIKE TABLE OF bapiaccait,
extension2 LIKE TABLE OF bapiparex,
realestate LIKE TABLE OF bapiacre09,
accountwt LIKE TABLE OF bapiacwt09,
END OF ls_request. DATA:BEGIN OF ls_response,
obj_type LIKE bapiache09-obj_type,
obj_key LIKE bapiache09-obj_key,
obj_sys LIKE bapiache09-obj_sys,
accountgl LIKE TABLE OF bapiacgl09,
accountreceivable LIKE TABLE OF bapiacar09,
accountpayable LIKE TABLE OF bapiacap09,
accounttax LIKE TABLE OF bapiactx09,
currencyamount LIKE TABLE OF bapiaccr09,
criteria LIKE TABLE OF bapiackec9,
valuefield LIKE TABLE OF bapiackev9,
extension1 LIKE TABLE OF bapiacextc,
return LIKE TABLE OF bapiret2,
paymentcard LIKE TABLE OF bapiacpc09,
contractitem LIKE TABLE OF bapiaccait,
extension2 LIKE TABLE OF bapiparex,
realestate LIKE TABLE OF bapiacre09,
accountwt LIKE TABLE OF bapiacwt09,
END OF ls_response. ls_request-documentheader = ls_header.
ls_request-accountgl[] = lt_gl[].
ls_request-currencyamount[] = lt_cr[].
ls_request-extension2[] = lt_ex[]. DATA:lv_fname TYPE string,
lv_request TYPE string,
lv_response TYPE string. lv_fname = `BAPI_ACC_DOCUMENT_POST`.
lv_request = /ui2/cl_json=>serialize( data = ls_request compress = abap_false pretty_name = 'L' ).
PERFORM frm_call_function USING lv_fname lv_request CHANGING lv_response.
/ui2/cl_json=>deserialize( EXPORTING json = lv_response pretty_name = 'X' CHANGING data = ls_response ). FORM frm_call_function USING iv_fname TYPE string
iv_request TYPE string
CHANGING ov_response TYPE string.
DATA:lv_url TYPE string,
lv_hostname TYPE string,
lv_port TYPE string. CALL FUNCTION 'TH_GET_VIRT_HOST_DATA'
EXPORTING
protocol = 0
virt_idx = 0
IMPORTING
hostname = lv_hostname
port = lv_port. lv_url = 'http://' && lv_hostname && ':' && lv_port && '/abapapi/' && iv_fname.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = DATA(lo_http_client)
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4. lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.
lo_http_client->authenticate( EXPORTING username = CONV string( 'HTTP_USER' ) password = CONV string( '123qazQAZ' ) ).
"lo_http_client->request->set_content_type( content_type = 'application/json; charset=utf-8' ).
lo_http_client->request->set_method( if_http_request=>co_request_method_post ).
lo_http_client->request->set_header_field( name = if_http_header_fields=>content_type value = 'application/json; charset=utf-8' ).
lo_http_client->request->set_cdata( data = iv_request offset = 0 length = strlen( iv_request ) ).
lo_http_client->send( EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 ).
lo_http_client->receive( EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 ).
lo_http_client->get_last_error( IMPORTING message = DATA(lv_message) code = DATA(lv_code) ).
ov_response = lo_http_client->response->get_cdata( ).
lo_http_client->close( ).
ENDFORM.
9.2在header页签输入参数:Commit,值为X,目的是提交数据

9.3,在左上角切换环境进行发送测试,如有COOKie干扰测试,可以删除COOKie,点击发送并保存

10已经成功生成会计凭证

11.进到SAP系统,使用事务码FB03查看该会计凭证

12.同理也可以调用其他SAP提供的函数或者自开发的函数
13.点击左下角的“文档模式”,切换编辑模式,将测试的报文进行修改,按项目要求生成对方能够理解的接口定义书

14.点击修改文档页签,点击“JSON/XML智能识别、快捷导入”按钮,将测试报文粘贴后,会自动转成测试的结构对象,按转义将项目要求的字段和字段描述加上,用不上的字段可以保留或者剔除

15.如果网络涉及到代理和证书,点击右上角设置按钮,可以配置代理和证书


利用APIFOX对ABAP函数进行调用的更多相关文章
- 利用backtrace和backtrace_symbols函数打印调用栈信息
在头文件"execinfo.h"中声明了三个函数用于获取当前线程的函数调用堆栈. #include <execinfo.h> int backtrace(void * ...
- python利用or在列表解析中调用多个函数.py
python利用or在列表解析中调用多个函数.py """ python利用or在列表解析中调用多个函数.py 2016年3月15日 05:08:42 codegay & ...
- C++利用模板在Windows上快速调用DLL函数
更新日志 --------- 2021/08/01 更新V2.2 增加 GetHmodule 函数 - 允许用户获取HMODULE以验证加载DLL是否成功. 2021/08/03 更新V2.3 增加 ...
- Direct3D Draw函数 异步调用原理解析
概述 在D3D10中,一个基本的渲染流程可分为以下步骤: 清理帧缓存: 执行若干次的绘制: 通过Device API创建所需Buffer: 通过Map/Unmap填充数据到Buffer中: 将Buff ...
- ABAP程序相互调用--SUBMIT
(1) 调用其他程序: * Trigger the IDOC SUBMIT zpcppmd001_idoc AND RETURN. (2) 调用其他程序参数传递参数: *当被调用的程序的屏幕有输入参数 ...
- 驱动:中断【2】中断处理程序、中断上下文中处理延时及一些函数的调用规则(调IIC中断驱动有感)
中断处理程序.中断上下文中处理延时及一些函数的调用规则(调IIC中断驱动有感)http://blog.csdn.net/samantha_sun/article/details/6790492 1,中 ...
- Python函数的定义、参数传入与函数的调用
作为计算机代码的一种抽象方式,函数在Python中扮演了极为重要的角色.今天给大家介绍Python函数的定义.参数的传入以及调用方式.其中函数参数的传入方式为本节重点内容.Python函数的参数形式包 ...
- Python基础(函数,函数的定义,函数的调用,函数的参数,递归函数)
1.函数 我们知道圆的面积计算公式为: S = πr2 当我们知道半径r的值时,就可以根据公式计算出面积.假设我们需要计算3个不同大小的圆的面积: r1 = 12.34 r2 = 9.08 r3 = ...
- 利用PHP的debug_backtrace函数,实现PHP文件权限管理、动态加载
简述 可能大家都知道,php中有一个函数叫debug_backtrace,它可以回溯跟踪函数的调用信息,可以说是一个调试利器. 好,来复习一下 01 one(); 02 03 function one ...
- (转)利用PHP的debug_backtrace函数,实现PHP文件权限管理、动态加载 【反射】
原文地址:http://www.cnblogs.com/melonblog/archive/2013/05/09/3062303.html 原文作者:豆浆油条 - melon 本文示例代码测试环境是W ...
随机推荐
- 基于Vue 使用threejs导入gltf动画模型
被老师要求学习这个完全不懂的领域的知识,代码东拼西凑终于搞定了,可能写的不好,但这方面的教程很少 某CS**平台的教程都是互相抄,看着烦死. <template> <div id=& ...
- ArcGIS模型构建器ModelBuilder的使用方法
本文介绍在ArcMap软件中,基于模型构建器(ModelBuilder)完成模型建立与使用的具体方法. 首先,在ArcMap软件中打开"ModelBuilder". 建 ...
- 中英文拼写检测纠正开源项目使用入门 word-checker 1.1.0
项目简介 word-checker 本项目用于单词拼写检查.支持英文单词拼写检测,和中文拼写检测. 特性说明 可以迅速判断当前单词是否拼写错误 可以返回最佳匹配结果 可以返回纠正匹配列表,支持指定返回 ...
- Bootstrapd导航条使用
要想在程序中集成Bootstrap,显然要对模板做所有必要的改动.不过,更简单的方法是使用一个名为Flask-Bootstrap 的Flask 扩展,简化集成的过程. 安装:Flask-Bootstr ...
- [智能制造] 如何利用生产软件(MES)进行生产信息收集?
1 如何保证生产管理软件所收集信息的准确性? 1.1 当前制造企业使用MES系统收集信息的现状 原以为使用了MES生产管理系统后,会得到稽核员的肯定. 但没想到,在实际的稽核过程中,稽核员还是发现目前 ...
- 5.根据uid获取用户所有收货地址信息和设置默认地址
1.总结:昨天主要是实现了根据uid获取该用户的所有收货地址以及设置默认地址:再对默认地址的实现里面让我认识到它的具体操作,首先我们根据aid查询收货地址 再根据收货地址查询到地址归属人的信息,判断u ...
- 四月六号java基础学习
四月六号 1.今天学习了JAVA语言特点,有以下几个特点: 1)简单易学:相对于C/c++语言,java语言省去了指针(pointer).联合体(Unions)以及结构体(struct) 2)面向对象 ...
- okio中数据存储的基本单位Segment
1.Segment是Buffer缓冲区存储数据的基本单位,每个Segment能存储的最大字节是8192也就是8k的数据 /** The size of all segments in bytes. * ...
- windows安装zabbix错误代码
zabbix安装:windows安装zabbix客户端很多坑,设计到很多问题,常见的问题有安装完成防火墙没有关闭,zabbix服务端接收不到客户端的信息.zabbix在cmd中安装的时候报错误代码,安 ...
- JMeter-BeanShell预处理程序和BeanShell后置处理程序的应用
一.什么是BeanShell? BeanShell是用Java写成的,一个小型的.免费的.可以下载的.嵌入式的Java源代码解释器,JMeter性能测试工具也充分接纳了BeanShell解释器,封装成 ...