Make field mandatory through coding

Hi experts,
I would like to know if there is a way to make a field mandatory through coding.
I have a field that should become mandatory based on the content of another field.
Any idea on how i can achieve that ?
Thanks for your help.
Regards.
Aw

Hi,
You could implement the DO_HANDLE_EVENT to check if you have value in the first field and based on that make second field as mandatory.
data: lv_wrapper type ref to cl_bsp_wd_collection_wrapper,
lv_order type ref to cl_crm_bol_entity,
lv_value1 type string,
lv_value2 type string,
lv_msgsrv type ref to cl_bsp_wd_message_service.
lv_wrapper = typed_context->[contex_node]->get_collection_wrapper( ).
lv_order ?= lv_wrapper->get_current( ).
* Check for required values
check lv_order is bound.
lv_value1 = lv_bp->get_property_as_string( iv_attr_name = '[first_field]' ).
if lv_value1 is not initial.
lv_value2 = lv_bp->get_property_as_string( iv_attr_name = '[second_field]' ).
if lv_value2 is not initial.
lv_msgsrv = cl_bsp_wd_message_service=>get_instance( ).
lv_msgsrv->add_message( iv_msg_type = 'E'
iv_msg_id = '[you_message_class]'
iv_msg_number = 'your_msg_no'
iv_msg_level = '1' ).
endif.
Hope this helps!
Cheers
Ajay

