0% found this document useful (0 votes)
357 views9 pages

Configuration Change Via BAPI

This document provides instructions for modifying an existing sales order configuration using BAPIs. It includes: 1) An example report that retrieves an order's configuration and allows changing characteristic values. 2) Instructions for configuring text elements and documentation for the report. 3) Information on valid releases and related notes.

Uploaded by

Bora Gür
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
0% found this document useful (0 votes)
357 views9 pages

Configuration Change Via BAPI

This document provides instructions for modifying an existing sales order configuration using BAPIs. It includes: 1) An example report that retrieves an order's configuration and allows changing characteristic values. 2) Instructions for configuring text elements and documentation for the report. 3) Information on valid releases and related notes.

Uploaded by

Bora Gür
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 9

SAP Note No. 562124 16.05.

2003 Page 1
________________________________________________________________________

Number 562124
Version 4 from 06.12.2002
Status Released for Customer
Set on 06.12.2002

Language EN
Master language DE
Short text Configuration change via BAPI

Responsible SAP AG
Component SD-SLS-GF-VA
SD BOM, Variant processing
________________________________________________________________________

Long text

Symptom
A sales order contains configured items.You want to change the
characteristic valuation via BAPI.

Additional key words


BAPI, configuration, BAPISDORDER_GETDETAILEDLIST, BAPI_SALESORDER_CHANGE

Cause and preconditions

Solution
This note provides an example report which changes the valuation of an
existing configuration. This report is meant to be an example report.

1. First, create report Z_BAPI_CHANGE_CFG in the customer namespace


(without TOP include) according to the correction instructions.

Then create includes Z_BAPI_CHANGE_DATA and Z_BAPI_CHANGE_FORMS.

2. Maintain the following text elements:

Text symbols:

001 Document entry

002 Display/change document

003 Options: change document

004 Characteristic valuation

005 Characteristics to be changed (config_id/inst_id/charc/value)

006 Incorrect entry

007 Return table


Page 2
Selection texts:

P_LS_ATP ATP mode

P_LS_NOS Do not explode BOM

P_LS_PR Pricing type

P_LS_SCH Schedule lines (A, X, ...)

P_METHOD R/3 configurator

P_SHOW Display document only

P_TEST Database update

P_VBELN Sales document

S_VAL New characteristics

Select the dictionary reference for P_LS_ATP and P_LS_PR.

3. Enter the following documentation:

under 'PURPOSE'

This report is used to change the configuration of existing sales


documents.You can first display the current characteristic valuation
and then change the valuation of the characteristics.

You can also, for example, reprocess an external configuration with


the R/3 configurator to explode text items again or to carry out a
material variant substitution, and so on.

You can use the following input fields:

o Display document only

If you select this field, the system displays the current


characteristic valuation for the document in a simple list.

o R/3 configurator

This field controls whether a configuration is processed by the


R/3 configurator or the SCE configurator (direct storage on the
database).This can be useful during the processing of documents
that were created in the CRM server.

o Database update

If you want to save the result of the report on the database, set
this flag.
Page 3
o New characteristics

Here, specify all characteristics with their new valuation that


you want to change. Use the following format:

config_id/inst_id/charc/value, for example


000001/00000001/COLOR/RED

________________________________________________________________________

Valid releases
Software Component Release
from to

SAP_APPL SAP Application 470 - 470


46C - 46C
46B - 46B

________________________________________________________________________

Reference to related Notes

Number Short text


____________________________________________________________
612850 BAPI_SALESORDER_CHANGE:characteristc value assgnmnt n changd
550431 FAQ: BAPI in sales - general questions

________________________________________________________________________
Page 4

Assigned Correction Instructions


________________________________________________________________________

*$*$----------------------------------------------------------------$*$*
*$ Correction Inst. 0120061532 0000473124 $*
*$--------------------------------------------------------------------$*
*$ Valid for : $*
*$ Software Component SAP_APPL SAP Application $*
*$ Release 46B All Support Package Levels $*
*$ Release 46C All Support Package Levels $*
*$ Release 470 All Support Package Levels $*
*$--------------------------------------------------------------------$*
*$ Changes/Objects Not Contained in Standard SAP System $*
*$*$----------------------------------------------------------------$*$*
*&---------------------------------------------------------------------*
*& Object REPS Z_BAPI_CHANGE_CFG
*& Object Header PROG Z_BAPI_CHANGE_CFG
*&---------------------------------------------------------------------*
*& REPORT Z_BAPI_CHANGE_CFG
*&---------------------------------------------------------------------*
*>>>> START OF INSERTION <<<<
*&---------------------------------------------------------------------*
*& Report Z_BAPI_CHANGE_CFG *
*& *
*&---------------------------------------------------------------------*
*& This report can be used to change the characteristic value *
*& assignment of the configuration in existing sales documents easily. *
*&---------------------------------------------------------------------*

