• ABAP-供应商主数据创建(采购视图)


    FUNCTION zmm_fm_21_03.
    *"----------------------------------------------------------------------
    *"*"本地接口:
    *"  IMPORTING
    *"     VALUE(IN) TYPE  ZSLIFNR_SRM
    *"  EXPORTING
    *"     VALUE(OUT) TYPE  ZSLIFNR_SRM
    *"     REFERENCE(GV_ERR) TYPE  CHAR1
    *"----------------------------------------------------------------------

      CONSTANTS : gc_black  TYPE char04 VALUE '@EB@',
                  gc_red    TYPE char04 VALUE '@0A@',
                  gc_green  TYPE char04 VALUE '@08@',
                  gc_yellow TYPE char04 VALUE '@09@'.
      DATA: ls_phone TYPE cvis_ei_phone_str,
            ls_fax   TYPE cvis_ei_fax_str,
            ls_smtp  TYPE cvis_ei_smtp_str.
      DATA: lt_return      LIKE bapiret2   OCCURS 0 WITH HEADER LINE,           "返回参数.
            ls_purchasing  TYPE vmds_ei_purchasing,
            ls_functions   TYPE vmds_ei_functions,
            lt_functions   TYPE vmds_ei_functions_t,
            lt_master_data TYPE vmds_ei_main,
            ls_master_data TYPE vmds_ei_extern.
      DATA: lv_lifnr TYPE lfa1-lifnr.

      CLEAR: lt_return.
      REFRESH: lt_return.
      CALL FUNCTION 'BAPI_BUPA_ROLE_ADD_2'
        EXPORTING
          businesspartner             = in-partner
          businesspartnerrolecategory = 'FLVN01'
    *     ALL_BUSINESSPARTNERROLES    = ' '
          businesspartnerrole         = 'FLVN01'
    *     DIFFERENTIATIONTYPEVALUE    =
    *     VALIDFROMDATE               =
    *     VALIDUNTILDATE              = '99991231'
        TABLES
          return                      = lt_return.
                                                                "20160721新增
      LOOP AT lt_return WHERE type = 'A' OR type = 'E'.
    *    GW_LIST-ICON = GC_RED.
    *    GW_LIST-MSG  = LT_RETURN-MESSAGE.
        gv_err = 'X'.
        "EXIT.
      ENDLOOP.

      IF gv_err = 'X'.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.
      ENDIF.

      CLEAR: ls_master_data,ls_purchasing,ls_master_data,lt_master_data.
      REFRESH:lt_functions.

      ls_master_data-header-object_task              = 'M'.
      ls_master_data-header-object_instance-lifnr    = in-partner.

      DATA:lv_ktokk2 TYPE tbc001-ktokk.
      CLEAR lv_ktokk2.
      SELECT SINGLE ktokk FROM tbc001 INTO lv_ktokk2 WHERE bu_group = in-bu_group.
      ls_master_data-central_data-central-data-ktokk  = lv_ktokk2. "供应商帐户组
      ls_master_data-central_data-central-datax-ktokk = 'X'. "供应商帐户组

      SELECT SINGLE lifnr
        INTO lv_lifnr
        FROM lfa1
        WHERE lifnr = in-partner.
      IF sy-subrc <> 0.
        ls_master_data-central_data-address-task = 'I'.
        ls_master_data-central_data-address-postal-data-title       = in-title_key.  " 地址关键字的表格
        ls_master_data-central_data-address-postal-datax-title      = 'X'.
        ls_master_data-central_data-address-postal-data-name        = in-name_org1.  " 名称1
        ls_master_data-central_data-address-postal-datax-name       = 'X'.
        ls_master_data-central_data-address-postal-data-name_2      = in-name_org2.  " 名称2
        ls_master_data-central_data-address-postal-datax-name_2     = 'X'.
        ls_master_data-central_data-address-postal-data-sort1       = in-bu_sort1.   " 搜索词 1
        ls_master_data-central_data-address-postal-datax-sort1      = 'X'.
        ls_master_data-central_data-address-postal-data-country     = in-land1.      " 国家
        ls_master_data-central_data-address-postal-datax-country    = 'X'.
        ls_master_data-central_data-address-postal-data-region      = in-regio.      " 地区
        ls_master_data-central_data-address-postal-datax-region     = 'X'.
        ls_master_data-central_data-address-postal-data-city        = in-city1.      " 城市
        ls_master_data-central_data-address-postal-datax-city       = 'X'.
        ls_master_data-central_data-address-postal-data-street      = in-street.     " 街道
        ls_master_data-central_data-address-postal-datax-street     = 'X'.
        ls_master_data-central_data-address-postal-data-postl_cod1  = in-post_code1. " 邮编
        ls_master_data-central_data-address-postal-datax-postl_cod1 = 'X'.
        ls_master_data-central_data-address-postal-data-langu       = 1.                 " 语言
        ls_master_data-central_data-address-postal-datax-langu      = 'X'.

        CLEAR ls_phone.
        ls_phone-contact-task = 'I'.
        ls_phone-contact-data-country    = in-land1.      " 国家.
        ls_phone-contact-datax-country   = 'X'.
        ls_phone-contact-data-std_no     = 'X'.
        ls_phone-contact-datax-std_no    = 'X'.
        ls_phone-contact-data-home_flag  = 'X'.
        ls_phone-contact-datax-home_flag = 'X'.
        ls_phone-contact-data-telephone  = in-tel_number. " 电话.
        ls_phone-contact-datax-telephone = 'X'.
        ls_phone-contact-data-r_3_user  = '1'.
        ls_phone-contact-datax-r_3_user = 'X'.
        APPEND ls_phone TO ls_master_data-central_data-address-communication-phone-phone[].

        CLEAR ls_phone.
        ls_phone-contact-task = 'I'.
        ls_phone-contact-data-country    = in-land1.      " 国家.
        ls_phone-contact-datax-country   = 'X'.
        ls_phone-contact-data-telephone  = in-tel_number. " 移动电话     ls_phone
    -contact-datax-telephone = 'X'.     ls_phone
    -contact-data-r_3_user  = '3'.     ls_phone
    -contact-datax-r_3_user = 'X'.     
    APPEND ls_phone TO ls_master_data-central_data-address-communication-phone-phone[].     

    CLEAR ls_fax.     ls_fax
    -contact-task          = 'I'.     ls_fax
    -contact-data-country    = in-land1.           " 国家.     ls_fax
    -contact-datax-country   = 'X'.     ls_fax
    -contact-data-std_no     = 'X'.     ls_fax
    -contact-datax-std_no    = 'X'.     ls_fax
    -contact-data-home_flag  = 'X'.     ls_fax
    -contact-datax-home_flag = 'X'.     ls_fax
    -contact-data-fax        = in-fax_number.      " 传真     ls_fax
    -contact-datax-fax       = 'X'.     
    APPEND ls_fax TO ls_master_data-central_data-address-communication-fax-fax[].     

    CLEAR ls_smtp.     ls_smtp
    -contact-task = 'I'.     ls_smtp
    -contact-data-std_no     = 'X'.     ls_smtp
    -contact-datax-std_no    = 'X'.     ls_smtp
    -contact-data-home_flag  = 'X'.     ls_smtp
    -contact-datax-home_flag = 'X'.     ls_smtp
    -contact-data-e_mail     = in-smtp_addr.   " 邮箱     ls_smtp
    -contact-datax-e_mail    = 'X'.     
    APPEND ls_smtp TO ls_master_data-central_data-address-communication-smtp-smtp[].   
    ENDIF.   ls_purchasing
    -task                              = 'I'.   ls_purchasing
    -data_key-ekorg                    = in-caigou-ekorg.    " 采购组织   ls_purchasing
    -data-waers                        = in-caigou-waers.    " 币种   ls_purchasing
    -datax-waers                       = 'X'.   ls_purchasing
    -data-zterm                        = in-caigou-zterm1.   " 付款条件   ls_purchasing
    -datax-zterm                       = 'X'.
    *    LS_PURCHASING-DATA-EKGRP                     = in-EKGRP.    " 采购组20160913
    *    LS_PURCHASING-DATAX-EKGRP                    = 'X'.   ls_purchasing
    -data-verkf                        = in-caigou-verkf.    " 供应商联系人   ls_purchasing
    -datax-verkf                       = 'X'.   ls_purchasing
    -data-telf1                        = in-caigou-telf1.    " 供应商联系电话   ls_purchasing
    -datax-telf1                       = 'X'.   ls_purchasing
    -data-webre                        = in-caigou-webre.    " 基于收货的发票校验   ls_purchasing
    -datax-webre                       = 'X'.   ls_purchasing
    -data-lebre                        = in-caigou-lebre.    " 基于服务的发票校验标识   ls_purchasing
    -datax-lebre                       = 'X'.   ls_purchasing
    -data-kalsk                        = in-caigou-kalsk.    " 方案组   ls_purchasing
    -datax-kalsk                       = 'X'.   ls_functions

    -task = 'M'.

    *    IF in-KTONR <> ''.
    *      LS_FUNCTIONS-DATA_KEY-PARVW = 'ZM'.                "ER内外部转换后为ZM
    **    LS_FUNCTIONS-DATA-DEFPA = ''.
    *      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    *        EXPORTING
    *          INPUT  = in-KTONR
    *        IMPORTING
    *          OUTPUT = in-KTONR.
    *      LS_FUNCTIONS-DATA-PARTNER = in-KTONR.
    *      LS_FUNCTIONS-DATAX-PARTNER =  'X'.
    *      APPEND LS_FUNCTIONS TO LS_PURCHASING-FUNCTIONS-FUNCTIONS.
    *
    *    ENDIF.   ls_functions

    -data_key-parvw = 'BA'.   
    APPEND ls_functions TO ls_purchasing-functions-functions.   ls_functions

    -data_key-parvw = 'LF'.   
    APPEND ls_functions TO ls_purchasing-functions-functions.   ls_functions

    -data_key-parvw = 'RS'.   
    APPEND ls_functions TO ls_purchasing-functions-functions.   

    APPEND ls_purchasing TO ls_master_data-purchasing_data-purchasing.   
    APPEND ls_master_data TO  lt_master_data-vendors[].

    *    LS_FUNCTIONS-DATA_KEY-PARVW = 'OA'.
    *    APPEND LS_FUNCTIONS TO LS_PURCHASING-FUNCTIONS-FUNCTIONS.
    *
    *    LS_FUNCTIONS-DATA_KEY-PARVW = 'VN'.
    *    APPEND LS_FUNCTIONS TO LS_PURCHASING-FUNCTIONS-FUNCTIONS.
    *
    *    LS_FUNCTIONS-DATA_KEY-PARVW = 'PI'.
    *    LS_FUNCTIONS-DATA-DEFPA = ''.
    *    APPEND LS_FUNCTIONS TO LS_PURCHASING-FUNCTIONS-FUNCTIONS.   

    DATA ls_msg1 TYPE vmds_ei_main.   
    DATA ls_msg2 TYPE cvis_message.   
    DATA ls_msg3 TYPE vmds_ei_main.   
    DATA ls_msg4 TYPE cvis_message.   
    DATA ls_msg  TYPE bapiret2.   vmd_ei_api

    =>initialize( ).   

    CALL METHOD vmd_ei_api=>maintain_bapi                                      "VMD_EI_API=>MAINTAIN_DIRECT_INPUT     
    EXPORTING       iv_collect_messages      
    = 'X'       is_master_data           
    = lt_master_data     
    IMPORTING       es_master_data_correct   
    = ls_msg1       es_message_correct       
    = ls_msg2       es_master_data_defective 
    = ls_msg3       es_message_defective     
    = ls_msg4.   

    IF ls_msg4-is_error = ''.     
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'       
    EXPORTING         
    wait = 'X'.     

    in-lfm1f = 'X'.     
    in-icon_a  = gc_yellow.     
    in-remark = in-remark && '供应商采购视图扩展成功'.   
    ELSE.     
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.     
    LOOP AT ls_msg4-messages INTO ls_msg.       
    in-remark = in-remark && '/' && ls_msg-message.     
    ENDLOOP.     
    in-icon_a  = gc_red.   

    ENDIF.   out 

    = in.

    ENDFUNCTION.

  • 相关阅读:
    mysql查找有某列但没有此列索引的表
    mysql找到所有索引
    mysq在某一刻同时获取主从库的位置点
    新书《深入应用C++11:代码优化与工程级应用》出版,感谢支持
    c++11实现一个简单的lexical_cast
    应该用bind+function取代虚函数吗?
    《深入应用C++11:代码优化与工程级应用》开始发售
    一个更好的C++序列化/反序列化库Kapok
    C++技术沙龙主要内容
    C++11模版元编程
  • 原文地址:https://www.cnblogs.com/eagle-dtq/p/12848617.html
Copyright © 2020-2023  润新知