Copy Rounting (BAPI:BAPI_ROUTING_CREATE)

Copy Rounting (BAPI:BAPI_ROUTING_CREATE)FORMfrm_uploadUSINGvalue(ps_i_tabindex)LIKEsy-tabixvalue(pc_i_fieldname)TYPEslis_fieldnameCHANGING

大家好,又见面了,我是你们的朋友全栈君。

FORM frm_upload USING value(ps_i_tabindex) LIKE sy-tabix
                                value(pc_i_fieldname) TYPE slis_fieldname
                            CHANGING
                                 value(l_subrc) LIKE sy-subrc
                                 value(l_msgtx) TYPE msgtx.
  CLEAR:l_subrc,l_msgtx,g_lines.

  DATA:
        l_lines         LIKE sy-tabix,
        l_testrun       TYPE bapiflag VALUE space,
        l_group         TYPE  bapi1012_tsk_c-task_list_group,
        l_groupcounter  TYPE  bapi1012_tsk_c-group_counter.

  TYPES:BEGIN OF ty_routing_tbl,
    plnty LIKE ckmlmv001-plnty_nd,
    plnnr LIKE ckmlmv001-plnnr_nd,
    plnal LIKE ckmlmv001-plnal_nd,
  END OF ty_routing_tbl.
  DATA:
        ls_routing_tbl TYPE ty_routing_tbl,
        le_routing_tbl TYPE STANDARD TABLE OF ty_routing_tbl.
  DATA:
        lt_tsk_tab    LIKE STANDARD TABLE OF capp_tsk WITH HEADER LINE,
        lt_seq_tab    LIKE STANDARD TABLE OF capp_seq WITH HEADER LINE,
        lt_opr_tab    LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
        lt_phase_tab  LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
        lt_subopr_tab	LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
        lt_rel_tab    LIKE STANDARD TABLE OF capp_rel WITH HEADER LINE,
        lt_com_tab    LIKE STANDARD TABLE OF capp_com WITH HEADER LINE,
        lt_referr_tab	LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
        lt_refmis_tab	LIKE STANDARD TABLE OF capp_opr WITH HEADER LINE,
        lt_it_aenr    LIKE STANDARD TABLE OF aenr WITH HEADER LINE.
  DATA:
        lt_task	                  LIKE STANDARD TABLE OF bapi1012_tsk_c WITH HEADER LINE,
        lt_materialtaskallocation	LIKE STANDARD TABLE OF bapi1012_mtk_c WITH HEADER LINE,
        lt_sequence	              LIKE STANDARD TABLE OF bapi1012_seq_c WITH HEADER LINE,
        lt_operation              LIKE STANDARD TABLE OF bapi1012_opr_c WITH HEADER LINE,
        lt_suboperation	          LIKE STANDARD TABLE OF bapi1012_sub_opr_c WITH HEADER LINE,
        lt_referenceoperation	    LIKE STANDARD TABLE OF bapi1012_ref_opr_c WITH HEADER LINE,
        lt_workcenterreference    LIKE STANDARD TABLE OF bapi1012_wc_ref_opr_c WITH HEADER LINE,
        lt_componentallocation    LIKE STANDARD TABLE OF bapi1012_com_c WITH HEADER LINE,
        lt_productionresource	    LIKE STANDARD TABLE OF bapi1012_prt_c WITH HEADER LINE,
        lt_inspcharacteristic	    LIKE STANDARD TABLE OF bapi1012_cha_c WITH HEADER LINE,
        lt_textallocation	        LIKE STANDARD TABLE OF bapi1012_txt_hdr_c WITH HEADER LINE,
        lt_text	                  LIKE STANDARD TABLE OF bapi1012_txt_c WITH HEADER LINE,
        lt_return	                LIKE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
  DATA:
        ls_return LIKE bapiret2,
        ls_crhd  LIKE crhd.
  FIELD-SYMBOLS:<f_list> LIKE LINE OF gt_list.

  l_lines = lines( gt_list ).

  LOOP AT gt_list ASSIGNING <f_list> WHERE sel = 'X'.
    g_tabix = sy-tabix.

    CALL FUNCTION 'ZFM_SHOW_PROGRESSBAR'
      EXPORTING
        text      = 'Creating Routing...'
        curr_num  = g_tabix
        total_num = l_lines.

    CALL FUNCTION 'CKBA_ROUTING_GET_LIST'
      EXPORTING
        i_matnr       = <f_list>-matnr
        i_werks       = <f_list>-werks
      IMPORTING
        e_routing_tbl = le_routing_tbl
      EXCEPTIONS
        no_values     = 1
        OTHERS        = 2.
    IF sy-subrc <> 0.
      CONTINUE.
    ENDIF.

    LOOP AT le_routing_tbl INTO ls_routing_tbl.
      REFRESH:
      lt_tsk_tab,
      lt_seq_tab,
      lt_opr_tab,
      lt_phase_tab,
      lt_subopr_tab,
      lt_rel_tab,
      lt_com_tab,
      lt_referr_tab,
      lt_refmis_tab,
      lt_it_aenr.

      REFRESH:
      lt_task,
      lt_materialtaskallocation,
      lt_sequence,
      lt_operation,
      lt_suboperation,
      lt_referenceoperation,
      lt_workcenterreference,
      lt_componentallocation,
      lt_productionresource,
      lt_inspcharacteristic,
      lt_textallocation,
      lt_text,
      lt_return.

      CALL FUNCTION 'CARO_ROUTING_READ'
        EXPORTING
          plnty       = ls_routing_tbl-plnty
          plnnr       = ls_routing_tbl-plnnr
          plnal       = ls_routing_tbl-plnal
        TABLES
          tsk_tab     = lt_tsk_tab
          seq_tab     = lt_seq_tab
          opr_tab     = lt_opr_tab
          phase_tab   = lt_phase_tab
          subopr_tab  = lt_subopr_tab
          rel_tab     = lt_rel_tab
          com_tab     = lt_com_tab
          referr_tab  = lt_referr_tab
          refmis_tab  = lt_refmis_tab
          it_aenr     = lt_it_aenr
        EXCEPTIONS
          not_found   = 1
          ref_not_exp = 2
          not_valid   = 3
          OTHERS      = 4.
      IF sy-subrc <> 0.
        CONTINUE.
      ENDIF.

      "Fill Header -  lt_task
      LOOP AT lt_tsk_tab.
        CLEAR lt_task.
        "lt_task-task_list_group   = ''.                 "Key for Task List Group
        lt_task-task_list_usage   = lt_tsk_tab-verwe.   "Task list usage
        lt_task-task_list_status  = lt_tsk_tab-statu.   "Status
        lt_task-task_measure_unit = lt_tsk_tab-plnme.
        lt_task-description       = lt_tsk_tab-ktext.
        lt_task-plant             = lt_tsk_tab-werks.
        lt_task-valid_from        = lt_tsk_tab-datuv.
        lt_task-valid_to_date     = lt_tsk_tab-datub.
        APPEND lt_task.
      ENDLOOP.

      "Fill lt_materialtaskallocation
      CLEAR lt_materialtaskallocation.
      lt_materialtaskallocation-material      = <f_list>-matnr_n.
      lt_materialtaskallocation-plant         = <f_list>-werks.
      lt_materialtaskallocation-valid_from    = lt_tsk_tab-datuv.
      lt_materialtaskallocation-valid_to_date = lt_tsk_tab-datub.
      APPEND lt_materialtaskallocation.

      "Fill lt_operation
      LOOP AT lt_opr_tab.
        CLEAR lt_operation.
        lt_operation-activity       = lt_opr_tab-vornr.   "操作/活动编号/Operation/Activity Number
        lt_operation-control_key    = lt_opr_tab-steus.   "控制码/Control key
        lt_operation-description    = lt_opr_tab-ltxa1.   "工序短文本
        lt_operation-plant          = lt_opr_tab-werks.   "工厂
        lt_operation-denominator    = lt_opr_tab-umren.   "用于转换工艺路线和工序单位的分母
        lt_operation-nominator      = lt_opr_tab-umrez.   "用于转换任务清单和工序计量单位的计数器
        lt_operation-base_quantity  = lt_opr_tab-bmsch.   "基本数量
        lt_operation-acttype_01     = lt_opr_tab-lar01.
        lt_operation-std_unit_01    = lt_opr_tab-vge01.
        lt_operation-std_value_01   = lt_opr_tab-vgw01.
        lt_operation-acttype_02     = lt_opr_tab-lar02.
        lt_operation-std_unit_02    = lt_opr_tab-vge02.
        lt_operation-std_value_02   = lt_opr_tab-vgw02.
        lt_operation-acttype_03     = lt_opr_tab-lar03.
        lt_operation-std_unit_03    = lt_opr_tab-vge03.
        lt_operation-std_value_03   = lt_opr_tab-vgw03.
        lt_operation-valid_from     = lt_opr_tab-datuv.
        lt_operation-valid_to_date  = lt_opr_tab-datub.
        lt_operation-cost_relevant  = lt_opr_tab-ckselkz.

        "Work center
        CLEAR ls_crhd.
        CALL FUNCTION 'CR_WORKSTATION_READ'
          EXPORTING
            id        = lt_opr_tab-arbid
          IMPORTING
            ecrhd     = ls_crhd
          EXCEPTIONS
            not_found = 1
            OTHERS    = 2.
        IF sy-subrc = 0.
          lt_operation-work_cntr = ls_crhd-arbpl. "工作中心
        ENDIF.
        APPEND lt_operation.
      ENDLOOP.

      CALL FUNCTION 'BAPI_ROUTING_CREATE'
        EXPORTING
          testrun                = l_testrun
        IMPORTING
          group                  = l_group
          groupcounter           = l_groupcounter
        TABLES
          task                   = lt_task
          materialtaskallocation = lt_materialtaskallocation
          sequence               = lt_sequence
          operation              = lt_operation
          return                 = lt_return.

      READ TABLE lt_return WITH KEY type = 'E'.
      IF sy-subrc <> 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = ls_return.
        IF ls_return-type = 'E'.

        ENDIF.
        CONCATENATE <f_list>-msgtx l_group '/' l_groupcounter ';' INTO <f_list>-msgtx.
        CONDENSE <f_list>-msgtx NO-GAPS.
        IF <f_list>-icon <> icon_led_red.
          <f_list>-werks_n = <f_list>-werks.
          <f_list>-icon = icon_led_green.
        ENDIF.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
          IMPORTING
            return = ls_return.
        CONCATENATE <f_list>-msgtx l_group 'Error;' INTO <f_list>-msgtx.
        CONDENSE <f_list>-msgtx NO-GAPS.
        <f_list>-icon = icon_led_red.
      ENDIF.
    ENDLOOP.
  ENDLOOP.

  l_msgtx = 'Conversion is complete'.