REPORT z_bapi_change_cfg .

* Data Declaration
INCLUDE z_bapi_change_cfg_data.
* Forms
INCLUDE z_bapi_change_cfg_forms.

*----------------------------------------------------------------------*
* Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK text-001
WITH FRAME TITLE text-001.
PARAMETERS: p_vbeln TYPE vbak-vbeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK text-001.

SELECTION-SCREEN BEGIN OF BLOCK text-002


WITH FRAME TITLE text-002.
PARAMETERS: p_show AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK text-002.

SELECTION-SCREEN BEGIN OF BLOCK text-005


WITH FRAME TITLE text-005.
SELECT-OPTIONS: s_val FOR ls_val NO INTERVALS.
SELECTION-SCREEN END OF BLOCK text-005.

SELECTION-SCREEN BEGIN OF BLOCK text-003


WITH FRAME TITLE text-003.
PARAMETERS: p_method AS CHECKBOX,
Page 5

p_test AS CHECKBOX,
p_ls_nos LIKE bapisdls-nostructure,
p_ls_pr LIKE bapisdls-pricing,
p_ls_atp LIKE bapisdls-atp_wrkmod,
p_ls_sch LIKE bapisdls-scheduling.
SELECTION-SCREEN END OF BLOCK text-003.
*----------------------------------------------------------------------*

START-OF-SELECTION.

ls_vbeln-vbeln = p_vbeln.
APPEND ls_vbeln TO lt_vbeln.

* Select the output tables


ls_bapi_view-header = 'X'.
ls_bapi_view-item = 'X'.
ls_bapi_view-sdschedule = 'X'.
ls_bapi_view-partner = 'X'.
ls_bapi_view-sdcond = 'X'.
ls_bapi_view-configure = 'X'.

* Get the salesorder data


CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
EXPORTING
i_bapi_view = ls_bapi_view
TABLES
sales_documents = lt_vbeln
order_headers_out = lt_header
order_items_out = lt_item
order_schedules_out = lt_schedules
order_partners_out = lt_partners
order_conditions_out = lt_conditions
order_cfgs_curefs_out = lt_curefs
order_cfgs_cucfgs_out = lt_cucfgs
order_cfgs_cuins_out = lt_cuins
order_cfgs_cuprts_out = lt_cuprts
order_cfgs_cuvals_out = lt_cuvals
order_cfgs_cublbs_out = lt_blob
order_cfgs_cuvks_out = lt_cuvks.

* Only Display characteristic assignment


IF NOT p_show IS INITIAL.

IF NOT lt_cuvals[] IS INITIAL.


WRITE: / text-004,
AT /(15) 'CONFIG_ID' COLOR COL_HEADING,
AT (15) 'INST_ID' COLOR COL_HEADING,
AT (25) 'CHARC' COLOR COL_HEADING,
AT (25) 'VALUE' COLOR COL_HEADING.

LOOP AT lt_cuvals INTO ls_cuvals.


WRITE: AT /(15) ls_cuvals-config_id COLOR COL_NORMAL,
AT (15) ls_cuvals-inst_id COLOR COL_NORMAL,
AT (25) ls_cuvals-charc COLOR COL_NORMAL,
AT (25) ls_cuvals-value COLOR COL_NORMAL.
ENDLOOP.
Page 6

ELSE.
MESSAGE i001(cuib1).
ENDIF.

ELSE.

* Change values for characteristics


IF NOT s_val IS INITIAL.
LOOP AT s_val INTO ls_val.
SPLIT ls_val+3 AT '/' INTO ls_cuvals-config_id
ls_cuvals-inst_id
ls_cuvals-charc
ls_cuvals-value.
APPEND ls_cuvals TO lt_cuval_ch.
ENDLOOP.

LOOP AT lt_cuval_ch.
READ TABLE lt_cuvals INTO ls_cuvals WITH KEY
config_id = lt_cuval_ch-config_id
inst_id = lt_cuval_ch-inst_id
charc = lt_cuval_ch-charc.
IF sy-subrc = 0 AND
ls_cuvals-author is initial.
ls_cuvals-value = lt_cuval_ch-value.
MODIFY lt_cuvals FROM ls_cuvals INDEX sy-tabix.
ELSE.
MESSAGE e111(cu) WITH lt_cuval_ch-charc
lt_cuval_ch-value
text-006.
ENDIF.
ENDLOOP.
ENDIF.

