`
Jack Wu
  • 浏览: 887523 次
  • 来自: ...
社区版块
存档分类
最新评论

BDC program for Purchase Info Records (ME11)

阅读更多

*&---------------------------------------------------------------------*
*&   REPORT ZMM0069                                                    *
*&---------------------------------------------------------------------*
*& Module : MM                                                         |
*& Application : The program loads the Purchasing Inforecords          |
*&                                                                     |
*----------------------------------------------------------------------*
*| Modification Log                                                    |
*| ----------------                                                    |
*| Programmer      Date       CC#    Chg.Ref        Description of
*|                                                       Change        |
*| ------------- ----------- ---- ----------- ----------------------|
*| Rajesh Singh 23-AUG-2005                        Initial
*|                                                  development.       |
*----------------------------------------------------------------------*
 REPORT zmm0069 NO STANDARD PAGE HEADING
                                  MESSAGE-ID z0
                                  LINE-SIZE 132
                                  LINE-COUNT 65(2).
*----------------------------------------------------------------------*
*                      Internal Tables                                 *
*----------------------------------------------------------------------*
*Internal table for the purchasing info records fields.
 DATA: BEGIN OF i_inforecord OCCURS 0,
        matnr(18),
        lifnr(10),
        uom(3),
        ekgrp(3),
        planned_time(3),
        under_tol(3),
        over_tol(3),
        qty(10),
        price_cat(5),
        inco(3),
        designation(28),
        netpr(13),
        scale_qty1(10),
        scale_pr1(13),
        scale_qty2(10),
        scale_pr2(13),
        scale_qty3(13),
        scale_pr3(10),
        scale_qty4(13),
        scale_pr4(10),
        scale_qty5(13),
        scale_pr5(10),
        scale_qty6(13),
        scale_pr6(10),
        scale_qty7(13),
        scale_pr7(10),
        scale_qty8(13),
        scale_pr8(10),
        scale_qty9(13),
        scale_pr9(10),
        scale_qty10(13),
        scale_pr10(10),
        END OF i_inforecord.
** Internal table for Old and New Vendor number
 DATA : BEGIN OF i_lfb1 OCCURS 1,
         lifnr(10),
         altkn(10),
         END   OF i_lfb1.
** Declare internal table for Call Transaction and BDC Session
 DATA: i_bdc_table LIKE bdcdata OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
*                      Global Variables                                *
*----------------------------------------------------------------------*
 DATA: g_counter(2) TYPE n,
        g_field_name(18) TYPE c,
        zc_yes TYPE syftype VALUE 'X'.
*----------------------------------------------------------------------*
*                      Selection Screen                                *
*----------------------------------------------------------------------*
 SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
 PARAMETERS: p_fname1 TYPE localfile .
 SELECTION-SCREEN SKIP 1.
 SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
 PARAMETERS: p_rloc1 AS CHECKBOX DEFAULT 'X'.
 SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
 PARAMETERS p_group(12) OBLIGATORY DEFAULT 'ZPURCHINFO'.
 SELECTION-SCREEN END OF BLOCK c.
 SELECTION-SCREEN END OF BLOCK b.
 SELECTION-SCREEN END OF BLOCK a.
**WRITE the report header
 TOP-OF-PAGE.
    INCLUDE zheading.
*----------------------------------------------------------------------*
*                      Start of selection                              *
*----------------------------------------------------------------------*
 START-OF-SELECTION.
* Load Input file
    PERFORM f_load_input_file.
* Create BDC records.
    PERFORM create_bdc_records .
*&---------------------------------------------------------------------*
*&      Form Create_BDC_records
*&---------------------------------------------------------------------*
*       Perform the BDC for the records in the internal table
*----------------------------------------------------------------------*
 FORM create_bdc_records .
    IF NOT i_inforecord[] IS INITIAL.
** Open BDC session
      PERFORM open_bdc_session.
      SELECT lifnr altkn FROM lfb1 INTO TABLE i_lfb1
                          FOR ALL ENTRIES IN i_inforecord
                          WHERE altkn = i_inforecord-lifnr.
* Sorting the Internal table for better performance
      SORT i_lfb1 BY altkn.
      LOOP AT i_inforecord.
***Mapping Old Vendor number to the new Vendor number
        READ TABLE i_lfb1 WITH KEY altkn = i_inforecord-lifnr BINARY
                                                              SEARCH.
        IF sy-subrc EQ 0.
          i_inforecord-lifnr = i_lfb1-lifnr.
        ENDIF.
        CLEAR i_bdc_table[].
        PERFORM insert_screen_header.
*      call transaction 'ME11' using i_bdc_table
*                    mode 'A'.
*      CLEAR i_bdc_table.
      ENDLOOP.
      CLEAR i_inforecord[].
      PERFORM close_bdc_session.
** Release the BDC sessions created
      PERFORM release_bdc.
    ENDIF.
 ENDFORM.                    " open_group
*&---------------------------------------------------------------------*
*&      Form bdc_dynpro_start
*&---------------------------------------------------------------------*
*       Start the screen for the transfer of fields
*----------------------------------------------------------------------*
 FORM bdc_dynpro_start USING    p_g_program_1
                                  p_g_screen.
    CLEAR i_bdc_table.
    i_bdc_table-program = p_g_program_1.
    i_bdc_table-dynpro   = p_g_screen.
    i_bdc_table-dynbegin = 'X'.
    APPEND i_bdc_table.
 ENDFORM.                    " bdc_dynpro_start_start
*&---------------------------------------------------------------------*
*&      Form bdc_insert_field
*&---------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
 FORM bdc_insert_field USING f_name f_value.
    IF f_value <> space.
      CLEAR i_bdc_table.
      i_bdc_table-fnam = f_name.
      i_bdc_table-fval = f_value.
      APPEND i_bdc_table.
    ENDIF.
 ENDFORM.                    "bdc_insert_field
*&--------------------------------------------------------------------*
*&      Form open_bdc_session
*&--------------------------------------------------------------------*
*       Open a BDC session
*---------------------------------------------------------------------*
 FORM open_bdc_session .
** Open BDC session and create and update records
    CALL FUNCTION 'BDC_OPEN_GROUP'
      EXPORTING
        client                    = sy-mandt
*       DEST                      = FILLER8
        group                     = p_group
*       HOLDDATE                  = FILLER8
        keep                      = 'X'
        user                      = sy-uname
*       RECORD                    = FILLER1
*       PROG                      = SY-CPROG
*     IMPORTING
*       QID                       =
   EXCEPTIONS
     client_invalid            = 1
     destination_invalid       = 2
     group_invalid             = 3
     group_is_locked           = 4
     holddate_invalid          = 5
     internal_error            = 6
     queue_error               = 7
     running                   = 8
     system_lock_error         = 9
     user_invalid              = 10
     OTHERS                    = 11
              .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
 ENDFORM.                    " create_bdc_session
*&---------------------------------------------------------------------*
*&      Form insert_screen_header
*&---------------------------------------------------------------------*
*       Screen flow for the transfer of fields
*----------------------------------------------------------------------*
 FORM insert_screen_header .
* First Screen 100
    PERFORM bdc_dynpro_start USING 'SAPMM06I' '0100'.
    PERFORM bdc_insert_field USING:'BDC_CURSOR' 'EINA-LIFNR',
                                   'BDC_OKCODE' '/00',
                                   'EINA-LIFNR' i_inforecord-lifnr,
                                   'EINA-MATNR' i_inforecord-matnr,
                                   'EINE-EKORG' '1000',
                                   'RM06I-NORMB' zc_yes.
*****----------------------------------------********
* Next Screen 101
    PERFORM bdc_dynpro_start USING 'SAPMM06I' '0101'.
    PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'EINA-MAHN1',
                                     'BDC_OKCODE' '/00',
                                     'EINA-MEINS' i_inforecord-uom.
*****----------------------------------------********
*Next Screen 102
    PERFORM bdc_dynpro_start USING 'SAPMM06I' '0102'.
    PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'EINE-INCO2',
                                 'EINE-APLFZ' i_inforecord-planned_time,
                                 'EINE-EKGRP' i_inforecord-ekgrp,
                                 'EINE-NORBM' i_inforecord-qty.
    PERFORM bdc_insert USING 'EINE-UEBTK' ' '.
    PERFORM bdc_insert_field USING:'EINE-PEINH' i_inforecord-scale_qty1,
                                   'EINE-BPRME' i_inforecord-uom,
                                   'EINE-UNTTO' '5',
                                   'EINE-UEBTO' '25',
                                   'EINE-MEPRF' i_inforecord-price_cat,
                                   'EINE-NETPR' i_inforecord-netpr,
                                   'EINE-INCO1' i_inforecord-inco,
                                  'EINE-INCO2' i_inforecord-designation.
* Checking for Scale quantities
    IF i_inforecord-scale_qty2 = space.
      PERFORM bdc_insert_field USING 'BDC_OKCODE' '=BU'.
      PERFORM insert_bdc_new.
    ELSE.
      PERFORM bdc_insert_field USING 'BDC_OKCODE' '=KO'.
*****----------------------------------------********
* Next Screen 201
      PERFORM bdc_dynpro_start USING 'SAPMV13A' '0201'.
      PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'RV13A-DATAB',
                                        'BDC_OKCODE' '=PSTF'.
*****----------------------------------------********
* Next Screen 201
      PERFORM bdc_dynpro_start USING 'SAPMV13A' '0201'.
      PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'KONP-KSCHL(01)',
                                       'BDC_OKCODE' '=PSTF',
                                       'RV130-SELKZ(01)' zc_yes.
*****----------------------------------------********
* LAST SCREEN 303
      PERFORM bdc_dynpro_start USING 'SAPMV13A' '0303'.
      PERFORM bdc_insert_field USING : 'BDC_CURSOR' 'KONM-KBETR(03)',
                                       'BDC_OKCODE' '=SICH'.
* Counter to Loop the Item level entry
      g_counter = 0.
      PERFORM scale_entry USING i_inforecord-scale_qty2
                                i_inforecord-scale_pr2.
      PERFORM scale_entry USING i_inforecord-scale_qty3
                                i_inforecord-scale_pr3.
      PERFORM scale_entry USING i_inforecord-scale_qty4
                                i_inforecord-scale_pr4.
      PERFORM scale_entry USING i_inforecord-scale_qty5
                                i_inforecord-scale_pr5.
      PERFORM scale_entry USING i_inforecord-scale_qty6
                                i_inforecord-scale_pr6.
      PERFORM scale_entry USING i_inforecord-scale_qty7
                                i_inforecord-scale_pr7.
      PERFORM scale_entry USING i_inforecord-scale_qty8
                                i_inforecord-scale_pr8.
      PERFORM scale_entry USING i_inforecord-scale_qty9
                                i_inforecord-scale_pr9.
      PERFORM scale_entry USING i_inforecord-scale_qty10
                                 i_inforecord-scale_pr10.
      PERFORM insert_bdc_new.
    ENDIF.
 ENDFORM.                    " insert_screen_header
*&---------------------------------------------------------------------*
*&      Form insert_bdc
*&---------------------------------------------------------------------*
*       Insert BDC
*----------------------------------------------------------------------*
 FORM insert_bdc_new .
    CALL FUNCTION 'BDC_INSERT'
       EXPORTING
         tcode                  = 'ME11'
*       POST_LOCAL             = NOVBLOCAL
*       PRINTING               = NOPRINT
*       SIMUBATCH              = ' '
*       CTUPARAMS              = ' '
       TABLES
         dynprotab              = i_bdc_table
    EXCEPTIONS
      internal_error         = 1
      not_open               = 2
      queue_error            = 3
      tcode_invalid          = 4
      printing_invalid       = 5
      posting_invalid        = 6
      OTHERS                 = 7
               .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE
分享到:
评论
1 楼 elin_yi 2009-05-12  
你好,上面代码中的INCLUDE zheading.
可是ZHEADING的代码是什么呢?

相关推荐

    BDC.rar_bdc.youzack_com_单词_背单词

    标题"BDC.rar_bdc.youzack_com_单词_背单词"揭示了这是一个与英语学习相关的压缩文件,可能包含一个名为"BDC"的应用程序或工具,由youzack.com开发,专为帮助用户背诵单词设计。这个工具利用金山词霸的界面,使用户...

    SAP BDC技术 录屏

    ### SAP BDC技术详解 #### 一、BDC技术概述 **SAP BDC (Batch Data Conversion)** 技术主要用于批量处理数据录入任务,尤其是在需要重复执行相同操作但涉及的数据不同的场景下。例如,在切换系统时,需要将旧系统...

    BDC Generator

    BDC generator for MOSS 2007.

    SAP BDC精华教程

    SAP BDC精华教程 本资源摘要信息将详细介绍SAP BDC(Batch Data Conversion)技术,包括BDC的概念、应用场景、技术原理、编程步骤及实践示例。 BDC概念 BDC是一种SAP系统中的数据批量处理技术,用于将外部数据源...

    BDC数据导入简介

    ### BDC数据导入简介 #### 一、BDC(Business Data Creator)概述 BDC,全称为Business Data Creator,是SAP系统中的一个重要组件,主要用于自动化处理数据输入任务。通过BDC,用户可以创建一系列标准化的数据输入...

    BDC资料 数据导入工具_BDC使用方法

    【BDC资料 数据导入工具_BDC使用方法】 BDC(Batch Input Communication)是SAP系统中用于批量数据导入的关键技术,也称为批输入。它允许用户高效地输入大量数据到SAP系统,尤其适用于需要频繁处理大批量业务数据的...

    SAP BDC开发讲解

    ### SAP BDC开发详解 #### 一、SAP BDC技术概述 SAP Business Data Cooperation (BDC) 是一种用于批量或自动化数据录入SAP系统的工具。它通过模拟用户交互来执行事务处理,从而实现数据的批量输入。BDC不仅能够...

    abap BDC 操作

    ABAP BDC 操作 ABAP BDC 操作是 SAP 系统中的一种批量数据输入机制,通过模拟事务处理将数据录入 R/3 系统。BDC 类似 SAP 的 CATT,控制性更好,处理能力更强。下面是一个简单的 BDC 实例,包含全部操作过程。 ...

    sap bdc 使用

    ### SAP BDC 使用详解 #### 1. BDC的基本知识 ##### 1.1 BDC概述 BDC(Batch Input Communication)即批输入通信,是SAP系统中一种重要的数据传输技术,它允许用户批量地将数据输入到SAP系统中。通过BDC技术,...

    BDC介绍BDC介绍BDC介绍

    【BDC技术详解】 BDC(Batch Data Conversion)是SAP系统中用于批量数据转换的一种技术,主要用于自动化处理大量重复性的数据输入任务。在企业信息化过程中,如系统切换、数据迁移或常规的数据更新等场景,BDC技术...

    SAP_BDC_举例讲解

    SAP BDC技术举例讲解 在SAP系统中,BDC(Batch Data Conversion)技术是一种重要的技术,它可以使用户快速地批量处理数据。下面我们将通过一个实例来讲解BDC技术的应用。 在SAP系统中,BDC技术可以使用户快速地...

    SAP BDC学习导入教程

    ### SAP BDC(Batch Data Conversion)学习导入教程详解 #### 一、SAP BDC概念与应用场景 SAP BDC,即Batch Data Conversion,是一种在SAP系统中用于批量数据导入的技术。它允许用户通过录制特定的事务处理过程,...

    abap bdc 例子

    标题:“abap bdc 例子” 描述:“简单的BDC实例,有助于理解BDC的作用。” 从提供的文件信息中,我们可以深入探讨ABAP中的BDC(Batch Input or Business Data Capture)概念及其应用实例。BDC是SAP ABAP环境中...

    5分钟包教包会,超详细超简单的SAP BDC录屏技术.docx

    SAP BDC录屏技术 本文将详细介绍SAP BDC录屏技术的应用操作,旨在帮助读者快速掌握BDC的使用方法,并能够轻松实现业务顾问的录屏操作。 什么是BDC? BDC是Batch Data Conversion的简称,对应的事物码是SHDB,是一...

    SAP BDC与LSMW介绍.pdf

    SAP BDC与LSMW介绍 SAP BDC(Batch Data Conversion)是SAP系统中的一种批量数据转换机制,用于自动化大量重复的数据输入操作。BDC可以模拟人工操作,快速、重复地执行数据输入任务,减少人工操作的时间和劳动强度...

    SAP ABAP开发学习——第17课:BDC(视频教程)

    在本课程中,我们将深入探讨SAP ABAP中的批量数据通信(Batch Data Communication,简称BDC)技术。BDC是SAP系统中一种用于大量数据输入的高效工具,尤其适用于将外部数据导入到SAP系统中。在SAP ABAP开发的学习过程...

    SAP BDC与LSMW介绍.pptx

    SAP BDC与LSMW介绍 SAP BDC(Batch Data Conversion)是一种批量数据转换机制,允许用户快速、重复地模拟人工操作,以解决大量数据输入问题。在SAP系统中,BDC扮演着重要角色,可以大量、重复地模拟人工操作,避免...

    BDC技术教程

    **BDC技术详解** BDC(Batch Data Conversion)是SAP系统中用于批量数据转换的一种技术,主要用于在大量数据需要录入或更新时自动化处理。在SAP系统中,当需要重复进行相同操作但数据不同的场景时,如系统切换时旧...

Global site tag (gtag.js) - Google Analytics