首页 > 其他分享 >HU打包BAPI:内部给号 更新交货单

HU打包BAPI:内部给号 更新交货单

时间:2022-10-14 18:07:33浏览次数:68  
标签:BAPI goods return sy HU lw lt 交货单 TYPE


其他相关资料可点击:

​HU相关配置​

​HU打包 内外部给号 前台操作​


代码

输入参数:内向交货单号

*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(INB_VBELN) TYPE VBELN
*" TABLES
*" ET_CREATED_HUS STRUCTURE BAPIHUIDENTIFICATION OPTIONAL
*" RETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------
TYPE-POOLS: pdt.

DATA: lv_vbeln TYPE vbeln.

DATA: lv_error TYPE c,
lw_return TYPE bapiret2.

DATA: lw_koko TYPE vbkok,
lw_kopo TYPE vbpok,
lt_prot TYPE TABLE OF prott,
lw_prott TYPE prott,
lt_kopo TYPE TABLE OF vbpok,
lt_vsek TYPE TABLE OF verko,
lt_vsep TYPE TABLE OF verpo,
lv_pupd TYPE c.

DATA: lw_goods TYPE packgood,
lt_goods TYPE pdt_packgoods,
lw_object TYPE pdt_object,
lv_profile TYPE pdt_profile,
lv_application TYPE pdt_application.

DATA: lt_packitems TYPE pdt_packitems,
lt_packqty TYPE pdt_t_packqty,
lx_hus TYPE pdt_hus,
lt_hu_messages TYPE huitem_messages_t,
lv_objectkey TYPE pdt_objkey,
lv_packresult TYPE pdt_autopackresult.

DATA: lw_likp TYPE likp,
lw_lips TYPE lips,
lt_lips TYPE TABLE OF lips.

DATA: lv_vpobjkey TYPE vpobjkey,
ls_huhdr_proposal TYPE huhdr_proposal,
lw_huitm_prop TYPE huitm_proposal.

DATA: lw_vbkok TYPE vbkok,
lt_verpo TYPE TABLE OF verpo,
ls_verpo TYPE verpo,
lt_verko TYPE TABLE OF verko,
ls_verko TYPE verko,
lw_created_hus TYPE vekpvb,
lt_created_hus TYPE TABLE OF vekpvb,
lw_inb_hu TYPE bapihuidentification.

date:ls_likp type likp. FIELD-SYMBOLS TYPE huitm_proposal.

IF inb_vbeln IS NOT INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = inb_vbeln
IMPORTING
output = lv_vbeln.
*&------------------------------------------------------------------
* Auto Packing
*&------------------------------------------------------------------
REFRESH: lt_packitems, lt_goods, lt_packqty, lt_hu_messages.
CLEAR: lv_packresult, lv_objectkey, lw_object,lx_hus.
SELECT * INTO TABLE lt_lips FROM lips WHERE vbeln = lv_vbeln.
select single * from likp into ls_likp vbeln = lv_vbeln..
IF sy-subrc <> 0.
CLEAR: lw_return.
lw_return-id = 'VL'.
lw_return-type = 'E'.
lw_return-number = '331'.
APPEND lw_return TO return.
EXIT.
ENDIF.
LOOP AT lt_lips INTO lw_lips.
CLEAR: lw_goods.
lw_goods-matnr = lw_lips-matnr.
lw_goods-kunag = lw_likp-kunag.
lw_goods-kunwe = lw_likp-kunnr.
lw_goods-vkorg = lw_likp-vkorg.
lw_goods-vtweg = lw_lips-vtweg.
lw_goods-spart = lw_lips-spart.
lw_goods-kunnr = lw_likp-kunnr.
lw_goods-ablad = lw_likp-ablad.
lw_goods-abrvw = lw_lips-abrvw.
lw_goods-route = lw_likp-route.
lw_goods-vstel = lw_likp-vstel.
lw_goods-versart = lw_likp-vsart.
lw_goods-werks = lw_lips-werks.
lw_goods-lgort = lw_lips-lgort.
lw_goods-charg = lw_lips-charg. lw_goods-lifnr = ls_likp-lifnr. "可能涉及到 HU 数量选择的优先级
SELECT SINGLE xchpf INTO lw_goods-xchpf
FROM marc
WHERE matnr = lw_goods-matnr
AND werks = lw_goods-werks.
IF lw_goods-xchpf = 'X'.
* IF lw_goods-charg IS INITIAL.
* lw_goods-charg = '9999999999'.
* ENDIF.
ENDIF.
lw_goods-maxqua = lw_lips-lfimg.
lw_goods-qunit_a = lw_lips-vrkme.
APPEND lw_goods TO lt_goods.
ENDLOOP.