* Delete SCE Flag in order to call R/3 configurator


IF NOT p_method IS INITIAL.
LOOP AT lt_cucfgs INTO ls_cucfgs WHERE NOT sce IS initial.
CLEAR ls_cucfgs-sce.
MODIFY lt_cucfgs FROM ls_cucfgs.
ENDLOOP.
ENDIF.

* Update flags for BAPI


lt_header_x-updateflag = 'U'.
LOOP AT lt_item INTO ls_item.
ls_item_x-itm_number = ls_item-itm_number.
ls_item_x-updateflag = 'U'.
ls_item_x-config_id = 'X'.
ls_item_x-po_itm_no = 'X'.
APPEND ls_item_x TO lt_item_x.
ENDLOOP.

* Convert configuration data


PERFORM convert_cfg_data.

* Call change bapi


CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
Page 7

EXPORTING
salesdocument = p_vbeln
order_header_inx = lt_header_x
logic_switch = ls_logic
TABLES
return = lt_return
order_item_in = lt_items
order_item_inx = lt_item_x
order_cfgs_ref = lt_cfgs_ref
order_cfgs_inst = lt_inst
order_cfgs_part_of = lt_parts
order_cfgs_value = lt_values
order_cfgs_blob = lt_cublob
order_cfgs_vk = lt_cuvk
order_cfgs_refinst = lt_curef.

* Database update
IF NOT p_test IS INITIAL.
COMMIT WORK.
ENDIF.

* Return Table
WRITE: / text-007,
AT /(5) 'TYPE' COLOR COL_HEADING,
AT (15) 'ID' COLOR COL_HEADING,
AT (7) 'NUMBER' COLOR COL_HEADING,
AT (80) 'MESSAGE' COLOR COL_HEADING.

LOOP AT lt_return INTO ls_return.


WRITE: AT /(5) ls_return-type COLOR COL_NORMAL,
AT (15) ls_return-id COLOR COL_NORMAL,
AT (7) ls_return-number COLOR COL_NORMAL,
AT (80) ls_return-message COLOR COL_NORMAL.
ENDLOOP.

ENDIF.
*>>>> END OF INSERTION <<<<<<
...
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Object REPS Z_BAPI_CHANGE_CFG_DATA
*& Object Header PROG Z_BAPI_CHANGE_CFG_DATA
*&---------------------------------------------------------------------*
*>>>> START OF INSERTION <<<<

*----------------------------------------------------------------------*
* INCLUDE Z_BAPI_CHANGE_CFG_DATA *
*----------------------------------------------------------------------*
* Data declaration
DATA: ls_val(180) TYPE C,
ls_vbeln TYPE sales_key,
lt_vbeln TYPE TABLE OF sales_key,
ls_bapi_view TYPE order_view,
ls_logic TYPE bapisdls,
lt_header TYPE TABLE OF bapisdhd,
lt_header_x TYPE bapisdh1x,
ls_item TYPE bapisdit,
ls_items TYPE bapisditm,
Page 8

lt_item TYPE TABLE OF bapisdit,


lt_items TYPE TABLE OF bapisditm,
lt_item_x TYPE TABLE OF bapisditmx,
ls_item_x TYPE bapisditmx,
lt_schedules TYPE TABLE OF bapisdhedu,
lt_partners TYPE TABLE OF bapisdpart,
lt_conditions TYPE TABLE OF bapisdcond,
ls_curefs TYPE bapicurefm,
lt_curefs TYPE TABLE OF bapicurefm,
ls_cucfgs TYPE bapicucfgm,
lt_cucfgs TYPE TABLE OF bapicucfgm,
ls_cuins TYPE bapicuinsm,
lt_cuins TYPE TABLE OF bapicuinsm,
ls_cuprts TYPE bapicuprtm,
lt_cuprts TYPE TABLE OF bapicuprtm,
ls_cuvals TYPE bapicuvalm,
lt_cuvals TYPE TABLE OF bapicuvalm,
lt_cuval_ch TYPE TABLE OF bapicuvalm WITH HEADER LINE,
ls_blob TYPE bapicublbm,
lt_blob TYPE TABLE OF bapicublbm,
ls_cuvks TYPE bapicuvkm,
lt_cuvks TYPE TABLE OF bapicuvkm,
ls_return TYPE bapiret2,
lt_return TYPE TABLE OF bapiret2,
ls_cfgs_ref TYPE bapicucfg,
lt_cfgs_ref TYPE TABLE OF bapicucfg,
ls_inst TYPE bapicuins,
lt_inst TYPE TABLE OF bapicuins,
ls_parts TYPE bapicuprt,
lt_parts TYPE TABLE OF bapicuprt,
ls_values TYPE bapicuval,
lt_values TYPE TABLE OF bapicuval,
ls_cublob TYPE bapicublb,
lt_cublob TYPE TABLE OF bapicublb,
ls_cuvk TYPE bapicuvk,
lt_cuvk TYPE TABLE OF bapicuvk,
ls_curef TYPE bapicuref,
lt_curef TYPE TABLE OF bapicuref.