ENDFORM.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/163909.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 从零开始的 Android 开发[通俗易懂]

    从零开始的 Android 开发[通俗易懂]文章目录0、简介0.1个人情况0.2现状0.3展望0.4一些问题(IDE/编程语言)0.5更新日志0、简介0.1个人情况先说一说自己的情况吧。某985大学的本科学生,因为对Android开发感兴趣,所以先学习了Java(教材是《疯狂Java讲义》,这本书非常好),之后又开始按照郭霖先生的《第一行代码(第二版)》学习Android开发。《疯狂…

  • vim中翻页的命令

    vim中翻页的命令整页翻页ctrl-fctrl-bf就是forwordb就是backward翻半页ctrl-dctlr-ud=downu=up滚一行ctrl-ectrl-yzz让光标所杂的行居屏幕中央zt让光标所杂的行居屏幕最上一行t=topzb让光标所杂的行居屏幕最下一行b=bottom转载于:https://www.cnblogs.com/orez88/articles/1867879….

  • Perl中的单行凝视和多行凝视

    Perl中的单行凝视和多行凝视

  • Effective C++ 条款11

    Effective C++ 条款11

  • 解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile

    解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compilemvncleanpackage-Dmaven.test.skip=true今天项目用maven命令打包时候抛出错误:Failedtoexecutegoalorg.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile(default-compile)onprojectspringbootdemo:Fata…

  • win7电脑卡顿严重解决方法_电脑卡顿一下

    win7电脑卡顿严重解决方法_电脑卡顿一下最近有很多游戏玩家和小编说win7电脑玩2D游戏经常发生卡顿,游戏卡顿问题确实让玩家苦恼,因为导致2D游戏经常发生卡顿的原因有很多种,那么win7电脑玩2D游戏经常发生卡顿怎么办?不要着急,针对此问题,下面小编告诉大家造成2D游戏经常发生卡顿的六大解决方法。解决方法一:1、建议下载并安装【百度电脑专家】,2、打开【百度电脑专家】,在搜索框内输入“玩游戏卡”,在搜索结果里面选择第一项的【立即修复】,…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号