`

Maintain contact person in customer master

    博客分类:
  • ABAP
阅读更多
REPORT  ztest.

*--------------------------------------------------------------------*
*  VARIABLE DEFINITION
*--------------------------------------------------------------------*
DATA: w_kna1 TYPE kna1.

*--------------------------------------------------------------------*
*  INTERNAL TABLE DEFINITION
*--------------------------------------------------------------------*
DATA: it_addr TYPE STANDARD TABLE OF bapiad3vl WITH HEADER LINE,
      it_smtp TYPE STANDARD TABLE OF bapiadsmtp WITH HEADER LINE,
      it_smtpx TYPE STANDARD TABLE OF bapiadsmtx WITH HEADER LINE,
      it_xknvk TYPE STANDARD TABLE OF fknvk WITH HEADER LINE,
      it_yknvk TYPE STANDARD TABLE OF fknvk WITH HEADER LINE,
      it_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
*--------------------------------------------------------------------*
*  SELECTION SCREEN
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
PARAMETERS: p_kunnr TYPE bapi4003_1-objkey_c OBLIGATORY,
            p_parnr TYPE bapi4003_1-objkey_p OBLIGATORY,
            p_email LIKE adr6-smtp_addr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk.

*--------------------------------------------------------------------*
*  START-OF-SELECTION
*--------------------------------------------------------------------*
START-OF-SELECTION.
*Maintain customer data
  SELECT SINGLE * FROM kna1 INTO w_kna1 WHERE kunnr EQ p_kunnr.
  IF sy-subrc EQ 0.
    SELECT  * FROM knvk INTO CORRESPONDING FIELDS OF TABLE it_xknvk WHERE kunnr EQ p_kunnr AND
                                                                                parnr EQ p_parnr.
    IF sy-subrc EQ 0.
      it_yknvk[] = it_xknvk[].
      READ TABLE it_xknvk INDEX 1.
      it_xknvk-name1 = 'TEST'.
      it_xknvk-kz    = 'U'.
      MODIFY it_xknvk INDEX 1.
      CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
        EXPORTING
          i_kna1                  = w_kna1
          pi_postflag             = 'X'
        TABLES
          t_xknvk                 = it_xknvk[]
          t_yknvk                 = it_yknvk[]
        EXCEPTIONS
          client_error            = 1
          kna1_incomplete         = 2
          knb1_incomplete         = 3
          knb5_incomplete         = 4
          knvv_incomplete         = 5
          kunnr_not_unique        = 6
          sales_area_not_unique   = 7
          sales_area_not_valid    = 8
          insert_update_conflict  = 9
          number_assignment_error = 10
          number_not_in_range     = 11
          number_range_not_extern = 12
          number_range_not_intern = 13
          account_group_not_valid = 14
          parnr_invalid           = 15
          bank_address_invalid    = 16
          tax_data_not_valid      = 17
          no_authority            = 18
          company_code_not_unique = 19
          dunning_data_not_valid  = 20
          knb1_reference_invalid  = 21
          cam_error               = 22
          OTHERS                  = 23.
      IF sy-subrc EQ 0.
*Maintain contact person's address data
        CALL FUNCTION 'BAPI_ADDRESSCONTPART_GETDETAIL'
          EXPORTING
            obj_type_p = 'BUS1006001'
            obj_id_p   = p_parnr
            obj_type_c = 'KNA1'
            obj_id_c   = p_kunnr
            context    = 5
          TABLES
            bapiad3vl  = it_addr[]
            bapiadsmtp = it_smtp[].
        IF sy-subrc EQ 0.
          READ TABLE it_smtp INDEX 1.
          it_smtp-e_mail = p_email.
          MODIFY it_smtp INDEX 1.
          it_smtpx-e_mail = 'X'.
          it_smtpx-updateflag = 'U'.
          APPEND it_smtpx.
          CALL FUNCTION 'BAPI_ADDRESSCONTPART_CHANGE'
            EXPORTING
              obj_type_p  = 'BUS1006001'
              obj_id_p    = p_parnr
              obj_type_c  = 'KNA1'
              obj_id_c    = p_kunnr
              context     = 5
            TABLES
              bapiadsmtp  = it_smtp[]
              bapiadsmt_x = it_smtpx[]
              return      = it_return[].
          IF sy-subrc EQ 0.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                wait = 'X'.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
分享到:
评论

相关推荐

    tensorflow models-master.7z.002

    it is up to the individual researchers to maintain the models and/or provide support on issues and pull requests. The [samples folder](samples) contains code snippets and smaller models that ...

    tensorflow models-master.7z.001

    it is up to the individual researchers to maintain the models and/or provide support on issues and pull requests. The [samples folder](samples) contains code snippets and smaller models that ...

    Master-Item-Manager:Maintain维护和重复使用主要物品

    GINQO MasterItemManager 我们的意图是创建一个有助于提高开发效率的应用程序,尤其是围绕Master Items的开发。 由于主项目经常在应用程序中重复使用,因此我们认为受管方法最合适。 使用我们的模板文件,可以保存主...

    BAPI_NETWORK_MAINTAIN 下达项目网络的BAPI

    ### BAPI_NETWORK_MAINTAIN:下达项目网络的BAPI #### 概述 在SAP系统中,**BAPI_NETWORK_MAINTAIN** 是一个用于维护和管理项目网络的业务应用程序接口(Business Application Programming Interface,简称BAPI)...

    pentaho-kettle-master.zip

    When writing unit tests, you have at your disposal a couple of ClassRules that can be used to maintain a healthy test environment. Use RestorePDIEnvironment and RestorePDIEngineEnvironment for core ...

    GPU Programming in MATLAB

    GPU programming in MATLAB is intended for scientists, engineers, or students who develop or maintain applications in MATLAB and would like to accelerate their codes using GPU programming without ...

    C# BaseData Maintain (标准三层C/S架构 )

    “Maintain”在这里可能指的是数据的维护和管理,这涉及到数据的增删改查、事务处理、异常处理和数据验证。在三层架构中,这些操作通常在业务逻辑层执行,确保数据的完整性和一致性。 综上,通过C#和SQL构建的标准...

    Netty In Action

    Netty is a Java-based networking framework designed to handle asynchronous network events smoothly so your applications are easy to write and maintain. The framework hides all the boilerplate and low...

    Game programming in c++

    Since it’s used throughout their enormous code bases, studios use it to maintain and improve their games, and look for it constantly when hiring new developers. Game Programming in C++ is a ...

    英文原版-GPU Programming in MATLAB 1st Edition

    GPU programming in MATLAB is intended for scientists, engineers, or students who develop or maintain applications in MATLAB and would like to accelerate their codes using GPU programming without ...

    ECC-LSMW魔鬼教程

    标题“ECC-LSMW魔鬼教程”指出了文档的主要内容是关于SAP ERP ECC(企业核心组件)版本中主数据导入技术LSMW(Legacy System Migration Workbench)的详细指导。ECC是SAP ERP的第六代版本,LSMW是SAP提供的一种工具...

    GPU.Programming.in.MATLAB.0128051329

    GPU programming in MATLAB is intended for scientists, engineers, or students who develop or maintain applications in MATLAB and would like to accelerate their codes using GPU programming without ...

    Event Streams in Action: Real-time event systems with Kafka and Kinesis

    Event Streams in Action: Real-time event systems with Kafka and Kinesis。 Writing real-world applications in a data-rich environment can feel like being caught in the cross fire of a paintball battle....

    Expert SQL Server in-Memory OLTP(Apress,2015)

    The book describes the architecture and internals of the In-Memory OLTP Engine and explains how to develop, deploy, and maintain systems using it. With it you can dramatically increase transactional ...

    MBA in A Day

    It enables businesses to differentiate themselves and maintain a competitive edge in the market. **2. Financial Management** - **Key Elements:** - **Financial Statements:** Balance sheets, income ...

    AOP.in..NET

    Core concerns that cut across all parts of your application, such as logging or authorization, are difficult to maintain independently. In aspect-oriented programming (AOP) you isolate these cross-...

    Netty in Action

    Netty is a Java-based networking framework designed to handle asynchronous network events smoothly so your applications are easy to write and maintain. The framework hides all the boilerplate and low...

    netscreen firewall deploy model and maintain

    netscreen firewall deploy model and maintain

    Kubernetes in Action-Manning Publications (2018)

    people at Manning to contact me about whether I would like to write a book about Kubernetes. Of course, I couldn’t say no to such an offer, even though I was sure they’d approached other people as ...

Global site tag (gtag.js) - Google Analytics