利用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 ...
随机推荐
- 用Java代码验证三门问题
三门问题(Monty Hall problem)亦称为蒙提霍尔问题,出自美国的电视游戏节目Let's Make a Deal. 问题名字来自该节目的主持人蒙提·霍尔(Monty Hall).参赛者会看 ...
- linux中查看用户和组信息小结
查看当前登录用户的组内成员groups 查看当前登录用户名whoami 查看tom用户所在的组,以及组内成员groups tom 查看所有的用户信息cat /etc/passwd 用户名.密码.用户i ...
- 网页静态化技术 Freemarker
网页静态化解决方案在实际运用中比较多,例如新闻网站,门户网站中的新闻频道或者是文章类的频道.对于电商网站的商品详细页(几百万的商品,同样的页面模板格局)来说,每个商品又有大量的信息,这样的情况同样也适 ...
- Spring Data Solr 对 Solr 的增删改查实例
Spring Data Solr 就是为了方便 solr 的开发研制的一个框架,其底层是对 SolrJ(官方 API)的封装 一.环境搭建 第一步:创建 Maven 项目(springdatasolr ...
- SpringBoot——自定义start
更多内容,前往 IT-BLOG 一.Mybatis 实现 start 的原理 首先在写一个自定义的 start 之前,我们先参考下 Mybatis 是如何整合 SpringBoot:mybatis-s ...
- CPU内部的奥秘:代码是如何被执行的?
我们是袋鼠云数栈 UED 团队,致力于打造优秀的一站式数据中台产品.我们始终保持工匠精神,探索前端道路,为社区积累并传播经验价值. 本文作者:景明 我们以一段 C 代码为例,来看一下代码被编译成二进制 ...
- CTFSHOW-Reverse-刷题记录
re2 打开初步分析为32位程序,无壳,拖入IDA32分析 找到关键行47-50,分析得出各函数内部的基本作用如图所示 首先进入分析输入后的处理 可以很明显看出,是对输入的字符串进行处理后再操作,因此 ...
- Android APP开机启动,安卓APP开发自启动,安卓启动后APP自动启动 Android让程序开机自动运行APP 全开源下载
让APP在安卓系统启动自动运行可以带来以下几个好处:用户方便:当用户打开设备时,自动启动所需的APP可以让用户更方便地使用设备,不必手动打开APP.提高用户黏性:自动启动APP可以让用户更快地开始使用 ...
- 「刷起来」Go必看的进阶面试题详解
勤学如春起之苗,不见其增日有所长:辍学如磨刀之石,不见其损日有所亏. 本文的重点:逃逸分析.延迟语句.散列表.通道.接口. 1.逃逸分析 逃逸分析是Go语言中的一项重要优化技术,可以帮助程序减少内存分 ...
- Semantic Kernel 入门系列:🔥Kernel 内核和🧂Skills 技能
理解了LLM的作用之后,如何才能构造出与LLM相结合的应用程序呢? 首先我们需要把LLM AI的能力和原生代码的能力区分开来,在Semantic Kernel(以下简称SK),LLM的能力称为 sem ...