lw_object-objtype = '03'.
lw_object-objkey = inb_vbeln.
lv_application = '1'.
* Assign packinstruction
CALL FUNCTION 'VHUPILE_ASSIGN_PACKINSTRUCTION'
EXPORTING
application = lv_application
object = lw_object
profile = '0001'
* PDPARA = PDPARA
packgoods = lt_goods
* DIALOG_FLAG = DIALOG_FLAG
IMPORTING
packitems = lt_packitems
t_packqty = lt_packqty
return_code = lv_packresult
EXCEPTIONS
failure = 1
profile_not_found = 2
profile_wrong = 3
creation_failed = 4
no_packgood_found = 5
packinstr_deleted = 6
packinstr_not_found = 7
OTHERS = 8.
IF sy-subrc <> 0.
CLEAR lw_return.
lw_return-id = sy-msgid.
lw_return-type = sy-msgty.
lw_return-number = sy-msgno.
lw_return-message_v1 = sy-msgv1.
lw_return-message_v2 = sy-msgv2.
lw_return-message_v3 = sy-msgv3.
lw_return-message_v4 = sy-msgv4.
PERFORM frm_build_msgtext CHANGING lw_return.
IF lw_return IS NOT INITIAL.
APPEND lw_return TO return.
ENDIF.
EXIT.
ENDIF.
**------------------------------------------
* get proposals
**------------------------------------------
CALL FUNCTION 'VHUPILE_CREATE_HU_PROPOSALS'
EXPORTING
application = lv_application
object = lw_object
profile = '0001'
* PDPARA = PDPARA
packitems = lt_packitems
IMPORTING
s_mmdata = lx_hus-s_mmdata
t_hd_prp = lx_hus-t_hd_prp
t_hd_cap = lx_hus-t_hd_cap
t_hd_add = lx_hus-t_hd_add
t_hd_tra = lx_hus-t_hd_tra
t_items = lx_hus-t_items
t_srlnr = lx_hus-t_srlnr
EXCEPTIONS
failure = 1
profile_not_found = 2
profile_wrong = 3
creation_failed = 4
no_packgood_found = 5
packinstr_deleted = 6
packinstr_not_found = 7
OTHERS = 8.
IF sy-subrc <> 0.
CLEAR lw_return.
lw_return-id = sy-msgid.
lw_return-type = sy-msgty.
lw_return-number = sy-msgno.
lw_return-message_v1 = sy-msgv1.
lw_return-message_v2 = sy-msgv2.
lw_return-message_v3 = sy-msgv3.
lw_return-message_v4 = sy-msgv4.
PERFORM frm_build_msgtext CHANGING lw_return.
IF lw_return IS NOT INITIAL.
APPEND lw_return TO return.
ENDIF.
EXIT.
ENDIF.

*...To clear the memory before calling WS_UPDATE_DELIVERY..........
CALL FUNCTION 'HU_PACKING_REFRESH'.

* General Header
CLEAR: lw_vbkok.
lw_vbkok-vbeln = lw_object-objkey.
lw_vbkok-vbeln_vl = lw_object-objkey.
lw_vbkok-vbtyp_vl = '7'. "Inbound Delivery

* Items
SORT lt_lips BY matnr.
LOOP AT lx_hus-t_items ASSIGNING .
READ TABLE lt_lips INTO lw_lips WITH KEY matnr = -matnr BINARY SEARCH.
IF sy-subrc = 0.
-belnr = lw_lips-vbeln.
-posnr = lw_lips-posnr.
ENDIF.
ENDLOOP.
REFRESH: lt_verpo.
LOOP AT lx_hus-t_items[] INTO lw_huitm_prop.
CLEAR: ls_verpo.
MOVE lw_huitm_prop-matnr TO ls_verpo-matnr.
MOVE lw_huitm_prop-velin TO ls_verpo-velin .
MOVE lw_huitm_prop-exidv TO ls_verpo-exidv_ob .
MOVE lw_huitm_prop-lgort TO ls_verpo-lgort.
MOVE lw_huitm_prop-belnr TO ls_verpo-rfbel.
MOVE lw_huitm_prop-belnr TO ls_verpo-vbeln.
MOVE lw_huitm_prop-posnr TO ls_verpo-rfpos.
MOVE lw_huitm_prop-posnr TO ls_verpo-posnr .
MOVE lw_huitm_prop-quantity TO ls_verpo-tmeng.
MOVE lw_huitm_prop-werks TO ls_verpo-werks.
MOVE lw_huitm_prop-charg TO ls_verpo-charg.
MOVE lw_huitm_prop-meins TO ls_verpo-vrkme.
APPEND ls_verpo TO lt_verpo.
ENDLOOP.

