Skip to Content
author's profile photo Former Member
Former Member

BAPI_CUSTOMERCONTRACT_CHANGE / BAPI_SALESORDER_CHANGE

Hi All,

Can any one help me out for changing sales order partner name(<i>adrc-name1</i>) using the above function modules? I'm not able to find the correct input parameters for these function modules.

Thanks in advance!

Thomas.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Apr 07, 2006 at 08:29 AM
    REPORT ZSD_CONTRACT_INTERACTIVE_RPT.
    
    * Includes
    INCLUDE zrdpdmrflowtop.
    INCLUDE zrdpdmrflowf01.
    INCLUDE zrdpdmrflowf02.
    INCLUDE zrdpdmrflowf03.
    INCLUDE zrdpdmrflowf04.
    INCLUDE zrdpdmrflowf05.
    INCLUDE zrdpdmrflowf06.
    INCLUDE zrdpdmrflowf07.
    
    * data
    data : v_tabix(4) type n,
           v_number(4) type n.
    CONSTANTS gc_save TYPE syucomm VALUE '&DATASAVE'.
    
    CLASS lcl_event_alv DEFINITION DEFERRED.
    FIELD-SYMBOLS <user> LIKE LINE OF zt_ad01repdmr.
    DATA :
      go_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid  TYPE REF TO cl_gui_alv_grid,
      go_event_alv TYPE REF TO lcl_event_alv,
    
      okcode      TYPE syucomm,
      gv_okcode   TYPE syucomm.
    
    CLASS lcl_event_alv DEFINITION.
    
      PUBLIC SECTION.
        METHODS:
          h_double_click FOR EVENT double_click OF cl_gui_alv_grid
                         IMPORTING e_row
                                   e_column.
    
    ENDCLASS.                              " LCL_EVENT_ALV DEFINITION
    CLASS lcl_event_alv IMPLEMENTATION.
    
      METHOD h_double_click.
        READ TABLE zt_ad01repdmr INDEX e_row-index ASSIGNING <user>.
        IF sy-subrc EQ 0.
          PERFORM f_user_command USING '&IC1'.
        ENDIF.
      ENDMETHOD.                           " H_double_click
    
    ENDCLASS.
    
    *DATA: G_REPID LIKE SY-REPID,
    *GS_PRINT            TYPE SLIS_PRINT_ALV,
    *GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    *GT_EVENTS           TYPE SLIS_T_EVENT,
    *GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    *GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    *GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    *FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    *COL_POS TYPE I.
    
    *data : wa like gt_ad01repdmr.
    LOAD-OF-PROGRAM.
    * Get reference to BADI
      CALL METHOD cl_exithandler=>get_instance
        EXPORTING
          exit_name              = 'AD01_RRB_REPORTING_1'
          null_instance_accepted = seex_true
        CHANGING
          instance               = g_ad01_rrb_reporting_1.
    
    INITIALIZATION.
    *  SET TITLEBAR 'RDPDMRFLOW'.
    
    AT SELECTION-SCREEN OUTPUT.
    * Clear selection of all sales document types except orders
      CLEAR: trvog_1,
             trvog_2,
             trvog_3,
             trvog_4,
             trvog_5.
    * Hide selections of sales document types
      LOOP AT SCREEN.
        IF screen-name CS 'TRVOG'.
          screen-invisible = 1.
          MODIFY SCREEN.
        ENDIF.
        IF screen-name CS 'DD_ERDAT' or screen-name CS 'DD_ERNAM'  or
           screen-name CS 'DD_BSTNK' or screen-name CS 'DD_VKBUR'  or
           screen-name CS 'DD_VKGRP' .
           screen-invisible = 1.
           screen-input = 0.
           screen-output = 0.
           MODIFY SCREEN.
         endif.
      ENDLOOP.
    
    * Get data from logical database
    GET vbak.
      APPEND vbak TO gt_vbak.
    
    GET vbuk.
      APPEND vbuk TO gt_vbuk.
    
    GET vbkd.
      APPEND vbkd TO gt_vbkd.
    
    GET vbpa.
      APPEND vbpa TO gt_vbpa.
    
    GET vbap.
      CHECK vbap-posnr IN s_posnr.
      CHECK vbap-vkgru = 'I02'.
      APPEND vbap TO gt_vbap.
    
    GET vbup.
      CHECK vbup-posnr IN s_posnr.
      CHECK vbap-vkgru = 'I02'.
      APPEND vbup TO gt_vbup.
    
    GET vbkdpo.
      CHECK vbkdpo-posnr IN s_posnr.
      CHECK vbap-vkgru = 'I02'.
      APPEND vbkdpo TO gt_vbkd.
    
    GET vbpapo.
      CHECK vbpapo-posnr IN s_posnr.
      CHECK vbap-vkgru = 'I02'.
      APPEND vbpapo TO gt_vbpa.
    
    END-OF-SELECTION.
    * Fill output table
      PERFORM read_data
              TABLES    gt_vbak
                        gt_vbuk
                        gt_vbkd
                        gt_vbpa
                        gt_vbap
                        gt_vbup
               USING    p_selnet
               CHANGING gt_ad01repdmr.
    
    * FIlter selected records
    perform filter_records.
    
    * Filter completed orders
    perform filter_compl_ords.
    
    * Call ALV
    call screen 100.
    
    
    *---------------------------------------------------------------------*
    *       Module  pbo_0100  OUTPUT
    *---------------------------------------------------------------------*
    MODULE pbo_0100 OUTPUT.
    
    
    *   SET PF-STATUS 'MAIN' EXCLUDING 'SAVE'.
    
       SET PF-STATUS 'MAIN1'.
       set titlebar  'TITLE01'.
      IF go_container IS INITIAL.
         PERFORM create_and_init_alv.
      ENDIF.
    
    ENDMODULE.                             " PBO_0100  OUTPUT
    *---------------------------------------------------------------------*
    *       Module  user_command_0100  INPUT
    *---------------------------------------------------------------------*
    MODULE user_command_0100 INPUT.
    
      gv_okcode = okcode.
      CLEAR okcode.
    
      CASE gv_okcode.
        WHEN 'BACK'.
          SET SCREEN 0.
        WHEN 'SAVE'.
          PERFORM f_user_command USING gc_save.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    
    ENDMODULE.                             " USER_COMMAND_0100  INPUT
    
    *---------------------------------------------------------------------*
    *       Form  create_and_init_alv
    *---------------------------------------------------------------------*
    FORM create_and_init_alv.
    
    * Macro definition
      DEFINE m_fieldcat.
        add 1 to ls_alv_cat-col_pos.
        ls_alv_cat-fieldname = &1.
        ls_alv_cat-ref_table = &2.
        ls_alv_cat-edit      = &3.
        append ls_alv_cat to lt_alv_cat.
      END-OF-DEFINITION.
    
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-group     = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
    
      DATA:
        ls_variant      TYPE disvariant,
        lt_sort         TYPE lvc_t_sort,
        ls_sort         TYPE lvc_s_sort,
        lt_alv_cat      TYPE lvc_t_fcat,
        ls_alv_cat      TYPE lvc_s_fcat,
        ls_alv_lay      TYPE lvc_s_layo,
        ls_print        TYPE lvc_s_prnt,
        l_offline       TYPE char1,
        lt_toolbar_excl TYPE ui_functions.
    
      CALL METHOD cl_gui_alv_grid=>offline
        RECEIVING e_offline = l_offline.
    *
    *  IF l_offline EQ 0.
        CREATE OBJECT go_container
            EXPORTING
                extension = 2000
            EXCEPTIONS
                cntl_error = 1
                cntl_system_error = 2
                create_error = 3
                lifetime_error = 4
                lifetime_dynpro_dynpro_link = 5
                others                      = 6.
        IF sy-subrc NE 0.
          MESSAGE e208(00) WITH 'The control could not be created'.
        ENDIF.
    *  ENDIF.
    
    * Create an instance of alv control
      CREATE OBJECT go_alv_grid
          EXPORTING i_parent = go_container.
    
    ** Build field catalog and sort table
      m_fieldcat 'ZVBELN'    'ZAD01REPDMR1'     ''.
      m_fieldcat 'ZPOSNR'    'ZAD01REPDMR1' ''.
      m_fieldcat 'PERNR'     'ZAD01REPDMR1'     ''.
      m_fieldcat 'SNAME'     'ZAD01REPDMR1' ''.
      m_fieldcat 'VBELN'     'ZAD01REPDMR1' ''.
      m_fieldcat 'POSNR'     'ZAD01REPDMR1'     ''.
      m_fieldcat 'MATNR_SD'  'ZAD01REPDMR1' ''.
      m_fieldcat 'ARKTX'     'ZAD01REPDMR1'     ''.
    * m_fieldcat 'IN_MEGBTR' 'ZAD01REPDMR1' ''.
      m_fieldcat 'KWMENG'    'ZAD01REPDMR1'     ''.
      m_fieldcat 'KLMENG'    'ZAD01REPDMR1'     ''.
      m_fieldcat 'MVGR5'     'ZAD01REPDMR1'     'X'.
      m_fieldcat 'NETWR'     'ZAD01REPDMR1' ''.
      m_fieldcat 'WAERK'     'ZAD01REPDMR1'     ''.
      m_fieldcat 'POSEX'     'ZAD01REPDMR1' ''.
      m_fieldcat 'BSTDK'     'ZAD01REPDMR1'     'X'.
      m_fieldcat 'ABGRU'     'ZAD01REPDMR1'     ''.
    
      m_fieldcat 'OBJID'     'ZAD01REPDMR1' ''.
    * m_fieldcat 'OBJTXT'     'ZAD01REPDMR1' ''.
      m_fieldcat 'KUNNR'     'ZAD01REPDMR1'     ''.
      m_fieldcat 'NAME1'     'ZAD01REPDMR1'     ''.
      m_fieldcat 'VKORG'     'ZAD01REPDMR1' ''.
      m_fieldcat 'VTWEG'     'ZAD01REPDMR1'     ''.
      m_fieldcat 'SPART'     'ZAD01REPDMR1' ''.
    
    
      m_sort 'ZVBELN' ''.        " Line break
      m_sort 'ZPOSNR' ''.
    
    * Layout
      CLEAR ls_alv_lay.
      ls_alv_lay-zebra      = ''.
      ls_alv_lay-cwidth_opt = 'X'.
    
    *  IF l_offline EQ 0.
    *   Exclude toolbar functions*
    *    APPEND cl_gui_alv_grid=>mc_fc_detail         TO lt_toolbar_excl.
    *    APPEND cl_gui_alv_grid=>mc_fc_info           TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_graph          TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_view_crystal   TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_delete_row TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_append_row TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_copy_row   TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_undo       TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_check          TO lt_toolbar_excl.
    *   APPEND cl_gui_alv_grid=>mc_fc_refresh        TO lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_copy       to lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_cut        to lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_paste      to lt_toolbar_excl.
    *   APPEND cl_gui_alv_grid=>mc_fc_select_all     to lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_insert_row to lt_toolbar_excl.
        APPEND cl_gui_alv_grid=>mc_fc_loc_paste_new_row to lt_toolbar_excl.
    
        CREATE OBJECT go_event_alv.
    
        SET HANDLER go_event_alv->h_double_click
                FOR go_alv_grid.
    
    *  ENDIF.
    
      ls_variant-report = sy-cprog.
      zt_ad01repdmr_old[] = zt_ad01repdmr[].
    
    * Display
      CALL METHOD go_alv_grid->set_table_for_first_display
        EXPORTING
          is_variant           = ls_variant
          is_layout            = ls_alv_lay
          is_print             = ls_print
          i_save               = 'A'
          it_toolbar_excluding = lt_toolbar_excl
        CHANGING
          it_sort              = lt_sort
          it_outtab            = zt_ad01repdmr[]
          it_fieldcatalog      = lt_alv_cat.
    
    ENDFORM.                               " CREATE_AND_INIT_ALV
    *---------------------------------------------------------------------*
    *       FORM F_USER_COMMAND                                           *
    *---------------------------------------------------------------------*
    FORM f_user_command USING u_ucomm LIKE sy-ucomm.
    
      DATA :
        l_valid    TYPE flag,
        lt_message TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE,
        lt_bdcdata TYPE STANDARD TABLE OF bdcdata WITH HEADER LINE.
    
      CASE u_ucomm.
        WHEN '&IC1'.
            set parameter id 'AUN' field <user>-vbeln.
            CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
    
        WHEN gc_save.
    *     Verify changes
          CALL METHOD go_alv_grid->check_changed_data
            IMPORTING e_valid = l_valid.
    
          CHECK NOT l_valid IS INITIAL.
          loop at zt_ad01repdmr .
          read table zt_ad01repdmr_old with key vbeln =  zt_ad01repdmr-vbeln
                                                posnr =  zt_ad01repdmr-posnr
                                                .
          if sy-subrc = 0 and
             ( ( zt_ad01repdmr-mvgr5 <> zt_ad01repdmr_old-mvgr5 ) or
               ( zt_ad01repdmr-bstdk <> zt_ad01repdmr_old-bstdk ) ).
    * Call sales order change BAPI
             perform sales_order_change.
             wait up to 3 seconds.
          endif.
          endloop.
          perform popup_userinfo.
          zt_ad01repdmr_old[] = zt_ad01repdmr[].
      ENDCASE.
    
    ENDFORM.                               " F_USER_COMMAN
    *&---------------------------------------------------------------------*
    *&      Form  filter_records
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM filter_records .
    data v_tabix like sy-tabix.
    if contract <> ''.
    loop at zt_ad01repdmr.
      v_tabix = sy-tabix.
      if zt_ad01repdmr-zvbeln <> CONTRACT.
         delete zt_ad01repdmr index v_tabix.
      endif.
    endloop.
    endif.
    clear v_tabix.
    if line <> ''.
    loop at zt_ad01repdmr.
      v_tabix = sy-tabix.
      if zt_ad01repdmr-zposnr <> line.
         delete zt_ad01repdmr index v_tabix.
      endif.
    endloop.
    endif.
    clear v_tabix.
    if customer <> ''.
    loop at zt_ad01repdmr.
      v_tabix = sy-tabix.
      if zt_ad01repdmr-kunnr <> customer.
         delete zt_ad01repdmr index v_tabix.
      endif.
    
    endloop.
    endif.
    
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  sales_order_change
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM sales_order_change .
    v_doc = zt_ad01repdmr-vbeln.
    i_headin-sales_org = zt_ad01repdmr-vkorg.
    i_headin-distr_chan = zt_ad01repdmr-vtweg.
    i_headin-division = zt_ad01repdmr-spart.
    
    i_headinx-updateflag = 'U'.
    
    i_orditem-itm_number = zt_ad01repdmr-posnr.
    *i_orditem-po_itm_no = zt_ad0repdmr-.
    i_orditem-material   = zt_ad01repdmr-matnr_sd.
    i_orditem-prc_group5 = zt_ad01repdmr-mvgr5.
    i_orditem-purch_date = zt_ad01repdmr-bstdk.
    append i_orditem.
    
    i_orditemx-itm_number = zt_ad01repdmr-posnr.
    i_orditemx-updateflag = 'U'.
    i_orditemx-prc_group5 = 'X'.
    i_orditemx-purch_date  = 'X'.
    append i_orditemx.
    
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
      EXPORTING
        SALESDOCUMENT               = v_doc
        ORDER_HEADER_IN             = i_headin
        ORDER_HEADER_INX            = i_headinx
    *   SIMULATION                  =
    *   BEHAVE_WHEN_ERROR           = ' '
    *   INT_NUMBER_ASSIGNMENT       = ' '
    *   LOGIC_SWITCH                =
      TABLES
        RETURN                      = i_ret
        ORDER_ITEM_IN               = i_orditem
        ORDER_ITEM_INX              = i_orditemx
    *   PARTNERS                    =
    *   PARTNERCHANGES              =
    *   PARTNERADDRESSES            =
    *   ORDER_CFGS_REF              =
    *   ORDER_CFGS_INST             =
    *   ORDER_CFGS_PART_OF          =
    *   ORDER_CFGS_VALUE            =
    *   ORDER_CFGS_BLOB             =
    *   ORDER_CFGS_VK               =
    *   ORDER_CFGS_REFINST          =
    *   SCHEDULE_LINES              =
    *   SCHEDULE_LINESX             =
    *   ORDER_TEXT                  =
    *   ORDER_KEYS                  =
    *   CONDITIONS_IN               =
    *   CONDITIONS_INX              =
    *   EXTENSIONIN                 =
    
              .
    if sy-subrc = 0.
      v_number = v_number + 1.
      v_line = v_doc.
      write zt_ad01repdmr-posnr to v_line+12(6).
      append i_val.
      clear i_val.
    endif.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    * EXPORTING
    *   WAIT          =
    * IMPORTING
    *   RETURN        =
              .
    
    refresh : i_orditem, i_orditemx.
    clear : v_doc, i_headin, i_headinx, i_orditem, i_orditemx, v_line.
    ENDFORM.                    " sales_order_change
    *&---------------------------------------------------------------------*
    *&      Form  popup_userinfo
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM popup_userinfo .
    
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
      EXPORTING
        TITEL              = ''
        TEXTLINE1          = 'No Of Sales Order Lines Changed'
        TEXTLINE2          = v_number
    *   START_COLUMN       = 25
    *   START_ROW          = 6
              .
       clear v_number.
       refresh i_val.
       clear i_val.
    ENDFORM.                    " popup_userinfo
    *&---------------------------------------------------------------------*
    *&      Form  filter_compl_ords
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM filter_compl_ords .
    select * from vbuk into table it_vbuk for all entries in zt_ad01repdmr
                                          where vbeln = zt_ad01repdmr-vbeln.
    select * from vbup into table it_vbup for all entries in zt_ad01repdmr
                                          where vbeln = zt_ad01repdmr-vbeln.
    clear v_tabix.
    loop at zt_ad01repdmr.
      v_tabix = sy-tabix.
      read table it_vbuk with key vbeln = zt_ad01repdmr-vbeln.
      if sy-subrc = 0 and it_vbuk-fksak <> 'C'.
         if it_vbuk-fksak = 'B'.
             read table it_vbup with key vbeln = zt_ad01repdmr-vbeln
                                         posnr = zt_ad01repdmr-posnr.
             if sy-subrc = 0 and it_vbup-fksaa = 'C'.
                check v_tabix <> '000'.
                delete zt_ad01repdmr index v_tabix.
             endif.
         endif.
      else.
         check v_tabix <> '000'.
         delete zt_ad01repdmr index v_tabix.
      endif.
    endloop.
    ENDFORM.                    " filter_compl_ords

    regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2006 at 08:28 AM

    Thomas,

    Did you look at the parameter BAPIPARNRC?

    It has new and old partner numbers.

    Or is it that you just want to change the name of the partner in the address alone?

    Regards,

    Ravi

    Note : Please mark the helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2006 at 08:30 AM

    You might be able to change it in BAPIADDR1 as well. Both the parameters are part of the funciton BAPI_SALESORDER_CHANGE.

    Regards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 07, 2006 at 09:05 AM

    Sorry, I was not very clear about my question.

    For the funtion modules I am trying to fill BAPIPARNRC and BAPIPARNRC along with BAPISDITM(sales org, dis channel, division), BAPISDITMX(update flag = 'U').

    My question is, if suppose I was to change RE(Bill-to-party) address-name1/name2/street, what all should be the mandatory input fields for BAPIPARNRC and BAPIPARNRC?

    Believe I clarifued my doubt properly.

    Thanks,

    Thomas.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 17, 2008 at 08:26 PM

    Hi Thomas,

    I need your help on changing the address details of ship to party customer using BAPI_CUSTOMERCONTRACT_CHANGE.Currently i am able to change the Partner no using PARTNERCHANGES table (BAPIPARNRC strucuture).But it doesnt have option to pass any other details like name,sytreet,city,state.....I tried to pass these details in PARTNERS (BAPIPARNR )table.but it is not changing the address details.Please help me on this.

    Regards,

    Vigneswaran S

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Vigneswaran S,

      I would like to ask on how did you change the partner numbers for AG, WE, and RE using BAPI_CUSTOMERCONTRACT_CHANGE?

      Because i do have a dev work which needs to update the Bill-to-party, Sold-to-party, and Ship-to-party values.

      Hope you'll be able to help me with this...

      Thanks and have a nice day!

      regards,

      Noel

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.