*>>>> END OF INSERTION <<<<<<


...
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Object REPS Z_BAPI_CHANGE_CFG_FORMS
*& Object Header PROG Z_BAPI_CHANGE_CFG_FORMS
*&---------------------------------------------------------------------*
*>>>> START OF INSERTION <<<<

*----------------------------------------------------------------------*
* INCLUDE Z_BAPI_CHANGE_CFG_FORMS *
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
* Data conversion:
* BAPISDORDER_GETDETAILEDLIST => BAPI_SALESORDER_CHANGE
*----------------------------------------------------------------------*
FORM convert_cfg_data.
Page 9

LOOP AT lt_item INTO ls_item.


ls_items-itm_number = ls_item-itm_number.
ls_items-hg_lv_item = ls_item-hg_lv_item.
ls_items-po_itm_no = ls_item-itm_number.
ls_items-material = ls_item-material.
append ls_items to lt_items.
ENDLOOP.

LOOP AT lt_cucfgs INTO ls_cucfgs.


ls_cfgs_ref-posex = ls_cucfgs-posex.
ls_cfgs_ref-config_id = ls_cucfgs-config_id.
ls_cfgs_ref-root_id = ls_cucfgs-root_id.
ls_cfgs_ref-sce = ls_cucfgs-sce.
ls_cfgs_ref-kbname = ls_cucfgs-kbname.
ls_cfgs_ref-kbversion = ls_cucfgs-kbversion.
APPEND ls_cfgs_ref TO lt_cfgs_ref.
ENDLOOP.

LOOP AT lt_cuins INTO ls_cuins.


ls_inst-config_id = ls_cuins-config_id.
ls_inst-inst_id = ls_cuins-inst_id.
ls_inst-obj_type = ls_cuins-obj_type.
ls_inst-class_type = ls_cuins-class_type.
ls_inst-obj_key = ls_cuins-obj_key.
APPEND ls_inst TO lt_inst.
ENDLOOP.

LOOP AT lt_cuprts INTO ls_cuprts.


ls_parts-config_id = ls_cuprts-config_id.
ls_parts-parent_id = ls_cuprts-parent_id.
ls_parts-inst_id = ls_cuprts-inst_id.
ls_parts-part_of_no = ls_cuprts-part_of_no.
ls_parts-obj_type = ls_cuprts-obj_type.
ls_parts-class_type = ls_cuprts-class_type.
ls_parts-obj_key = ls_cuprts-obj_key.
APPEND ls_parts TO lt_parts.
ENDLOOP.

LOOP AT lt_cuvals INTO ls_cuvals.


ls_values-config_id = ls_cuvals-config_id.
ls_values-inst_id = ls_cuvals-inst_id.
ls_values-charc = ls_cuvals-charc.
ls_values-value = ls_cuvals-value.
ls_values-author = ls_cuvals-author.
APPEND ls_values TO lt_values.
ENDLOOP.

LOOP AT lt_blob INTO ls_blob.


ls_cublob-config_id = ls_blob-config_id.
ls_cublob-context = ls_blob-context.
APPEND ls_cublob TO lt_cublob.
ENDLOOP.

LOOP AT lt_cuvks INTO ls_cuvks.


ls_cuvk-config_id = ls_cuvks-config_id.
ls_cuvk-inst_id = ls_cuvks-inst_id.
ls_cuvk-vkey = ls_cuvks-vkey.
Page 10

ls_cuvk-factor = ls_cuvks-factor.
APPEND ls_cuvk TO lt_cuvk.
ENDLOOP.

*>>>> END OF INSERTION <<<<<<


...
*&---------------------------------------------------------------------*

You might also like