cancel
Showing results for 
Search instead for 
Did you mean: 

change item condition in BADI order save with crm_order_maintain

Former Member
0 Kudos

Hi all,

i could update conditions in report but not successful in BADI order save, below is my code in BADI...

what is the problem maybe ? Ths


* Get order info.
  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      it_header_guid       = lt_header_guid
      it_requested_objects = lt_requested_objects
    IMPORTING
      et_ORDERADM_I        = lt_ORDERADM_I
      ET_TEXT              = lt_text
      ET_STATUS            = lt_status
      et_pridoc            = et_pridoc
    EXCEPTIONS
      DOCUMENT_NOT_FOUND   = 1
      ERROR_OCCURRED       = 2
      DOCUMENT_LOCKED      = 3
      NO_CHANGE_AUTHORITY  = 4
      NO_DISPLAY_AUTHORITY = 5
      NO_CHANGE_ALLOWED    = 6
      OTHERS               = 7.

read table lt_ORDERADM_I into ls_ORDERADM_I with key ITM_TYPE = 'YTS1'.
  if sy-subrc = 0.
    read table et_pridoc INTO es_pridoc index 1.

    LOOP AT es_pridoc-pric_cond into es_pric_cond where kposn = ls_ORDERADM_I-guid.
      clear is_cond_chg.
      move-corresponding es_pric_cond to is_cond_chg.
      clear is_cond_chg-kbetr.   "  clear the amount
      INSERT is_cond_chg INTO TABLE is_pridoc-cond_change.
    endloop.

    CLEAR: lt_input_field_names.
    ls_input_field_names-fieldname = 'COND_CHANGE'.
    INSERT ls_input_field_names INTO TABLE lt_input_field_names.

    CLEAR: cs_input_fields, ct_input_fields.
    cs_input_fields-ref_guid = ls_ORDERADM_I-guid.
    cs_input_fields-ref_kind = 'B'.
    cs_input_fields-objectname = 'PRIDOC'.
    cs_input_fields-field_names = lt_input_field_names.
    INSERT cs_input_fields INTO table ct_input_fields.


    is_pridoc-ref_guid = ls_ORDERADM_I-guid.
    is_pridoc-ref_kind = 'B'.
    INSERT is_pridoc INTO it_pridoc INDEX 1.

  endif.

  CALL FUNCTION 'CRM_ORDER_MAINTAIN'
    EXPORTING
      it_pridoc         = it_pridoc
    CHANGING
      ct_input_fields   = ct_input_fields
    EXCEPTIONS
      error_occurred    = 1
      document_locked   = 2
      no_change_allowed = 3
      no_authority      = 4
      OTHERS            = 5.




Accepted Solutions (0)

Answers (2)

Answers (2)

saumya_govil
Active Contributor
0 Kudos

Hi Gang Li,

In which method of the BAdI have you written this code?

What exactly is the error you are getting? Try debugging the code line by line and check if you are getting the value for the GUID, passing the correct parametets, etc.

Regards,

Saumya

Former Member
0 Kudos

Hi ,

In which method have you written the code i.e CHECK_BEFORE_SAVE , CHANGE_BEFORE_UPDATE or PREPARE.

Thank you,

Gangadhar.S

rb
Active Participant
0 Kudos

Try this Function Modul after Order_Maintain

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   = 
      IMPORTING
        return = .

Edited by: Richard Brünning on Nov 12, 2009 1:55 PM