cancel
Showing results for 
Search instead for 
Did you mean: 

How to make territory ID field mandatory

Former Member
0 Kudos

Hello All,

I have to make Territory ID field mandatory when user wants to save...i wrote the code by implementing new implementation in ORDER_SAVE  but it is not making any effect on UI screen even it is not going in debugger also...please suggest what step we need to follow and where we need to write the code ?

Also guys tell me how can i see my older posts here in new SCN ?

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Saurabh,

If the Terr ID is a WebUI Field, you can make it mandatory in the UI config tool itself.

ORDER_SAVE badi works only for One orders like quotations, appointments, activities, orders, contracts etc...

If the Terr ID belongs to Account/Contact or Terr Mgmt, then Oder_save badi does not works out.

I would suggest to use UI Config Tool as the easiest way to make any field mandatory in the WebUI,

Former Member
0 Kudos

Hello Satish & Mauro,

Hi All,

I have made the Territory ID field mandatory in view BT111H_OPPT in configuration and also i have implemented a Z method in 'CHECK_BEFORE_SAVE'  and wrote the below code:

   CALL METHOD me->terr_input_val
   EXPORTING
     iv_guid        = iv_guid
    CHANGING
     cv_own_message = cv_own_message
   EXCEPTIONS
      do_not_save    = 1
     OTHERS         = 2.
  IF sy-subrc IS NOT INITIAL.
    RAISE do_not_save.
  ENDIF.

and inside the method 'TERR_INPUT_VAL'  i wrote below code:

   DATA: ls_partner_wrk        TYPE crmt_partner_external_wrk,
       lv_terr               TYPE crmt_territory_path_id.
CONSTANTS: lc_emp_resp_pfct TYPE crmt_partner_fct VALUE '00000014',
             lc_ref_kind      TYPE crmt_object_kind VALUE 'A'.
   CALL FUNCTION 'CRM_PARTNER_READ_OW'
      EXPORTING
       iv_ref_guid          = iv_guid
        iv_ref_kind          = lc_ref_kind
       iv_partner_fct       = lc_emp_resp_pfct
IMPORTING
       es_partner_wrk       = ls_partner_wrk
     EXCEPTIONS
        error_occurred       = 1
       parameter_error      = 2
       entry_does_not_exist = 3
       OTHERS               = 4.
   CHECK sy-subrc IS INITIAL AND ls_partner_wrk IS NOT INITIAL.
***Read the Territory ID determined in the Opportunity
    lv_terr = ls_partner_wrk-attribute_values-comt_attr_territory-path_id.
    IF lv_terr IS INITIAL.
RAISE do_not_save.
    ENDIF.
  ENDIF.

but problem is that when i am going to created an opportunity then after giving input when i click on CANCEL button then it is giving error for all field 'Field is not Bound' even i have set BSPWD_SHOW_NOT_BOUND = 'N' in user profile.

Please let us know if i have to write some other code or i have to do something in configuration of UI.?

Regards

Former Member
0 Kudos

Hello Satish & Mauro,

Hi All,

I have made the Territory ID field mandatory in view BT111H_OPPT in configuration and also i have implemented a Z method in 'CHECK_BEFORE_SAVE'  and wrote the below code:

   CALL METHOD me->terr_input_val
   EXPORTING
     iv_guid        = iv_guid
    CHANGING
     cv_own_message = cv_own_message
   EXCEPTIONS
      do_not_save    = 1
     OTHERS         = 2.
  IF sy-subrc IS NOT INITIAL.
    RAISE do_not_save.
  ENDIF.

and inside the method 'TERR_INPUT_VAL'  i wrote below code:

   DATA: ls_partner_wrk        TYPE crmt_partner_external_wrk,
       lv_terr               TYPE crmt_territory_path_id.
CONSTANTS: lc_emp_resp_pfct TYPE crmt_partner_fct VALUE '00000014',
             lc_ref_kind      TYPE crmt_object_kind VALUE 'A'.
   CALL FUNCTION 'CRM_PARTNER_READ_OW'
      EXPORTING
       iv_ref_guid          = iv_guid
        iv_ref_kind          = lc_ref_kind
       iv_partner_fct       = lc_emp_resp_pfct
