*&---------------------------------------------------------------------*
*& 程序名: ZDQFI_925
*&
*&---------------------------------------------------------------------*
*& 抬头 : 生鲜项目原料消耗发货功能 *
*& 模块 : FI *
*& 作者 : *
*& 创建日期 : 20180301 *
*& 程序类型 : 功能报表 *
*& 消息类 : zmg_fi *
*& 描述 : 生鲜项目原料消耗发货功能 *
*& *
*& 修改记录 : *
*& 日期 修改人 修改内容 *
*& YYYY/MM/DD 修改人员名 说明 *
*&---------------------------------------------------------------------*
REPORT zdqfi_925 MESSAGE-ID . *&---------------------------------------------------------------------*
*& INCLUDE
*&---------------------------------------------------------------------*
INCLUDE zdqfi_925_top. "Type/Data
*INCLUDE zxxxxxxxx_class. "Class
INCLUDE zdqfi_925_selscr. "Selection screen
INCLUDE zdqfi_925_form. "Form
*INCLUDE zxxxxxxxx_module. "Module *&---------------------------------------------------------------------*
*& 初始化处理
*&---------------------------------------------------------------------*
INITIALIZATION.
* PERFORM xxxxxxx. *&---------------------------------------------------------------------*
*& 选择屏幕控制
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
* PERFORM xxxxxxx. *&---------------------------------------------------------------------*
*& 参数输入检查
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
* PERFORM xxxxxxx. *&---------------------------------------------------------------------*
*& 程序开始处理
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM frm_check_run.
PERFORM frm_get_data. "取数,过滤数据 逻辑
PERFORM frm_pro_doc. "处理数据 *&---------------------------------------------------------------------*
*& 程序结束处理
*&---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM frm_alv_data. "alv显示数据
*&---------------------------------------------------------------------*
*& Form frm_check_run
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_check_run .
DATA:ls_zfit1004 TYPE zfit1004. "加锁配置表.
DATA:ls_zruning_lock TYPE zruning_lock. "加锁配置表. IF p_ccl = 'X'.
IF sy-batch = 'X'.
MESSAGE '重处理只能前台手工处理!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
SELECT SINGLE * FROM zfit1004 INTO ls_zfit1004 WHERE usnam = sy-uname.
IF sy-subrc <> .
MESSAGE '请联系产品维护权限!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF. SELECT SINGLE * FROM zruning_lock INTO ls_zruning_lock WHERE zprogram = sy- repid AND flag = 'X'.
IF sy-subrc EQ .
DO.
*加锁
CALL FUNCTION 'ENQUEUE_EZ_ZRUNING_LOCK'
EXPORTING
mode_zruning_lock = 'X'
mandt = sy-mandt
zprogram = sy-repid
_scope = ''
EXCEPTIONS
foreign_lock =
system_failure =
OTHERS = .
IF sy-subrc = .
EXIT.
ELSE.
IF sy-batch = 'X'.
WAIT UP TO SECONDS.
ELSE.
MESSAGE '该程序已有其他用户在运行,请稍候再试!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ENDDO.
ELSE.
MESSAGE '请维护加锁配置表ZRUNING_LOCK!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF. ENDFORM. " frm_check_run
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_get_data .
DATA:
lr_status TYPE RANGE OF zdestatus01,
ls_status LIKE LINE OF lr_status.
DATA: lt_zfit1048 LIKE TABLE OF zfit1048,
ls_zfit1048 LIKE zfit1048.
FIELD-SYMBOLS:
<lf_alv> LIKE LINE OF gt_alv. ls_status() = 'IEQ'.
IF p_ccl = 'X'.
ls_status-low = 'C'.
APPEND ls_status TO lr_status.
ELSE.
ls_status-low = 'E'.
APPEND ls_status TO lr_status.
ls_status-low = ''.
APPEND ls_status TO lr_status.
ENDIF. **取主数据
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_alv
FROM zfit1048
WHERE zdate_js IN s_zdate
AND ajust_date IN s_adate
AND mblnr IN s_mblnr
AND iblnr IN s_iblnr
AND status IN lr_status. SORT gt_alv BY iblnr mblnr.
IF gt_alv[] IS INITIAL.
MESSAGE '查询不到符合条件的数据' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF. **不是重处理时,需先设置C状态,然后释放程序锁
IF p_ccl <> 'X'.
LOOP AT gt_alv ASSIGNING <lf_alv>.
MOVE-CORRESPONDING <lf_alv> TO ls_zfit1048.
ls_zfit1048-status = 'C'.
APPEND ls_zfit1048 TO lt_zfit1048.
ENDLOOP.
MODIFY zfit1048 FROM TABLE lt_zfit1048.
IF sy-subrc = .
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
MESSAGE '更新处理数据C状态到表ZFIT1048失败' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF. PERFORM frm_release_lock. ENDFORM. " frm_get_data
*&---------------------------------------------------------------------*
*& Form frm_pro_doc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_pro_doc .
FIELD-SYMBOLS: <lf_alv> LIKE LINE OF gt_alv.
**定义货物移动(MB11)收货过账的结构和变量
DATA: ls_heade LIKE bapi2017_gm_head_01.
DATA: ls_code LIKE bapi2017_gm_code.
* DATA: ls_testrun LIKE bapi2017_gm_gen-testrun.
DATA: ls_goodsmvt_headret LIKE bapi2017_gm_head_ret.
DATA: ls_materialdocument LIKE bapi2017_gm_head_ret-mat_doc.
DATA: ls_matdocumentyear LIKE bapi2017_gm_head_ret-doc_year.
DATA: ls_goodsmvt_item LIKE bapi2017_gm_item_create,
lt_goodsmvt_item LIKE TABLE OF bapi2017_gm_item_create,
ls_goodsmvt_serialnumber LIKE bapi2017_gm_serialnumber,
lt_goodsmvt_serialnumber LIKE TABLE OF bapi2017_gm_serialnumber,
ls_return LIKE bapiret2 ,
lt_return LIKE TABLE OF bapiret2 .
DATA: lv_xblnr LIKE bkpf-xblnr,
lv_zuonr LIKE bseg-zuonr.
DATA: l_error TYPE c,
l_msg TYPE string.
DATA: ls_bkpf LIKE bkpf,
ls_bseg LIKE bseg,
lv_awkey LIKE bkpf-awkey. **处理数据
LOOP AT gt_alv ASSIGNING <lf_alv>. CLEAR: ls_heade,
ls_goodsmvt_headret,ls_materialdocument, ls_matdocumentyear,
lt_goodsmvt_item, lt_goodsmvt_serialnumber,lt_return.
**s1.抬头赋值:
*凭证日期:调整日期AJUST_DATE
*记账日期:当屏幕输入的BUDAT为空,则取调整日期AJUST_DATE,否则取屏幕输入BUDAT
ls_code-gm_code = ''. "MB11执行货物移 动收货,标准收货
ls_heade-doc_date = <lf_alv>-ajust_date. "凭证日期
IF p_budat IS INITIAL.
ls_heade-pstng_date = <lf_alv>-ajust_date. "记账日期
ELSE.
ls_heade-pstng_date = p_budat.
ENDIF.
ls_heade-pr_uname = sy-uname. "用户名
**is_heade-header_txt = '[ERP2.0]自营库存平台一期'. "抬头文本 **s2.项目赋值:
*商品:取数为存表中的MATNR;
*数量:取数为存表中的DIFMG;
*批次:取数为存表中的CHARG;
*移动类型:需根据DIFMG差异数量判断:
*当DIFMG差异数量不存在‘-’是,R3调用MB11增加库存,移动类型默认为Y52;
*当DIFMG差异数量存在‘-’是,R3调用MB11减少库存,移动类型默认为Y51;
*地点:WERKS 工厂
*库存地点:LGORT 库存地点
ls_goodsmvt_item-material = <lf_alv>-matnr. "商品号
ls_goodsmvt_item-sales_ord = <lf_alv>-difmg. "数量
ls_goodsmvt_item-plant = <lf_alv>-werks. "工厂
ls_goodsmvt_item-move_plant = <lf_alv>-werks. "工厂11/18
ls_goodsmvt_item-stge_loc = <lf_alv>-lgort. "库存地点
ls_goodsmvt_item-move_stloc = <lf_alv>-lgort. "库存地点 /
ls_goodsmvt_item-batch = <lf_alv>-charg. "批号
IF <lf_alv>-difmg > .
ls_goodsmvt_item-move_type = 'Y52'. "移动类型
ELSE.
ls_goodsmvt_item-move_type = 'Y51'.
ENDIF. **s3.细节赋值
*仓储类型:默认为999;
*仓位:默认为999;
*分配:输入MBLNR SIMS MD 单号;
*文本:输入JUST_DATE 调整日期+ ‘确认销售发货成本(盘点)’
*参照:输入IBLNR SIMS MD 单号
ls_goodsmvt_item-entry_uom = <lf_alv>-meins. "单位
ls_goodsmvt_item-stge_type = ''. "仓储类型
ls_goodsmvt_item-stge_bin = ''. "仓位
CONCATENATE <lf_alv>-ajust_date '确认销售发货成本(盘点)' INTO ls_goodsmvt_item-item_text.
APPEND ls_goodsmvt_item TO lt_goodsmvt_item.
CLEAR: ls_goodsmvt_item. ***Export分配和参照,在ZGGBS002替代程序里Import
***去替代商品凭证对应会计凭证分配和参照
MOVE <lf_alv>-iblnr TO lv_xblnr.
MOVE <lf_alv>-mblnr TO lv_zuonr.
EXPORT lv_xblnr TO MEMORY ID 'LV_XBLNR'."抬头参照
EXPORT lv_zuonr TO MEMORY ID 'LV_ZUONR'."行分配 break .
**GR CREATE
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = ls_heade
goodsmvt_code = ls_code
IMPORTING
goodsmvt_headret = ls_goodsmvt_headret
materialdocument = ls_materialdocument
matdocumentyear = ls_matdocumentyear
TABLES
goodsmvt_item = lt_goodsmvt_item
goodsmvt_serialnumber = lt_goodsmvt_serialnumber
return = lt_return. LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.
CONCATENATE l_msg ls_return-message INTO l_msg.
l_error = 'X'.
ENDLOOP. IF l_error = 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
<lf_alv>-status_fh = 'E'.
CONCATENATE '生成商品凭证失败!' l_msg INTO <lf_alv>-message_fh.
ELSE.
* 返回商品凭证号,提交
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
<lf_alv>-status_fh = 'S'.
<lf_alv>-mblnr_fh = ls_materialdocument.
<lf_alv>-message_fh = '生成商品凭证成功!'.
**商品凭证成功,通过MBLNR_FH+年度 取会计凭证
CLEAR: ls_bkpf, ls_bseg, lv_awkey.
CONCATENATE ls_materialdocument ls_matdocumentyear INTO lv_awkey. SELECT SINGLE *
INTO ls_bkpf
FROM bkpf
WHERE awkey = lv_awkey
AND awtyp = 'MKPF'. IF sy-subrc EQ .
SELECT SINGLE *
INTO ls_bseg
FROM bseg
WHERE bukrs = ls_bkpf-bukrs
AND belnr = ls_bkpf-belnr
AND gjahr = ls_bkpf-gjahr
AND hkont = ''.
**会计凭证回写
<lf_alv>-belnr_fh = ls_bkpf-belnr.
<lf_alv>-mjahr = ls_bkpf-gjahr.
<lf_alv>-bukrs3 = ls_bkpf-bukrs.
<lf_alv>-budat_fh = ls_bkpf-budat.
<lf_alv>-cpudt_fh = ls_bkpf-cpudt.
<lf_alv>-dmbtr3 = ls_bseg-dmbtr.
ENDIF. ENDIF. **数据回写zfit1048
UPDATE zfit1048 SET status_fh = <lf_alv>-status_fh
message_fh = <lf_alv>-message_fh
mblnr_fh = <lf_alv>-mblnr_fh
belnr_fh = <lf_alv>-belnr_fh
bukrs3 = <lf_alv>-bukrs3
dmbtr3 = <lf_alv>-dmbtr3
mjahr = <lf_alv>-mjahr
budat_fh = <lf_alv>-budat_fh
cpudt_fh = <lf_alv>-cpudt_fh
* STATUS
WHERE iblnr = <lf_alv>-iblnr
AND gjahr = <lf_alv>-gjahr
AND serialno = <lf_alv>-serialno
AND mblnr = <lf_alv>-mblnr
AND uuid = <lf_alv>-uuid.
IF sy-subrc EQ .
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
<lf_alv>-status_fh = 'E'.
<lf_alv>-message_fh = '商品凭证记账状态更新zfit1048表失败!'.
ENDIF. ENDLOOP. ENDFORM. " frm_pro_doc
*&---------------------------------------------------------------------*
*& Form frm_alv_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_alv_data . IF sy-batch = 'X'.
RETURN.
ENDIF. DEFINE lm_fieldcat.
clear:gs_fcat.
gs_fcat-tabname = 'GT_ALV'.
gs_fcat-fieldname = &.
gs_fcat-scrtext_l = &.
gs_fcat-scrtext_m = &.
gs_fcat-scrtext_s = &.
gs_fcat-no_out = &.
gs_fcat-outputlen = &.
gs_fcat-do_sum = &.
gs_fcat-hotspot = &.
gs_fcat-ref_table = &.
gs_fcat-ref_field = &.
append gs_fcat to gt_fcat.
END-OF-DEFINITION. REFRESH: gt_fcat.
lm_fieldcat:
'IBLNR ' '库存盘点凭证' '' '' '' '' '' '' ,
'MBLNR ' 'SIMS MD单号' '' '' '' '' '' '',
'WERKS ' '工厂 ' '' '' '' '' '' '' ,
'LGORT ' '库存地点' '' '' '' '' '' '' ,
'MATNR ' '商品编码' '' '' '' '' '' '' ,
'MEINS ' '单位' '' '' '' '' '' '' ,
'CHARG ' '批次' '' '' '' '' '' '' ,
'DIFMG ' '差异数量 ' '' '' '' '' '' '' ,
'AJUST_DATE' '调整日期 ' '' '' '' '' '' '' ,
'STATUS_FH ' '商品凭证记账状态' '' '' '' '' '' '' ,
'MESSAGE_FH' '消息 ' '' '' '' '' '' '' ,
'MBLNR_FH ' '商品凭证' '' '' '' '' '' '' ,
'MJAHR ' '凭证年度' '' '' '' '' '' '',
'BELNR_FH ' '会计凭证' '' '' '' '' '' '' . gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
* gs_layout-box_fname = 'SEL'. "可放出最前的选择中方块" CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'FRM_USER_COMMAND'
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fcat
i_save = 'A'
TABLES
t_outtab = gt_alv
EXCEPTIONS
program_error =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " frm_alv_data
*&---------------------------------------------------------------------*
*& Form frm_release_lock
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_release_lock .
CALL FUNCTION 'DEQUEUE_EZ_ZRUNING_LOCK'
EXPORTING
mode_zruning_lock = 'X'
mandt = sy-mandt
zprogram = sy-repid.
ENDFORM. " frm_release_lock

