Skip to Content
0
Former Member
Jan 09, 2007 at 09:33 PM

Order - Update pricing date with requested delivery date?

37 Views

Kia Ora!

Business requires the pricing date in Pricing for a sales order line with the requested delivery date, when the order is created or changed.

I attempted the following code in the BADI IF_EX_ORDER_SAVE~PREPARE,

  • Read the Order (with Items) based on the GUID (iv_guid)

CALL FUNCTION 'CRM_ORDER_READ'

EXPORTING

it_header_guid = lt_header_guid

iv_no_auth_check = 'X'

IMPORTING

et_pricing = lt_pricing

et_sales = lt_sales "(Requested delivery date is BLANK)

EXCEPTIONS

document_not_found = 1

error_occurred = 2

document_locked = 3

no_change_authority = 4

no_display_authority = 5

no_change_allowed = 6.

FIELD-SYMBOLS: <pricing> TYPE LINE OF crmt_pricing_wrkt.

DATA: ls_pricing TYPE crmt_pricing_com,

lt_exception TYPE crmt_exception_t,

lt_pricing2 TYPE crmt_pricing_comt.

LOOP AT lt_pricing ASSIGNING <pricing> WHERE ref_kind = 'B'.

<pricing>-price_date = sy-datum + 2. "Hardcoding just to test

MOVE-CORRESPONDING <pricing> TO ls_pricing.

APPEND ls_pricing TO lt_pricing2.

data: ls_input_field TYPE crmt_input_field,

ls_input_field_names TYPE crmt_input_field_names,

lt_input_field_names TYPE crmt_input_field_names_tab.

ls_input_field-ref_guid = <pricing>-guid.

ls_input_field-objectname = 'PRICING'.

ls_input_field-ref_kind = 'B'.

ls_input_field_names-fieldname = 'PRICE_DATE'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field-field_names = lt_input_field_names.

append ls_input_field to lt_input_fields.

ENDLOOP.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

EXPORTING

it_pricing = lt_pricing2

IMPORTING

et_exception = lt_exception

CHANGING

ct_input_fields = lt_input_fields

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 4

OTHERS = 5.

Does not update the pricing date at all.

Any help is much appreciated.

TIA

John Kuriakose