IMPORTING
       es_partner_wrk       = ls_partner_wrk
     EXCEPTIONS
        error_occurred       = 1
       parameter_error      = 2
       entry_does_not_exist = 3
       OTHERS               = 4.
   CHECK sy-subrc IS INITIAL AND ls_partner_wrk IS NOT INITIAL.
***Read the Territory ID determined in the Opportunity
    lv_terr = ls_partner_wrk-attribute_values-comt_attr_territory-path_id.
    IF lv_terr IS INITIAL.
RAISE do_not_save.
    ENDIF.
  ENDIF.

but problem is that when i am going to created an opportunity then after giving input when i click on CANCEL button then it is giving error for all field 'Field is not Bound' even i have set BSPWD_SHOW_NOT_BOUND = 'N' in user profile.

Please let us know if i have to write some other code or i have to do something in configuration of UI.?

Regards

Former Member
0 Kudos

Hi,

in your code you are raising an exception (and probably this is causing the further troubles.. you should add some checks more)

In my opinion I would implement order_save badi adding a code like this:

lr_core = cl_crm_bol_core=>get_instance( ).
       lr_core->start_up( 'ALL' ).
       zir_mess_cont = lr_core->get_global_message_cont( ).





       call method zir_mess_cont->add_message
         exporting
           iv_msg_type       = 'W'
           iv_msg_id         = 'Z_SALES_ORDINI'
           iv_msg_number     = '000'
           iv_show_only_once = abap_false.

In this case you are raising an error(or a warning) within the container.

Former Member
0 Kudos

Hello Mauro,

Thanks for reply...Actually i am getting error 'Field not bound' while clicking on CANCEL button on opportunity create screen and in that case ORDER_SAVE is not executing. so can you please tell me why this error is coming? is this because of code written in ORDER_SAVE ? or i will have to check somthing else?

Regards.

Former Member
0 Kudos

Hi,

don't raise the exception and add an error message (as suggested in my code).

It's much safer than RAISE do_not_save especially when you are "cancelling" a transaction.


Former Member
0 Kudos

Even i checked with your said code but in this case it allowing the user to save the opportunity without giving any input in Territory ID...Please let me know if i am missing somthing...

what i did...:

1. i just made Territory ID field mandatory in BT111H_OPPT/Details

2. wrote the above mentioned codes in ORDE_SAVE

Please advise accordingly so that it give error while user try to save opportunity without territory ID and when user clicks on 'CANCEL' button then return back on opportunity create screen without mentioned error.

Regards

Former Member
0 Kudos
Former Member
0 Kudos

Hello Mauro,

Thanks for reply...Now i have commented the codes written in ORDER_SAVE and putted the mandatory condition only in BT111H_OPPT/Details but still when i click on CANCEL button during opportunity creation then i get same error for all fields 'Filed not bound'...please suggest accordingly.

Regards

Former Member
0 Kudos

but did you implement the note?

Former Member
0 Kudos

Yes, i have implemented the note but still getting same error 'Filed Not Bound' while clicking on CANCEL button in middle of opportunity creation.. please suggest.

Regards

Former Member
0 Kudos

Set your badi implementations inactive (inactive all the order_save implementations). I think that you forgot to comment some codes around...

Former Member
0 Kudos

Hi Mauro,

I deactivated the BADI but still getting same error while clicking on CANCEL button...plz suggest.

Former Member
0 Kudos

Hi Mauro,

I deactivated the BADI but still getting same error while clicking on CANCEL button...plz suggest.

Former Member
0 Kudos

Very strange.... honestly I'm running out of solution.

Have you searched for SAP notes? By the way you might try in transactin CRMD_ORDER transaction in SAP GUI (normally the log is much more verbose here)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

are you sure that your implementation works correctly? did you debug it? and which method did you implement?

By the way why don't you simply mark the field mandatory in UI?