Skip to Content
0
Former Member
Jul 02, 2007 at 12:09 PM

help on Funtion module

18 Views

hi experts,

Plz help me in using the FM 'PRC_PD_ITEM_CHANGE_COND'.

below is my coding to change value of a pricing condition,

DATA : LV_HEADER_GUID TYPE CRMT_OBJECT_GUID,

LV_PD_HANDLE TYPE PRCT_HANDLE,

LV_PRIC_PROC TYPE PRCT_PRIC_PROC,

LV_NEW_PRICING TYPE CRMT_BOOLEAN,

LV_OBJECT_GUID TYPE PRCT_ITEM_NO,

  • LV_DATA_CHANGED TYPE XFELD,

LV_PRIDOC_GUID TYPE PRCT_PRIDOC_GUID,

LV_BALH TYPE BALLOGHNDL,

LV_BALG TYPE BALLOGHNDL,

LV_DTASRC TYPE PRCT_DATA_SOURCE2.

DATA : LS_COND TYPE PRCT_COND_EXTERNAL_INPUT,

LT_COND TYPE PRCT_COND_EXTERNAL_INPUT_T,

  • LS_ITEM_RET TYPE PRCT_ITEM_RET,

LT_COND_PRT TYPE PRCT_COND_PRINT_T,

LT_COND_CHANGE TYPE PRCT_COND_EXTERNAL_CHANGE_T,

LS_COND_CHANGE TYPE PRCT_COND_EXTERNAL_CHANGE,

LS_ITEM_RET1 TYPE PRCT_ITEM_RET,

LT_ITEM_RET1 TYPE PRCT_ITEM_RET_T,

LT_COND_PRT1 TYPE PRCT_COND_PRINT_T,

LV_DATA_CHANGED1 TYPE XFELD.

  • LT_CONDS_FAULT TYPE PRCT_COND_EXTERNAL_CHANGE_T.

DATA : LT_PRCD_COND TYPE TABLE OF PRCD_COND,

LS_PRCD_COND LIKE LINE OF LT_PRCD_COND,

LT_HEADER_GUID TYPE CRMT_OBJECT_GUID_TAB.

*Local Varialble To hold Header GUID

LV_HEADER_GUID = 'DC1FFA19F26BFFF1B239001321CCD6DC'.

APPEND LV_HEADER_GUID TO LT_HEADER_GUID.

*Local Varialble To hold Object GUID

LV_OBJECT_GUID = 'DC1FFA19F26C7AF1B239001321CCD6DC'.

CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'

EXPORTING

IV_HEADER_GUID = LV_HEADER_GUID

IV_NO_CREATION = 'X'

  • IV_PRIC_PROC =

  • IV_ORGDATA_CHANGED = FALSE

  • IV_SOLD_TO_CHANGED = FALSE

IMPORTING

EV_PD_HANDLE = LV_PD_HANDLE

EV_PRICING_PROCEDURE = LV_PRIC_PROC

EV_NEW_PRICING_DOCUMENT = LV_NEW_PRICING

EV_PRIDOC_GUID = LV_PRIDOC_GUID

  • EXCEPTIONS

  • ERROR_OCCURRED = 1

  • HANDLE_DETERMINATION_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

SELECT * FROM PRCD_COND INTO TABLE LT_PRCD_COND WHERE KNUMV = LV_PRIDOC_GUID AND KSCHL = 'ZCIN'.

CHECK SY-SUBRC = 0.

READ TABLE LT_PRCD_COND INTO LS_PRCD_COND WITH KEY KSCHL = 'ZCIN'.

  • CHECK SY-SUBRC = 0.

LS_COND_CHANGE-STUNR = LS_PRCD_COND-STUNR.

LS_COND_CHANGE-ZAEHK = LS_PRCD_COND-ZAEHK.

*LS_COND_CHANGE-KWERT = '12345'.

LS_COND_CHANGE-KBETR = '12345'.

LS_COND_CHANGE-KNUMH = LV_PRIDOC_GUID.

LV_DTASRC = LS_PRCD_COND-DTASRC.

INSERT LS_COND_CHANGE INTO TABLE LT_COND_CHANGE.

CALL FUNCTION 'CRM_PRP_SAVE'

EXPORTING

IV_OBJECT_GUID = LV_OBJECT_GUID

CHANGING

CV_LOG_HANDLE = LV_BALH

.

data : ls_item_ret type PRCT_ITEM_RET,

lt_item_ret type PRCT_ITEM_RET_T,

lv_data_changed type XFELD,

lt_conds_fault type PRCT_COND_EXTERNAL_CHANGE_T.

*Function module to update a condition type

CALL FUNCTION 'PRC_PD_ITEM_CHANGE_COND'

EXPORTING

IV_PD_HANDLE = LV_PD_HANDLE

IV_BAL_LOG = LV_BALH

IV_ITEM_NO = LV_PRIDOC_GUID

IV_DTASRC2 = LV_DTASRC

IT_COND_CHANGE = LT_COND_CHANGE

IV_SUPPRESS_CHECKS = 'X'

IMPORTING

ES_ITEM_RET = ls_item_ret

ET_ITEM_RET = lt_item_ret

ET_COND_PRT = LT_COND_PRT1

EV_DATA_CHANGED = lv_data_changed

ET_CONDS_FAULT = lt_conds_fault

EXCEPTIONS

NON_EXISTING_HANDLE = 1

NON_EXISTING_ITEM = 2

IPC_ERROR = 3

NOT_ALLOWED = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'CRM_EVENT_PUBLISH_OW'

EXPORTING

iv_obj_name = 'PRIDOC_COM' "gc_object_name-pridoc_com

iv_guid_hi = lv_header_guid

iv_kind_hi = 'A' "gc_object_kind-orderadm_h

iv_event = 'AFTER_CHANGE' "gc_event-after_change

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION 'CRM_ORDER_SAVE'

EXPORTING

IT_OBJECTS_TO_SAVE = LT_HEADER_GUID

  • IV_UPDATE_TASK_LOCAL = FALSE

  • IV_SAVE_FRAME_LOG = FALSE

  • IV_NO_BDOC_SEND = FALSE

  • IMPORTING

  • ET_SAVED_OBJECTS =

  • ET_EXCEPTION =

  • ET_OBJECTS_NOT_SAVED =

  • CHANGING

  • CV_LOG_HANDLE =

  • EXCEPTIONS

  • DOCUMENT_NOT_SAVED = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

COMMIT WORK.