首页 > 其他分享 >增强Demo 03 销售订单屏幕增强后BAPI增强

增强Demo 03 销售订单屏幕增强后BAPI增强

时间:2022-10-14 19:07:47浏览次数:53  
标签:03 增强 inx partners Demo lt ls extensionin order


干货:

前面两篇文章分别介绍了销售订单抬头和行项目上屏幕增强的案例。

增强Demo 03 销售订单屏幕增强后BAPI增强_ico

增强Demo 03 销售订单屏幕增强后BAPI增强_ico_02

屏幕上增加了俩字段,那BAPI创建修改的时候怎么处理?

怎么把增强字段值写进去?


使用BAPI的EXTENSIONIN参数

增强Demo 03 销售订单屏幕增强后BAPI增强_ico_03

可以增强的表有VBAP VBAK VBEP

Adjust the following structures for customer enhancements to table VBAP:
a) VBAPKOZ
b) VBAPKOZX
c) BAPE_VBAP
d) BAPE_VBAPX
If you need to use custom fields for VBAK you must adjust the following structures for customer enhancements to table VBAK:
a) VBAKKOZ
b) VBAKKOZX
c) BAPE_VBAK
d) BAPE_VBAKX
If you need to use custom fields for VBEP you must adjust the following structures for customer enhancements to table VBEP:
a) VBEPKOZ
b) VBEPKOZX
c) BAPE_VBEP
d) BAPE_VBEPX


告知了如果要使用bapi做增强的话,需要增强的表和结构


接着上次的案例,增强了VBAK VBAP,所以还需要维护另外的八个结构


item:

增强Demo 03 销售订单屏幕增强后BAPI增强_ico_04

增强Demo 03 销售订单屏幕增强后BAPI增强_字段_05

增强Demo 03 销售订单屏幕增强后BAPI增强_ico_06

增强Demo 03 销售订单屏幕增强后BAPI增强_字段_07

Header:

增强Demo 03 销售订单屏幕增强后BAPI增强_字段_08

增强Demo 03 销售订单屏幕增强后BAPI增强_ico_09

增强Demo 03 销售订单屏幕增强后BAPI增强_赋值_10

增强Demo 03 销售订单屏幕增强后BAPI增强_赋值_11

然后BAPI参考如下

REPORT  zlm_create_so.


PARAMETERS p_kunnr TYPE kunnr DEFAULT '1001'.
PARAMETERS p_vkorg TYPE vkorg DEFAULT '1000'.
PARAMETERS p_vtweg TYPE vtweg DEFAULT '12'.
PARAMETERS p_spart TYPE spart DEFAULT '00'.
PARAMETERS p_werks TYPE werks_d DEFAULT '1200'.
PARAMETERS p_lgort TYPE lgort_d DEFAULT ' '.
PARAMETERS p_vstel TYPE vstel DEFAULT '1200'.
PARAMETERS p_matnr TYPE matnr DEFAULT 'L-40F'.
DATA:ls_order_header_in LIKE bapisdhd1.
DATA:ls_order_header_inx LIKE bapisdhd1x.
DATA:lt_order_items_in LIKE TABLE OF bapisditm.
DATA:lt_order_items_inx LIKE TABLE OF bapisditmx.
DATA:ls_order_items_in LIKE bapisditm.
DATA:ls_order_items_inx LIKE bapisditmx.
DATA:lt_order_partners LIKE TABLE OF bapiparnr.
DATA:ls_order_partners LIKE LINE OF lt_order_partners.
DATA:lt_schedules_in LIKE TABLE OF bapischdl .
DATA:lt_schedules_inx LIKE TABLE OF bapischdlx .
DATA:ls_schedules_in LIKE bapischdl .
DATA:ls_schedules_inx LIKE bapischdlx .
DATA:lt_order_conditions_in LIKE TABLE OF bapicond .
DATA:lt_order_conditions_inx LIKE TABLE OF bapicondx .
DATA:ls_order_conditions_in LIKE bapicond .
DATA:ls_order_conditions_inx LIKE bapicondx .
DATA: lt_return LIKE TABLE OF bapiret2.
DATA: ls_return LIKE bapiret2.
DATA:lv_salesdocument LIKE bapivbeln-vbeln.


