Skip to Content
avatar image
Former Member

How can i make a field mandatory

Hi Experts

I want to make a field in the purchase order mandatory for data entering. how can i do this?

Do i have to use the SDK or a Formatted search please tell me the proper way of doing this.

Thanks & Regards

Kanishka Wickrama

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

17 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 08, 2009 at 04:15 AM

    The following is the full procedure i use, let me know what is wrong in it

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER proc [dbo].[SBO_SP_TransactionNotification]

    @object_type nvarchar(25), -- SBO Object Type

    @transaction_type nchar(1), -- [A]dd, <u>pdate, [D]elete, [C]ancel, C[L]ose

    @num_of_cols_in_key int,

    @list_of_key_cols_tab_del nvarchar(255),

    @list_of_cols_val_tab_del nvarchar(255)

    AS

    begin

    -- Return values

    declare @error int -- Result (0 for no error)

    declare @error_message nvarchar (200) -- Error string to be displayed

    select @error = 0

    select @error_message = N'Ok'

    -


    -- ADD YOUR CODE HERE

    IF (@object_type = N'22' AND @transaction_type in (N'A', N'U') )

    BEGIN

    Set @error =1

    set @error_message = 'Profit Center cannot be blank'

    IF EXISTS (SELECT T1.DocEntry FROM OPOR T0 inner join POR1 T1 on T0.DocEntry = T1.DocEntry

    WHERE (T1.OcrCode = '') AND T0.DocEntry = @list_of_cols_val_tab_del)

    BEGIN

    Set @error =1

    set @error_message = 'Profit Center cannot be blank'

    SELECT @error , @error_message

    END

    END

    -


    end

    GO

    SET ANSI_NULLS OFF

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    Add comment
    10|10000 characters needed characters exceeded

    • Try this one, it is working. (And see the difference) ::

      ALTER proc [dbo].[SBO_SP_TransactionNotification] 
      
      @object_type nvarchar(20), 				-- SBO Object Type
      @transaction_type nchar(1),			-- [A]dd, <u>pdate, [D]elete, [C]ancel, C[L]ose
      @num_of_cols_in_key int,
      @list_of_key_cols_tab_del nvarchar(255),
      @list_of_cols_val_tab_del nvarchar(255)
      
      AS
      
      begin
      
      -- Return values
      declare @error  int				-- Result (0 for no error)
      declare @error_message nvarchar (200) 		-- Error string to be displayed
      select @error = 0
      select @error_message = N'Ok'
      
      --------------------------------------------------------------------------------------------------------------------------------
      
      --	ADD	YOUR	CODE	HERE
      IF (@object_type = N'22' AND @transaction_type in (N'A', N'U') )
      BEGIN
      IF EXISTS (SELECT T1.DocEntry FROM OPOR T0 inner join POR1 T1 on T0.DocEntry = T1.DocEntry
      WHERE (T1.OcrCode IS NULL or T1.OcrCode = '') AND T0.DocEntry = @list_of_cols_val_tab_del)
      BEGIN
      Set @error =1
      set @error_message = 'Profit Center cannot be blank'
      END
      END
      
      --------------------------------------------------------------------------------------------------------------------------------
      
      -- Select the return values
      select @error, @error_message
      
      end

  • avatar image
    Former Member
    Jul 16, 2009 at 03:33 AM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2009 at 04:17 AM

    hai!

    Wheather the field is a udf or what?

    The previous thread links guide you to a SP method to make a field mandatory.

    you can also try using a UDF.

    1. Add a new UDF in Header/Row - if your mandatory field is in header/row respectively

    2. mark the udf as mandatory.

    3. Assign a FMS on that UDF on PO form like, when BP code (Header)/ ItemCode (Row) get refreshed make it null

     select '' 

    this is the FMS..

    Try it, it will work fine..

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2009 at 04:44 AM

    Hi Kanishka,

    Use stored procedure to make a field mandatory.

    *Close the thread if issue solved.

    Regards

    Jambulingam.P

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2009 at 05:01 AM

    This message was moderated.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 17, 2009 at 02:16 PM

    If you are referring to a SAP table field, you could use either SDK or SBO_SP_TransactionNotification stored Procedure.

    Formatted Search would not help with this.

    Suda

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 17, 2009 at 04:03 PM

    You may check these threads:

    how-to-make-a-field-mandatory

    mandatory-field

    Thanks,

    Gordon

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 14, 2009 at 07:49 AM

    Hi Experts

    I wrote a code like below to make the profit center code mandatory in the purchase order but it does not work.

    If @object_type = '14' and @transaction_type in ( 'A','U')

    Begin

    if exists (SELECT T0.DocEntry FROM POR1 T0 inner join OPOR T1 on T0.DocEntry = T1.DocEntry

    WHERE T0.OcrCode is null and T1.DocEntry=@list_of_cols_val_tab_del)

    begin

    select @Error = 50 , @error_message = 'Please Fill Section'

    end

    End

    Can some one tell me what would be the problem here.

    Thanks & Regards

    Kanishka Wickrama

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Kanishka,

      Please try this and let me know if it works:

      If @object_type = '22' and @transaction_type in (N'A', N'U')

      Begin

      if exists (SELECT T0.DocEntry FROM POR1 T0 inner join OPOR T1 on T0.DocEntry = T1.DocEntry

      WHERE T0.OcrCode is null and T1.DocEntry=@list_of_cols_val_tab_del)

      begin

      begin

      set @Error = 50

      set @error_message = N'Please Fill Section'

      end

      End

      Regards,

      Joseph

  • avatar image
    Former Member
    Sep 14, 2009 at 10:14 AM

    HI

    I changed the object type to be 22 but still nothing happens.

    Thanks & Regards

    Kanishka Wickrama

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 14, 2009 at 04:07 PM

    Hi Kanishka Wickrama,

    Try this one:

    If @object_type = '22' and @transaction_type in (N'A', N'U')
    Begin
    if exists (SELECT DocEntry FROM POR1 T0 WHERE (T0.OcrCode is NULL or T0.OcrCode ='') and 
    T0.DocEntry=@list_of_cols_val_tab_del)
    begin
    begin
    set @Error = 50
    set @error_message = N'Please Fill Section'
    end
    End
    

    Add comment
    10|10000 characters needed characters exceeded