Skip to Content
0
Former Member
Dec 14, 2006 at 11:20 AM

crm_order_maintain

55 Views

Hi pppl,

I have tried to populate fields fom my internal table into the standard order using 'crm_order_maintain'. I have implemented the badi "EXEC_METHODCALL_PPF".

I dont get ne errors but data doesnt get populated.

The code is below.Please help......

DATA: lc_action_execute TYPE REF TO cl_action_execute.

IF sy-uname EQ 'VARANA'.

wa_field-tabname = 'ZITEM_PROPOSAL'.

wa_field-fieldname = 'ITEM_PROPOSAL_NO'.

APPEND wa_field TO it_fields.

CALL FUNCTION 'POPUP_GET_VALUES_DB_CHECKED'

EXPORTING

  • CHECK_EXISTENCE = 'X'

popup_title = 'Item Proposal Number'

  • START_COLUMN = '5'

  • START_ROW = '5'

  • IMPORTING

  • RETURNCODE =

TABLES

fields = it_fields

EXCEPTIONS

error_in_fields = 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.

LOOP AT it_fields INTO wa_field.

temp = wa_field-value.

ENDLOOP.

WRITE:/ 'the value is'.

WRITE:/ temp.

IF sy-subrc EQ 0.

SELECT item_proposal_no

material

material_desc

target_quantity

uom FROM zitem_proposal

INTO TABLE it_item

WHERE item_proposal_no = temp.

ENDIF.

  • object for action processing

CREATE OBJECT lc_action_execute.

  • Get guid from reference object

CALL METHOD lc_action_execute->get_ref_object

EXPORTING

io_appl_object = io_appl_object

ip_action = ip_action

ii_container = ii_container

IMPORTING

ev_guid_ref = lv_guid_ref.

APPEND lv_guid_ref TO gv_guids.

*loop at gt_orderadm_h into gwa_orderadm_h.

gwa_orderadm_h-guid = lv_guid_ref.

gwa_orderadm_h-mode = 'A'.

APPEND gwa_orderadm_h TO gt_orderadm_h.

LOOP AT it_item INTO wa_item.

CALL FUNCTION 'CRM_GUID_CREATE'

IMPORTING

ev_guid = lv_item_guid.

wa_prod2-partner_prod = wa_item-material.

wa_prod2-description = wa_item-material_desc.

wa_prod2-number_int = wa_item-item_proposal_no.

wa_prod2-guid = lv_item_guid

.

  • wa_prod2-header = lv_guid_ref.

wa_qty4-quantity = wa_item-target_quantity.

wa_vol2-volume_unit = wa_item-uom.

APPEND wa_vol2 TO wa_vol1.

APPEND wa_prod2 TO wa_prod1.

APPEND wa_qty4 TO wa_qty3.

wa_qty2-schedlines = wa_qty3.

APPEND wa_qty2 TO wa_qty1.

  • Set up the fields to be updated.

CLEAR lt_input_field_names.

ls_input_field_names-fieldname = 'ORDERED_PROD'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field_names-fieldname = 'DESCIPTION_UC'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field_names-fieldname = 'NUMBER_INT'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_fields-ref_handle = '0000000000'.

  • ls_input_fields-ref_guid = lv_guid_ref.

ls_input_fields-objectname = 'ORDERADM_I'.

ls_input_fields-field_names = lt_input_field_names.

INSERT ls_input_fields INTO TABLE lt_input_fields.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

  • EXPORTING

  • it_schedlin_i = wa_qty1

IMPORTING

et_exception = gt_crmt_exception_t

CHANGING

ct_orderadm_h = gt_orderadm_h

ct_orderadm_i = wa_prod1

ct_input_fields = lt_input_fields

EXCEPTIONS

error_occurred = 1

document_locked = 2

no_change_allowed = 3

no_authority = 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.

clear wa_prod2.

clear wa_prod1.

CLEAR wa_qty3.

CLEAR wa_qty1.

ENDLOOP.

  • CALL FUNCTION 'CRM_ORDER_SAVE'

  • EXPORTING

  • it_objects_to_save = gv_guids

  • CHANGING

  • CV_LOG_HANDLE = GT_BALLOGHNDL

  • 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.

  • *

    *

    • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

    ENDIF.