* Header
REFRESH: lt_verko.
LOOP AT lx_hus-t_hd_prp[] INTO ls_huhdr_proposal.
CLEAR: ls_verko.
MOVE-CORRESPONDING ls_huhdr_proposal TO ls_verko.
APPEND ls_verko TO lt_verko.
ENDLOOP.
REFRESH: lt_prot[], lt_created_hus[].
CLEAR: lv_error.
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
vbkok_wa = lw_vbkok
synchron = 'X'
commit = 'X'
delivery = lw_vbkok-vbeln
nicht_sperren = space
if_no_generic_system_service = 'X'
TABLES
verko_tab = lt_verko
verpo_tab = lt_verpo
prot = lt_prot
et_created_hus = lt_created_hus
EXCEPTIONS
communication_failure = 1
system_failure = 2.
IF sy-subrc <> 0.
lv_error = 'X'.
ENDIF.

IF lt_prot IS NOT INITIAL.
LOOP AT lt_prot INTO lw_prott WHERE msgno IS NOT INITIAL.
ENDLOOP.
IF sy-subrc = 0.
lv_error = 'X'.
ENDIF.
ENDIF.

IF lv_error = 'X'.
CLEAR lw_return.
lw_return-id = sy-msgid.
lw_return-type = sy-msgty.
lw_return-number = sy-msgno.
lw_return-message_v1 = sy-msgv1.
lw_return-message_v2 = sy-msgv2.
lw_return-message_v3 = sy-msgv3.
lw_return-message_v4 = sy-msgv4.
PERFORM frm_build_msgtext CHANGING lw_return.
IF lw_return IS NOT INITIAL.
APPEND lw_return TO return.
ENDIF.
ROLLBACK WORK.
EXIT.
ELSE.
COMMIT WORK AND WAIT.
LOOP AT lt_created_hus INTO lw_created_hus.
CLEAR: lw_inb_hu.
lw_inb_hu-hu_id = lw_created_hus-venum.
lw_inb_hu-hu_exid = lw_created_hus-exidv.
APPEND lw_inb_hu TO et_created_hus.
ENDLOOP.
ENDIF.
ENDIF.


HU打包BAPI:内部给号 更新交货单_ide



标签:BAPI,goods,return,sy,HU,lw,lt,交货单,TYPE
From: https://blog.51cto.com/u_15680210/5757657

相关文章

  • 外向交货单屏幕增强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_......
  • HU_CREATE_GOODS_MOVEMENT报错:对象清单抬头数据中的差异
    对于已经创建HU的物料,调用HU_CREATE_GOODS_MOVEMENT 创建凭证的时候遇到了下面的问题情景是这样:先对ct00工厂的数据进行了bapi调用commit后又对CT20工厂数据进行操作这个......
  • BAPI_GOODSMVT_CREATE 带序列号
     API_GOODSMVT_CREATE物料移动,比如MB1B'343'"unblock'344'"block参考代码*&BAPIDATA:goodsmvt_headerLIKEbapi2017_gm_head_01,goodsmvt_codeLIKE......
  • 获取成本中心层级BAPI_COSTCENTERGROUP_GETDETAIL
    T-CODE:OKEON可以查看成本中心层级如果你查找对应的表,会查找到  SETHEADER和对应的SETHEADERT文本表对照数据可能发下问题应该还有别的判断条件,其他字段这里也不继续看......
  • 使用hutool工具查询树形结构数据
    1.导入hutool工具的jar包<dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.7.22</version>......
  • 前端成神之路-WebAPIs07
    07-WebAPIs学习目标:能够写出移动端触屏事件能够写出常见的移动端特效能够使用移动端开发插件开发移动端特效能够使用移动端开发框架开发移动端特效能够写出sessio......
  • .net6 WebApi 之 Configuration
    .net6WebApi使用Configuration获取appsettings.json中的内容,用法如下:appsettings.json中的内容{"Logging":{"LogLevel":{"Default":"Informati......
  • github加速访问常规方法
    1、某场的网游加速器,uu163.com下载安装后,登录,搜索学术,点击加速即可,简单快速,套用B站Up的话,不用了要关掉,让给有需要的人。2、steam++,WattToolkit-瓦特工具箱(Steam++官......
  • 【杂谈】超过12个,150页深度学习开源框架指导手册与GitHub项目,初学CV你值得拥有...
    之前我们公众号输出了很多深度学习开源框架相关的内容,今天整理成技术手册给大家分享以方便阅读,下面是详细信息。开源框架背景现如今开源生态非常完善,深度学习相关的开源框架......
  • pikachu(文件包含)
    1.php中文件包含主要有以下四种函数:require(),找不到被包含的文件时会产生致命错误,并停止脚本运行。include(),找不到被包含的文件时只会产生警告,脚本将继续运行。include_o......