DATA:ls_bape_vbap TYPE bape_vbap,
ls_bape_vbapx TYPE bape_vbapx.
DATA:ls_bape_vbakx TYPE bape_vbakx.
DATA:ls_bape_vbak TYPE bape_vbak.

DATA:lt_extensionin LIKE TABLE OF bapiparex.
DATA:ls_extensionin LIKE bapiparex.

CLEAR ls_order_header_in.
ls_order_header_in-doc_type = 'TA'."订单类型
ls_order_header_in-sales_org = p_vkorg.
ls_order_header_in-distr_chan = p_vtweg."分销渠道
ls_order_header_in-division = p_spart."产品组
ls_order_header_in-purch_no_c = 'test'.
CLEAR ls_order_header_inx.
ls_order_header_inx-doc_type = 'X'.
ls_order_header_inx-sales_org = 'X'.
ls_order_header_inx-distr_chan = 'X'.
ls_order_header_inx-division = 'X'.
*ls_order_header_inx-sales_off = 'X'.
ls_order_header_inx-ass_number = 'X'.
ls_order_header_inx-updateflag = '1'.
ls_order_header_inx-purch_no_c = 'X'.
CLEAR ls_order_items_in.
CLEAR lt_order_items_in[].
ls_order_items_in-itm_number = '10'."只有一个行项目
ls_order_items_in-material = p_matnr.
ls_order_items_in-plant = p_werks.
ls_order_items_in-store_loc = p_lgort.
ls_order_items_in-target_qty = 1.
ls_order_items_in-ship_point = p_vstel."装运点
ls_order_items_in-target_qu = 'KAR'.
ls_order_items_in-sales_unit = 'KAR'.
APPEND ls_order_items_in TO lt_order_items_in.
CLEAR lt_schedules_in[].
CLEAR ls_schedules_in.
ls_schedules_in-itm_number = '10'."只有一个行项目
ls_schedules_in-req_qty = 1.
APPEND ls_schedules_in TO lt_schedules_in.
CLEAR ls_schedules_inx.
CLEAR lt_schedules_inx[].
ls_schedules_inx-updateflag = 'X'.
ls_schedules_inx-itm_number = 'X'.
ls_schedules_inx-req_qty = 'X'.
APPEND ls_schedules_inx TO lt_schedules_inx.
"售达方默认
CLEAR ls_order_partners.
ls_order_partners-partn_role = 'AG'.
ls_order_partners-partn_numb = p_kunnr.
APPEND ls_order_partners TO lt_order_partners.


"送达方
CLEAR ls_order_partners.
ls_order_partners-partn_role = 'WE'.
ls_order_partners-partn_numb = p_kunnr.
APPEND ls_order_partners TO lt_order_partners.

"付款方
CLEAR ls_order_partners.
ls_order_partners-partn_role = 'RE'.
ls_order_partners-partn_numb = p_kunnr.
APPEND ls_order_partners TO lt_order_partners.
"收票方
CLEAR ls_order_partners.
ls_order_partners-partn_role = 'RG'.
ls_order_partners-partn_numb = p_kunnr.
APPEND ls_order_partners TO lt_order_partners.




*&------------------------针对 增强字段的赋值------------------------------
CLEAR ls_extensionin.
CLEAR lt_extensionin[].


*& header 增强字段赋值
ls_bape_vbak-zlm_comment = 'ZLM_COMMENT'.
ls_extensionin-structure = 'BAPE_VBAK'.

CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = ls_bape_vbak
IMPORTING
ex_container = ls_extensionin-valuepart1.

APPEND ls_extensionin TO lt_extensionin.
CLEAR ls_extensionin.

ls_bape_vbakx-zlm_comment = 'X'.
ls_extensionin-structure = 'BAPE_VBAKX'.
ls_extensionin-valuepart1 = ls_bape_vbakx.

APPEND ls_extensionin TO lt_extensionin.
CLEAR ls_extensionin.

*& item 增强字段赋值

ls_bape_vbap-vbeln = space.
ls_bape_vbap-posnr = '000010'.
ls_bape_vbap-item_comment = 'ITEM_COMMENT'.
ls_extensionin-structure = 'BAPE_VBAP'.

