其他分享
首页 > 其他分享> > HU_CREATE_GOODS_MOVEMENT HU转储过账

HU_CREATE_GOODS_MOVEMENT HU转储过账

作者:互联网

在调用这个HU_CREATE_GOODS_MOVEMENT  bapi做转储的时候总是出现意想不到的问题,将解决方案记录下来,以供参考。

1.在做循环调用bapi的时候,需要清除输入和输出的数据,不然当第二次循环的时候,只产生一个凭证,第二次也不报错,也不生成凭证。

  源代码中输出表中有数据会EXIT退出。(一位不知名大佬debug找的)

 

2.报这个" 不能执行功能模块 MB_CREATE_GOOS_MOBEMENT "错误时,在第生成了第一个凭证时,除了需要调用以下函数清除数据

    CALL FUNCTION 'HU_PACKING_REFRESH'.
    CALL FUNCTION 'SERIAL_INTTAB_REFRESH'.
    CALL FUNCTION 'L_SAPLL03A_INIT_INT'.

还需要在第一个凭证产生后进行提交COMMIT WORK AND WAIT.

 

3.系统程序:/ISDFPS/STOCK_CHANGE_WERKS_LGO   可以参考这个程序写代码

 

提取业务中的主要代码:

data: begin of gt_itab occuse 0,
    werks type UMWRK,
    lgort type UMLGO,
    matnr type UMMAT,
    maktx type maktx,
    bestq type BESTQ,         "库存类别
    bestq_txt type val_text,  "库存类别描述
    charg type UMCHA,       "批号
    lgnum type LGNUM,         "仓库号
    lgtyp type lgtyp,       "仓储类型
    LGPLA TYPE LGPLA,       "仓位
    lenum type lenum ,      "仓储单位编号/hu
    letyp type lvs_letyp, "hu类型
    verme type lqua_verme,  "可用库存
    meins type MSEHI,       "meins
    MSEH3 TYPE MSEH3,
    wdatu type lvs_wdatu,   "收货日期
    sobkz type sobkz,       "特殊库存标识
    SONUM TYPE LVS_SONUM,   "特殊库存编号
    MBLNR TYPE MBLNR,       "物料凭证编号
    MSGV1 TYPE  SYMSGV,     "错误信息
 end of strut.

data:if_event type  huwbevent,
      is_imkpf  type  imkpf,
      it_move_to     type hum_data_move_to_t,
      is_move_to     type hum_data_move_to,
      it_internal_id  type HUM_VENUM_T WITH HEADER LINE,
*      it_external_id  type HUM_EXIDV,
      it_external_id  type HUM_EXIDV_T WITH HEADER LINE,
      es_emkpf  type  emkpf,
      es_message  TYPE  huitem_messages,
      et_messages TYPE HUITEM_MESSAGES_T,
      ls_messages type HUITEM_MESSAGES,
      ef_posted type  sysubrc.

*进行循环调用 loop at gt_itab1.
  clear:it_external_id[],it_move_to,is_imkpf,es_emkpf,ef_posted,es_message,et_messages.  "非常重要
   clear:ls_vepo,ls_vekp,ls_hu_items. CLEAR:is_move_to,ls_hu_items,it_external_id. SELECT SINGLE * FROM vekp INTO ls_vekp WHERE exidv = gt_itab1-lenum. it_external_id-exidv = ls_vekp-exidv. APPEND IT_EXTERNAL_ID. SELECT * FROM vepo INTO ls_vepo WHERE venum = ls_vekp-venum. * create header data IF sy-dbcnt = 1. is_move_to-huwbevent = if_event. is_move_to-matnr = gt_itab1-matnr. is_move_to-charg = gt_itab1-charg. is_move_to-werks = gt_itab1-werks. is_move_to-lgort = gt_itab1-lgort. is_move_to-bestq = gt_itab1-bestq. is_move_to-lgnum = gt_itab1-lgnum. is_move_to-sobkz = gt_itab1-sobkz. is_move_to-sobkz = gt_itab1-sonum. * is_move_to-bwart = '349'. ENDIF. * create item data ls_hu_items-venum = ls_vepo-venum. ls_hu_items-vepos = ls_vepo-vepos. APPEND ls_hu_items TO is_move_to-hu_items. ENDSELECT. APPEND is_move_to to it_move_to. ENDLOOP. CALL FUNCTION 'HU_PACKING_REFRESH'. CALL FUNCTION 'SERIAL_INTTAB_REFRESH'. CALL FUNCTION 'L_SAPLL03A_INIT_INT'. CALL FUNCTION 'HU_CREATE_GOODS_MOVEMENT' EXPORTING IF_EVENT = IF_EVENT * IF_SIMULATE = ' ' * IF_COMMIT = 'X' IF_TCODE = 'HUMO' "HUMO IS_IMKPF = IS_IMKPF IT_MOVE_TO = It_MOVE_TO * IT_INTERNAL_ID = IT_EXTERNAL_ID = IT_EXTERNAL_ID[] IMPORTING EF_POSTED = ef_posted ES_MESSAGE = es_message ET_MESSAGES = et_messages ES_EMKPF = es_emkpf. * if es_message-msgty = 'i' or es_message-msgty = 'e'. IF NOT ef_posted = 1. ROLLBACK WORK. CALL FUNCTION 'HU_PACKING_REFRESH'. CALL FUNCTION 'SERIAL_INTTAB_REFRESH'. ELSEif es_emkpf-mblnr <> ''. COMMIT WORK AND WAIT. ENDLOOP. ENDIF.

 

标签:FUNCTION,gt,itab1,move,转储,HU,过账,ls,type
来源: https://www.cnblogs.com/freeandeasy/p/14069754.html