MB11 生鲜项目原料消耗发货功能的更多相关文章

  1. iOS项目开发常用功能静态库

    YHDeveloperTools iOS项目开发常用功能静态库 查看源码 功能方法: 1.字符检查 [NSString checkStringWithType:Email andTargetStrin ...

  2. BBS(第一天)项目之 注册功能实现通过forms验证与 前端ajax请求触发查询数据库判断用户是否存在的功能实现

    1.BBS项目之注册功能通过forms验证 from django import forms from blog.models import User from django.contrib.auth ...

  3. 拥抱微服务,CODING 即将上线单项目多仓库功能

    随着数字化时代的全面到来,越来越多的企业开始尝试物联网.人工智能等新兴技术,用以加快自身的转型速度并积极开拓新的市场.互联网的兴起让各个行业的业务场景.用户行为.交互方式等都发生了巨大的变化.线上业务 ...

  4. python 天天生鲜项目

    python 天天生鲜项目 django版:https://github.com/Ivy-1996/fresh flask版:https://github.com/Ivy-1996/flask-fre ...

  5. DJANGO-天天生鲜项目从0到1-007-首页静态化与缓存

    本项目基于B站UP主‘神奇的老黄’的教学视频‘天天生鲜Django项目’,视频讲的非常好,推荐新手观看学习 https://www.bilibili.com/video/BV1vt41147K8?p= ...

  6. 网站开发学习Python实现-Django的models学习-生鲜项目(6.3.2)

    @ 目录 1.说明 2.模型类的设计 3.代码的具体实现 4.详情地址 关于作者 1.说明 models是django的很重要的部分,所以深入研究. 本文章的所研究项目为黑马教育python课程中的项 ...

  7. web手工项目03-登录功能测试用例及缺陷编写-流程图画法-前后台下单及发货流程图-流程图设计测试用例方法-功能测试涉及到的四种数据库场景

    回顾 注册功能测试(步骤,需求分析(输入分析,处理分析,输出分析),数据构造(有效等价类,无效等价类,有效数据,无效数据),编写用例,执行用例,缺陷报告) 轮播图功能测试(步骤,需求分析拆分测试点,测 ...

  8. DJANGO-天天生鲜项目从0到1-009-购物车-Ajax实现添加至购物车功能

    本项目基于B站UP主‘神奇的老黄’的教学视频‘天天生鲜Django项目’,视频讲的非常好,推荐新手观看学习 https://www.bilibili.com/video/BV1vt41147K8?p= ...

  9. DJANGO-天天生鲜项目从0到1-009-搜索功能实现(django-haystack+whoosh+jieba)

    本项目基于B站UP主‘神奇的老黄’的教学视频‘天天生鲜Django项目’,视频讲的非常好,推荐新手观看学习 https://www.bilibili.com/video/BV1vt41147K8?p= ...

随机推荐

  1. url参数

    两个参数情况: String url="http://59.78.93.208:9097/Order?id="+id+"&value="+value; ...

  2. deepin linux 15.3安装完eclipse启动报错An error has occurred.

    原因是系统中安装了jdk9 导致的. 卸载jdk9就可以了 $ java -version Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings ...

  3. 绕过云盾找真实IP-找真实IP-绕过CDN

    目标站:www.chinaparkview.cn 云盾挡着了 查一下历史IP 查出3月9号的IP是103.249.104.114 当然查出来的不一定准确 修改本地host文件 PS:不要加http 然 ...

  4. OpenERP report doesn't work

    1. When you have used OpenOffice edited  one of reports,it has stored the report's banary data is da ...

  5. libubox-uloop

    参考:libubox组件(3)——uloop uloop是提供事件驱动机制接口,类似libevent事件框架,基于epoll接口来实现的. uloop三大功能:事件管理(uloop_fd).超时管理( ...

  6. 【BZOJ】3397: [Usaco2009 Feb]Surround the Islands 环岛篱笆(tarjan)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3397 显然先tarjan缩点,然后从枚举每一个scc,然后向其它岛屿连费用最小的边,然后算最小的即可 ...

  7. Torch-RNN运行过程中的坑 [1](读取Lua非空table,size为0)

    0.踩坑背景 执行Torch-RNN的时候,在LanguageModel.lua中的encode_string函数中,对start_text的各个character进行id映射编码,实现功能类似“北京 ...

  8. js创建form添加input项目并提交表单

    var generateHideElement = function (name, value) { var tempInput = document.createElement("inpu ...

  9. Pat(Advanced Level)Practice--1026(Table Tennis)

    Pat1026代码 题目描写叙述: A table tennis club has N tables available to the public. The tables are numbered ...

  10. poj 3275(传递闭包)

    题目链接:http://poj.org/problem?id=3275 思路:对于n个节点,共有n*(n-1)/2对关系,对于给出的m对已经确定的关系,我们可以用传递闭包推出目前已经确定的关系对数an ...