CALL METHOD cl_abap_container_utilities=>fill_container_c
EXPORTING
im_value = ls_bape_vbap
IMPORTING
ex_container = ls_extensionin-valuepart1.

APPEND ls_extensionin TO lt_extensionin.

CLEAR ls_extensionin.
ls_bape_vbapx-vbeln = space.
ls_bape_vbapx-posnr = '000010'.
ls_bape_vbapx-item_comment = 'X'.
ls_extensionin-structure = 'BAPE_VBAPX'.
ls_extensionin-valuepart1 = ls_bape_vbapx.
APPEND ls_extensionin TO lt_extensionin.


*&------------------------*&------------------------*&------------------------

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = ls_order_header_in
order_header_inx = ls_order_header_inx
IMPORTING
salesdocument = lv_salesdocument
TABLES
return = lt_return
order_items_in = lt_order_items_in
order_items_inx = lt_order_items_inx
order_partners = lt_order_partners
order_schedules_in = lt_schedules_in
order_schedules_inx = lt_schedules_inx
extensionin = lt_extensionin.
IF lv_salesdocument IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
WRITE lv_salesdocument

标签:03,增强,inx,partners,Demo,lt,ls,extensionin,order
From: https://blog.51cto.com/u_15680210/5757802

相关文章

  • 增强Demo 02 销售订单屏幕增强-item 增强
    干货:首先append一个字段然后激活。之前写Header屏幕增强的时候,其实已经提到过增强的方法了。Header使用的BADI,当然还可以使用对应的itemBADI来实现这个需求。这里介绍下......
  • PR PO 根据控制条件自动勾选或取消勾选 收货标记增强
    ​PRPO有部分需求,根据条件判断PRPO保存时收货标记是否打叉。这里简单说下增强位置。PR位置:BADI: ME_PROCESS_REQ_CUST核心代码  DATA: G_ITEM_DATA     TYPE ......
  • VF01 开票增强
    ​VF01VF04开票的时候,可以调整价格条件的金额。增强位置:RV61AFZBuserexit_xkomv_bewerten_end修改开票过程中销售凭证和会计凭证金额XKOMV[]TKOMV[]如果这里调整不了,可以......
  • DEMO: 获取交货单未开票数量
    VL03N查看交货单交货数量为5,单位是CAR查看已经开票凭证流:直接看表VBFA开票84单位EA冲销76单位EA已开84-76=8EA而咱们看交货单的时候,交货单单位CAR.单位转换:交货......
  • 出口增强应用:强制邮箱大写
    货铺QQ群号:834508274进群统一修改群名片,例如BJ_ABAP_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合不修改昵称会被不定期踢除,谢谢配合前段时间解决......
  • Scratch 03:编写Hello World
    作为IT行业来说,一般第一个程序都是HelloWorld:HelloWorld中文意思是『你好,世界』。因为《TheCProgrammingLanguage》中使用它做为第一个演示程序,非常著名,所以后来的......
  • .Net Core redis 调用报错 '6000 Redis requests per hour' 解决 6000 此调用限制
    问题描述redis是一种基于内存,性能高效的NoSQL数据库,性能高主要就体现在数据交互耗时较短,能够段时快速的对用户的请求做出反应,所以在业务比较复杂或交互量需求大时,必然......
  • 外向交货单屏幕增强BADI:LE_SHP_TAB_CUST_OVER
    外向交货单屏幕增强1、涉及tcode:VL01N  Vl02N VL03N2、效果图3、后台增强点4、增强点,BADI:LE_SHP_TAB_CUST_OVER5、具体方法介绍:1)ACTIVATE_TAB_PAGE2)TRANSFER_DATA_TO_......
  • VA01 销售订单 审批 状态 增强
    需求:在使用事务代码VA01创建销售订单时,在点击保存按钮后,根据销售组织(VBAK-VKORG)及订单类型(VBAK-AUART)读取自定义表,如果自定义表有值且“自动审批”标识为“X”则自动将该订......
  • Demo:cl_salv_table ALV 弹出框
    效果图:代码REPORTZLM_001.DATA:go_alvTYPEREFTOcl_salv_table,go_funlstTYPEREFTOcl_salv_functions_list.DATA:gt_dataTYPESTANDARDTABLEOFspfli......