• SAP-BP 创建客商(摘抄)


    FORM frm_bp02 .
    
    * 更改供应商所需变量
      DATA:l_xfeld   TYPE xfeld,               "复选框
           ls_data   TYPE vmds_ei_main,        "供应商总数据
           ls_msg1   TYPE vmds_ei_main,
           ls_msg2   TYPE cvis_message,
           ls_msg3   TYPE vmds_ei_main,
           ls_msg4   TYPE cvis_message,
           l_msg_tmp TYPE char255.
    * 复杂外部接口的供应商
      DATA:ls_vendor TYPE vmds_ei_extern,
           lt_vendor TYPE vmds_ei_extern_t.
    
    * 供应商抬头数据
      DATA ls_header TYPE vmds_ei_header.
      ls_header-object_instance-lifnr = gs_alv-partner.
      ls_header-object_task           = 'U'.
    * 供应商中心数据
      DATA ls_central_data TYPE vmds_ei_central_data.
      ls_central_data-address-task                     = 'U'.
      ls_central_data-address-postal-data-name         = gs_alv-name_org1.
      ls_central_data-address-postal-datax-name        = 'X'.
      ls_central_data-address-postal-data-name_2       = gs_alv-name_org2.
      ls_central_data-address-postal-datax-name_2      = 'X'.
      ls_central_data-address-postal-data-sort1        = gs_alv-bu_sort1.
      ls_central_data-address-postal-datax-sort1       = 'X'.
      ls_central_data-address-postal-data-street       = gs_alv-street.
      ls_central_data-address-postal-datax-street      = 'X'.
      ls_central_data-address-postal-data-postl_cod1   = gs_alv-post_code1.
      ls_central_data-address-postal-datax-postl_cod1  = 'X'.
      ls_central_data-address-postal-data-city         = gs_alv-city1.
      ls_central_data-address-postal-datax-city        = 'X'.
      ls_central_data-address-postal-data-pobox_ctry   = gs_alv-land1.
      ls_central_data-address-postal-datax-pobox_ctry  = 'X'.
      ls_central_data-address-postal-data-regiogroup   = gs_alv-regio.
      ls_central_data-address-postal-data-regiogroup   = 'X'.
      CALL FUNCTION 'CONVERSION_EXIT_ISOLA_INPUT'
        EXPORTING
          input            = gs_alv-langu
        IMPORTING
          output           = gs_alv-langu
        EXCEPTIONS
          unknown_language = 1
          OTHERS           = 2.
      IF sy-subrc <> 0.
    * Implement suitable error handling here
      ENDIF.
      ls_central_data-address-postal-data-langu        = gs_alv-langu.
      ls_central_data-address-postal-datax-langu       = 'X'.
    *****************************************************************************************
    * 银行信息
      DATA: lv_bankl                  TYPE bnka-bankl,
    *        LS_BANK  TYPE CVIS_EI_CVI_BANKDETAIL,
    *        LT_BANK  TYPE CVIS_EI_BANKDETAIL_T.
            ls_bapibus1006_bankdetail TYPE bapibus1006_bankdetail.
    
      CLEAR lv_bankl.
      SELECT SINGLE bankl FROM bnka INTO lv_bankl WHERE banka = gs_alv-bank_name.
      IF lv_bankl <> ''.
        ls_bapibus1006_bankdetail-bank_key = lv_bankl.
    
      ELSE.
        "暂不直接创建供应商
    *    DATA: LV_BANK_CTRY    LIKE BAPI1011_KEY-BANK_CTRY,
    *          LT_BANK_ADDRESS LIKE BAPI1011_ADDRESS OCCURS 0 WITH HEADER LINE,
    *          LT_RETURN_BK    LIKE BAPIRET2   OCCURS 0 WITH HEADER LINE.
    *
    *    LV_BANK_CTRY              = GS_ALV-BANK_LAND.
    *    LT_BANK_ADDRESS-BANK_NAME = GS_ALV-BANK_NAME.
    *    APPEND LT_BANK_ADDRESS.
    *
    *    CLEAR: LT_RETURN_BK,LT_RETURN_BK[].
    *    CALL FUNCTION 'BAPI_BANK_CREATE'
    *      EXPORTING
    *        BANK_CTRY    = LV_BANK_CTRY
    **       BANK_KEY     =
    *        BANK_ADDRESS = LT_BANK_ADDRESS
    **       BANK_METHOD  =
    **       BANK_FORMATTING                    =
    **       BANK_ADDRESS1                      =
    **       I_XUPDATE    = 'X'
    **       I_CHECK_BEFORE_SAVE                =
    **       BANK_IBAN_RULE                     =
    **       BANK_B2B_SUPPORTED                 =
    **       BANK_COR1_SUPPORTED                =
    **       BANK_R_TRANSACTION_SUPPORTED       =
    *      IMPORTING
    *        RETURN       = LT_RETURN_BK
    **       BANKCOUNTRY  =
    *        BANKKEY      = LS_BAPIBUS1006_BANKDETAIL-BANK_KEY.
      ENDIF.
    
      ls_bapibus1006_bankdetail-bank_ctry       = gs_alv-bank_land.  "银行国家
      ls_bapibus1006_bankdetail-accountholder   = gs_alv-koinh.      "账户持有人
      ls_bapibus1006_bankdetail-bank_acct       = gs_alv-bank_no+0(18).    "银行账户
      ls_bapibus1006_bankdetail-bank_ref        = gs_alv-bank_no+18(20).   "参考明细
      "LS_BAPIBUS1006_BANKDETAIL-BANKACCOUNTNAME = GS_ALV-BANK_NO.         "账户名称
     CLEAR: lt_return2, lt_return2[].
      CALL FUNCTION 'BAPI_BUPA_BANKDETAIL_CHANGE'
        EXPORTING
          businesspartner = gs_alv-partner
          bankdetailid    = '0001'
          bankdetaildata  = ls_bapibus1006_bankdetail
    *     BANKDETAILDATA_X       =
        TABLES
          return          = lt_return2.
    
    *  CALL FUNCTION 'BAPI_BUPA_BANKDETAIL_ADD'
    *    EXPORTING
    *      BUSINESSPARTNER = GS_ALV-PARTNER
    **     BANKDETAILID    =
    *      BANKDETAILDATA  = LS_BAPIBUS1006_BANKDETAIL
    **           IMPORTING
    **     BANKDETAILIDOUT =
    *    TABLES
    *      RETURN          = LT_RETURN2.
    
      CLEAR l_msg2.
      LOOP AT lt_return2 WHERE type = 'E' OR type = 'A'.
        CONCATENATE lt_return2-message l_msg2 INTO l_msg2 SEPARATED BY ''.
        CONDENSE l_msg2.
      ENDLOOP.
    
      IF l_msg2 = ''.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait = 'X'.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
    *       IMPORTING
    *         RETURN        =
          .
      ENDIF.
    
    **************************************************************************
    * 电话信息更改
      DATA:ls_contact TYPE cvis_ei_phone_str,
           lt_contact TYPE cvis_ei_phone_t.
      ls_contact-contact-task = 'U'.
      ls_contact-contact-data-telephone = gs_alv-tel_number.
      ls_contact-contact-datax-telephone = 'X'.
      ls_contact-contact-data-extension = gs_alv-tel_extens.
      ls_contact-contact-datax-extension = 'X'.
      APPEND ls_contact TO lt_contact.
      ls_central_data-address-communication-phone-phone[] = lt_contact.
    
      ls_contact-contact-task = 'U'.
      ls_contact-contact-data-r_3_user = '2'.
      ls_contact-contact-datax-r_3_user = 'X'.
      ls_contact-contact-data-telephone = gs_alv-mob_number.
      ls_contact-contact-datax-telephone = 'X'.
      APPEND ls_contact TO lt_contact.
      ls_central_data-address-communication-phone-phone[] = lt_contact.
    
    * 传真信息更改
      DATA:ls_fax TYPE cvis_ei_fax_str,
           lt_fax TYPE cvis_ei_fax_t.
      ls_fax-contact-task = 'U'.
      ls_fax-contact-data-fax        = gs_alv-fax_number.
      ls_fax-contact-datax-fax       = 'X'.
      ls_fax-contact-data-extension  = gs_alv-fax_extens.
      ls_fax-contact-datax-extension = 'X'.
      APPEND ls_fax TO lt_fax.
      ls_central_data-address-communication-fax-fax[] = lt_fax[].
    
    * 电子邮箱
      DATA:ls_smtp TYPE cvis_ei_smtp_str,
           lt_smtp TYPE cvis_ei_smtp_t.
      ls_smtp-contact-task = 'U'.
      ls_smtp-contact-data-e_mail  = gs_alv-smtp_addr.
      ls_smtp-contact-datax-e_mail = 'X'.
      APPEND ls_smtp TO lt_smtp.
      ls_central_data-address-communication-smtp-smtp[] = lt_smtp[].
    
    * 税号
    *  DATA:LT_VAT_NUMBERS TYPE CVIS_EI_VAT_T,
    *       LS_VAT_NUMBERS TYPE CVIS_EI_VAT.
    *  LS_VAT_NUMBERS-TASK           = 'U'.
    *  LS_VAT_NUMBERS-DATA_KEY-LAND1 = GS_ALV-LAND1.
    *  LS_VAT_NUMBERS-DATA-STCEG     = GS_ALV-TAXNUM.
    *  LS_VAT_NUMBERS-DATAX-STCEG    = 'X'.
    *  APPEND LS_VAT_NUMBERS TO LT_VAT_NUMBERS.
    *  LS_CENTRAL_DATA-VAT_NUMBER-VAT_NUMBERS[] = LT_VAT_NUMBERS[].
      MOVE-CORRESPONDING ls_header       TO ls_vendor-header.   "20160905
      MOVE-CORRESPONDING ls_central_data TO ls_vendor-central_data. "20160905
    
    * 公司数据
      DATA:ls_company_data TYPE vmds_ei_vmd_company,
           ls_company      TYPE vmds_ei_company,
           lt_company      TYPE vmds_ei_company_t.
      ls_company-task = 'U'.
      ls_company-data_key-bukrs = gs_alv-bukrs.
      ls_company-data-akont     = gs_alv-akont.
      ls_company-datax-akont    = 'X'.
      ls_company-data-zuawa     = gs_alv-zuawa.
      ls_company-datax-zuawa    = 'X'.
      ls_company-data-zterm     = gs_alv-zterm.
      ls_company-datax-zterm    = 'X'.
      ls_company-data-zwels     = gs_alv-dzwels.
      ls_company-datax-zwels    = 'X'.
      ls_company-data-altkn     = gs_alv-zaltkn.
      ls_company-datax-altkn    = 'X'.
      ls_company-data-reprf     = 'X'.            "检查重复发票
      ls_company-datax-reprf    = 'X'.
      APPEND ls_company TO lt_company.
      ls_company_data-company[] = lt_company[].
      MOVE-CORRESPONDING ls_company_data TO ls_vendor-company_data.
    * 组织数据
      DATA:ls_purchasing_data TYPE vmds_ei_vmd_purchasing,
           ls_purchasing      TYPE vmds_ei_purchasing,
           lt_purchasing      TYPE vmds_ei_purchasing_t.
      ls_purchasing-task           = 'U'.
      ls_purchasing-data_key-ekorg = gs_alv-ekorg.
      ls_purchasing-data-waers     = gs_alv-waers.
      ls_purchasing-datax-waers    = 'X'.
      ls_purchasing-data-zterm     = gs_alv-zterm2.
      ls_purchasing-datax-zterm    = 'X'.
      ls_purchasing-data-ekgrp     = gs_alv-ekgrp.   "采购组
      ls_purchasing-datax-ekgrp    = 'X'.
      ls_purchasing-data-telf1     = gs_alv-telf1.
      ls_purchasing-datax-telf1    = 'X'.
      ls_purchasing-data-verkf     = gs_alv-verkf.
      ls_purchasing-datax-verkf    = 'X'.
      ls_purchasing-data-webre     = 'X'.                     "基于收货的发票校验
      ls_purchasing-datax-webre    = 'X'.
    
      ls_functions-task = 'U'.
      IF gs_alv-ktonr <> ''.
        ls_functions-data_key-parvw = 'ZM'.                "ER内外部转换后为ZM
    *        LS_FUNCTIONS-DATA-DEFPA = ''.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_alv-ktonr
          IMPORTING
            output = gs_alv-ktonr.
        ls_functions-data-partner = gs_alv-ktonr.
        ls_functions-datax-partner =  'X'.
        APPEND ls_functions TO ls_purchasing-functions-functions.
      ENDIF.
    
      APPEND ls_purchasing TO lt_purchasing.
      MOVE-CORRESPONDING ls_purchasing_data TO ls_vendor-purchasing_data.
    
      APPEND ls_vendor TO lt_vendor.
    
      ls_data-vendors[] = lt_vendor[].
      vmd_ei_api=>initialize( ).
    
      CALL METHOD vmd_ei_api=>maintain_bapi
        EXPORTING
          iv_collect_messages      = 'X'
          is_master_data           = ls_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'.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    
        DATA ls_msg4_tmp LIKE LINE OF ls_msg4-messages.
        LOOP AT ls_msg4-messages INTO ls_msg4_tmp WHERE type = 'E' OR type = 'A'.
          CONCATENATE l_msg_tmp ls_msg4_tmp-message INTO l_msg_tmp SEPARATED BY ''.
          CONDENSE l_msg_tmp.
        ENDLOOP.
      ENDIF.
    
      CLEAR: ls_contact, lt_contact[], ls_contact, lt_contact[], ls_fax, lt_fax[], ls_smtp, lt_smtp[].
    
      IF l_msg2 = '' AND l_msg_tmp = ''.
        gs_alv-remark = '信息修改成功。'.
        gs_alv-icon_a = icon_green_light.
        MODIFY gt_alv FROM gs_alv TRANSPORTING icon_a remark WHERE partner = g_partner AND bukrs = gs_alv-bukrs AND ekorg = gs_alv-ekorg.
    
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'                     "获取alv
          IMPORTING
            e_grid = l_grid.
    
        CALL METHOD l_grid->check_changed_data. "获取alv改变值
        CALL METHOD l_grid->refresh_table_display. "刷新ALV界面
    
      ELSE.
        CONCATENATE l_msg2 l_msg_tmp INTO gs_alv-remark SEPARATED BY ''.
        gs_alv-icon_a = icon_red_light.
        MODIFY gt_alv FROM gs_alv TRANSPORTING icon_a remark WHERE partner = g_partner AND bukrs = gs_alv-bukrs AND ekorg = gs_alv-ekorg.
    
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'                     "获取alv
          IMPORTING
            e_grid = l_grid.
    
        CALL METHOD l_grid->check_changed_data. "获取alv改变值
        CALL METHOD l_grid->refresh_table_display. "刷新ALV界面
    
      ENDIF.
    
    ENDFORM.
  • 相关阅读:
    设计模式之笔记--工厂方法模式(Factory Method)
    dmesg命令
    jumpserver2.3.0社区开源版
    container偶尔宕掉问题的解决记录
    sshd服务的白名单和黑名单
    /proc/sysrq-trigger文件
    ansible定义主机清单
    简述Etcd、Lvs、HAProxy
    ES6语法 let、const、for...of循环、展开运算符、ES6箭头函数、箭头函数和this、模板字面量、解构、对象字面量简写法、默认参数函数、super 和 extends、Object.assign()
    axios 将post请求时把对象obj数据转为formdata
  • 原文地址:https://www.cnblogs.com/BruceKing/p/12072789.html
Copyright © 2020-2023  润新知