Similar Messages

  • Help Desk - make fields mandatory and sub catagories

    Is there a way to make fields mandatory (not in the portal) but on the ticket?
    Also, when creating custom attributes, is there a way to make a 'sub attribute' show up based on another attribute?
    thanks!
    This topic first appeared in the Spiceworks Community

    Hello Alex,
    To add a message, you can modify the EH_ONSAVE method of the controller class.
    For a sample code, please see below.
    I hope this helps.
    Kind regards,
    Kristoff.
    data: lv_entity         TYPE REF TO cl_crm_bol_entity,
            lv_coll             TYPE REF TO if_bol_entity_col,
            lv_current        TYPE REF TO if_bol_bo_property_access,
            lv_country          TYPE string,
    Address Data
    *navigate down to Address
        try.
          lv_coll = lv_entity->get_related_entities(
                   iv_relation_name = 'BuilStandardAddressRel' ).
          lv_current = lv_coll->get_current( ).
          catch CX_CRM_GENIL_MODEL_ERROR.
        endtry.
        if lv_current is not bound.
          return.
        endif.
        lv_entity ?= lv_current.
        lv_country = lv_entity->IF_BOL_BO_PROPERTY_ACCESS~GET_PROPERTY_AS_STRING( 'COUNTRY' ).
        IF lv_country IS INITIAL.
              lv_msgsrv->add_message( iv_msg_type = 'E' iv_msg_id = 'Z_CRM_IC' iv_msg_number = '001' ).
              lv_input_nok = 'X'.
        ENDIF.

  • How to make fields mandatory in cost center

    Hi Sap Experts,
    How to make fields mandatory in cost center.
    Please give me advise.
    Regards,
    Raj

    If you want to make "Profit Center" field as mandatory, then OBA5 transaction code
    Application Area - KS
    Number 096
    make this as error for online and batch input. Then profit center will become mandatory.

  • Make fields mandatory in screen painting

    How to make the fields mandatory in customizing screens?
    I understand that i need to do some changes with fieldseection group.
    but in that screen i am confused what i should actually do.
    can some one guide me.

    Hi,
    Please Follow the Steps Bellow ,
    --> Double Click on the Field you want Obligatory
    --> A window will appear on the right side
    --> In this window you will see a box with heading u2018Attributesu2019
    --> There are Three u2018Tabsu2019
    --> Go to the 2nd tab which is u2018Programu2019
    --> The Label u2018Inputu2019 From the Dropdown menu  You can Select u201CRequiredu201D
    Hope will solve out your problem,
    Kind Regards,
    Faisal

  • LEAD MANAGEMENT- how to make fields mandatory

    Is there a provision in lead management to make the fields mandatory so that lead number is not generated without filling the mandatory fields/ as it is in business partnerm using field groupings in customizing (eg. without submitting address proof BP number is not generated)

    Hi
    I dont know Kai's solution but it could be good.
    If you want to deal with badi you can use its method CHECK_BEFORE_SAVE, and in it
    if some fields are not filled you can write: RAISE do_not_save.
    Document won't be saved then.
    I checked in my system, and guid is generated (perhaps it is just generated by special FM, but you can not find it
    in any of tables like crmd_orderadm_h or crmd_order_index).
    So in my opinion just guid is generated but not saved in database, until this BADI allows to save.
    Regards
    Radek

  • How to make Fields mandatory in service entry sheet

    Dear Experts,
    I need to make  "Quality of Service" and "Service Timeliness" fields mandatory for user entry  in VENDOR EVALN tab during Service Entry Sheet.
    Kindly help..

    Check the note attached to the configuration node.
    + for required (mandatory) field
    . for optional field
    - for hide
    for display
    Double click on the line showing ...+++...
    It will open up a list of fields grouped logically and you now have a radiobutton style way of changing status.

  • Make field mandatory conditionally ?

    I have two items
    a select list
    a date field
    if i select Yes in the select list
    i need to make the date field mandatory
    else
    make optional
    how can i do that ?

    See Region 3 at http://htmldb.oracle.com/pls/otn/f?p=24317:91
    If Yes is selected from that dropdown list, the mandatory indicator (red star) is shown otherwise it is hidden.
    Steps:
    1. Choose a Optional Label template for the Date Picker item
    2. Put the following in the Label field for the Date Picker item
    Date< span id="redstar" style="display:none;color:red">*< /span>3. Put the following in the HTML Form Element attributes of the Select list item
    onchange="RedStar();"4. Put the following in the Region Header for the Region 3
    <script type="text/javascript">
    function RedStar()
    var val=html_SelectValue('P91_SELECT2');
    if (val=='Yes') html_ShowElement('redstar')
    else            html_HideElement('redstar');
    window.onload=RedStar;
    </script>Hope this helps.

  • Make field mandatory thru SPRO

    Hi All,
             I wanna make a field mandatory in tcode J1IS . field name is STRTYP (Sub Tran type). I think we can do it thru SPRO. can u tell how i do it.
    Regards
    Jitendra

    Hi,
    Create a customizting Switch in SPRO, that is create a customizing table with fields KEY VALUES and then make this aviaalbe for customizing in SPRO.
    Like below
    KEY      VALUE
    FILED1  X
    Then in your program check the value of this customizing table entry.
    And make the filed mandatory/optional based on this value.
    Regards,
    Sesh

  • Create user field image through coding

    i want to create type general and  structure image through coding in vb
    please help

    Hi,
    Below is a table from SAP's SDK documentation. You should use the last option.
    Application
    DI API
    Type
    Structure
    Type
    SubType
    Alphanumeric
    Regular
    db_Alpha
    st_None
    Alphanumeric
    Address
    db_Alpha
    st_Address
    Alphanumeric
    Phone
    db_Alpha
    st_Phone
    Alphanumeric
    Text
    db_Memo
    st_None
    Numeric
    None
    db_Numeric
    st_None
    Date/Hour
    Date
    db_Date
    st_None
    Date/Hour
    Hour
    db_Date
    st_Time
    Units And Totals
    Rate
    db_Float
    st_Rate
    Units And Totals
    Sum
    db_Float
    st_Sum
    Units And Totals
    Price
    db_Float
    st_Price
    Units And Totals
    Quantity
    db_Float
    st_Quantity
    Units And Totals
    Percent
    db_Float
    st_Percentage
    Units And Totals
    Measure
    db_Float
    st_Measurement
    General
    Link
    db_Memo
    st_Link
    General
    Image
    db_Alpha
    st_Image
    Beni.

  • How to make fields mandatory in Message Address for Custom Notification.

    Hi Experts,
    We have created a new custom Notification Type and we were in the process of configuring it. I want to know, if I want to make a few fields obligatory in Message Address, can that be achieved through configurations. I am basically an ABAPer so please pardon my ignorance if the question looks basic.
    In our implementation, I have seen different Work Orders with different mandatory fields in Message Addresses. I hope the same is achievable for notification as well.
    Thanks for your help.
    Regards,
    Subhrangsu

    There are 2 ways to make any Notification filed mandatory.
    1. Configuration route:
    Here Under Plant Maintenance->Maintenance and Service Processing>Maintenance & Service Notifications>Notification Creation>Notification types> Set Field selection for Notifications:
    You select influencing button and your notification type then select the Radio button under Required column (against the 
    field you want to make mandatory)
    2. User Exit Route: Through SMOD -->User Exit QQMA0014 -->Cutsomer Exit EXIT_SAPMIWO0_020 -->Include ZXQQMU20.
    Then put your code in this include.
    Code Sample:
    IF I_VIQMEL-QMART= 'AC'.
    IF T_VIQMSM-MNGRP IS INITIAL.
    MESSAGE ID 'IW' TYPE 'I' NUMBER 464 WITH 'Tasks'.
    RAISE EXIT_FROM_SAVE.
    ENDIF.
    ENDIF.
    (The above Code makes the 'Tasks' filling mandatory in the Notification type 'AC')
    Hope this answers your query.
    Regards
    Jogeswara Rao
    Edited by: K Jogeswara Rao on Oct 8, 2010 9:21 AM

  • How to make field mandatory in Sales Order Item level?

    Hi SDN's,
    I need to make Shipping type field(Item level) mandatory in Sales order.
    Can any one tell me what is the user-exit to achieve this?
    Thanks in advance..
    Regards,
    Rahul

    Rahul,
    U can check the BADI     'BADI_SD_SALES_ITEM'
    othewise u can check
    Exit Program MV45AFZZ.
    Check the program SAPMV45A
    V45W0001
    V46H0001

  • Make Field mandatory on SU01

    Hi
    I want to know, If it is possible to make certain fields on user master record mandatory? For user ID creation I want to make Department and Function field as mandatory??

    Please take note that there is some tricky terminology in this area:
    There is an important difference between a standard transaction variant and a custom transaction variant (these are sometimes also called "variant transactions" which is not the same as a "transaction variant"). Some OSS notes mix the terms as well.
    Creating a new variant assigned to the standard transaction is better in my opinion, as it makes it possible to harden the tcode further without being forced to assign the "core" tcode for the custom transaction variants.
    As described in the note, the super users should have the additional standard access, via the additional custom code.
    This also means that if "normal" users can navigate back and forth (see transaction SU01_NAV) then they always experience the same screen variant.
    Cheers,
    Julius
    Edited by: Julius Bussche on Jul 9, 2009 10:11 PM

  • How to make field mandatory

    Hi all,
    i want to make price ,tax code and ware house code in purchase order rows mandatory.
    i have designed following Stored procedure..
    IF @transaction_type IN (N'A', N'U') AND
    (@Object_type = N'22')
    BEGIN
    if exists (SELECT T0.docnum FROM [dbo].[OPOR] T0 INNER
    JOIN [dbo].[POR1] T1 ON T1.DOCENTRY =
    T0.docENTRY
    WHERE   T1.[Price] = 0
    and T1.DOCENTRY = @list_of_cols_val_tab_del)
    select @Error = 1, @error_message =
    'Enter Price'
    else
    if exists (SELECT T0.docnum FROM [dbo].[OPOR] T0 INNER
    JOIN [dbo].[POR1] T1 ON T1.DOCENTRY =
    T0.docENTRY
    WHERE    T1.[TaxCode] is  null
    and T1.DOCENTRY = @list_of_cols_val_tab_del)
    begin
    select @Error = 2, @error_message =
    'Enter Tax Code'
    end
    else if exists (SELECT T0.docnum FROM [dbo].[OPOR] T0 INNER
    JOIN [dbo].[POR1] T1 ON T1.DOCENTRY =
    T0.docENTRY
    WHERE    T1.[WhsCode] is  null
    and T1.DOCENTRY = @list_of_cols_val_tab_del)
    begin
    select @Error = 3, @error_message =
    'Enter Warehouse Code'
    end
    END
    but system checks only for price and not for other two validation .
    kindly suggest me way where system will check for all the validation defind in the Stored Procedure.

    Hi Chetan
    Try this, This should definitely work
    if @object_type = '22' and @transaction_type in ('A','U')
    begin
    select @Total = (select T1.Price from OPOR T0 join POR1 T1 on T0.docentry = T1.docentry
    where T0.docentry=cast(@list_of_cols_val_tab_del as int))
    Select @comm = (select T1.TaxCode from OPOR T0 join POR1 T1 on T0.docentry = T1.docentry
    where T0.docentry=cast(@list_of_cols_val_tab_del as int))
    Select @venref = (select T1.TaxCode from OPOR T0 join POR1 T1 on T0.docentry = T1.docentry
    where T0.docentry=cast(@list_of_cols_val_tab_del as int))
    if @Total = 0
    begin
    set @Error =11
    set @Error_Message = 'Cannot have Zero Price'
    end
    else
    if @comm is null
    begin
    set @Error =12
    set @Error_Message = 'Select Tax'
    end
    else
    if @venref is null
    begin
    set @Error =13
    set @Error_Message = 'Select Warehouse'
    end
    end
    Regards
    Reno

  • How to make some fields mandatory for a custom screen we have added

    Hi All,
    Please let me know how can I make some fields mandatory through coding in PBO for only some fields of a screen.
    Say if I have 4 fields in my screen(module pool not selection screen) i want to make mandatory 2 fields based on some conditions how to do this? I tried using screen-group but this will make mandatory all the fields of that screen mandatory.
    I want only specific fields based on condition in run time.
    Regards
    Mahesh

    Hi Mahesh,
             Try this ..
      Assign the same group to those fields , say GRP
           in  PAI
             IF <CONDITION>
                Loop at screen.
                   if screen-group1 = 'GRP'.
                      screen-required = '1'.
                      modify screen.
                   endif.
                 endloop.
              ENDIF.

  • Need to Make end customer field mandatory in sales order form.

    I need to make end customer field mandatory when sales channel entered as some value...
    for this i have used when validate record on order form
    when i enter a value in sales channel as desired value the form is getting saved automatically and the field is getting mandatory
    but my requirement is to make field mandatory and then to save the order.
    let me know the sequence how it works if any one knows.

    Sanni,
    >
    when i enter a value in sales channel as desired value the form is <b>getting saved automatically</b> and (then) the <b>field is getting mandatory</b>
    but my requirement is to make field mandatory and then to save the order.
    >
    Which trigger are you using to do the "getting saved automatically'?
    Does this trigger fire before the trigger that is making the field mandatory?
    Regards,
    PS: Is this an Oracle EBS query? If yes, this is the wrong forum
    Edited by: Prabodh on Jun 14, 2012 4:48 PM

Maybe you are looking for

  • Document status values

    Hello! I am on solar02 transaction and pulling out IMG objects for configuration. After configuring I am documenting the config in the  by pulling object-document . The default status values for this in "processing status"column are - open, in proces

  • FDM Source Adapters

    When you go through the route of using a FDM Source Adapter to provide the Source GL trial balance file as opposed to generating a flat file out of the GL, does the Source adapter also pull out a flat file? Or is it a direct table copy and insert int

  • Behaviour of CurrVal - can anyone explain this?

    Hi All, I am expiriencing some "strange" behaviour of CurrVal. I will try to represent it with simple expample. Let's have one table and one sequence: create table TestCurrVal (A number, b number); create sequence SeqTestCurrVal start with 1;and some

  • Place word table as image

    Hi, back in the day if you created a text box and pasted a table from word, it would format to text, if you did not have a text box it would paste as an image. I really just want to paste a word table straight into indesign, is this still doable?

  • Photos missing from iCloud backup

    Hi, I used to have a 4s with photos on and it started to lose wifi connection which meant iCloud backups were hit and miss. On occasion I tried to reset my phone to rectify the wifi issue and when restoring from an old iCloud backup some photos were