cancel
Showing results for 
Search instead for 
Did you mean: 

How can i make a field mandatory

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

former_member204969
Active Contributor
0 Kudos

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

Answers (16)

Answers (16)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Suda

I have the below code in the SP SBO_SP_TransactionNotification but nothing happens what could be the reason ?

IF (@object_type = '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'

SELECT @error , @error_message

END

END

Does this only work for SAP B1 2007?

Thanks & Regards

Kanishka Wickrama

Edited by: kanishka wickrama on Oct 7, 2009 12:35 PM

former_member204969
Active Contributor
0 Kudos

If this code does not work for you, then probably you inserted it in the procedure in a wrong place, where it is not executed.

Try to change its place inside the procedure, and if you don't get the good result, list here the full SBO_SP_TransactionNotification procedure.

Former Member
0 Kudos

Oh sorry my mistake i changed it to 22 but no result yet.

Thanks & Regards

Kanishka Wickrama

former_member583013
Active Contributor
0 Kudos

If you are talking about Purchase Order then the table in your SQL should be POR1 and not PDN1

OPDN and PDN1 refers to Goods Receipts

OPOR and POR1 are table for Purchase Orders

IF (@object_type = '22' AND @transaction_type= 'A')
BEGIN

IF EXISTS (SELECT DocEntry FROM dbo.POR1 WHERE (OcrCode IS NULL OR OcrCode = '') AND DocEntry = @list_of_cols_val_tab_del)
BEGIN
SELECT @error =1, @error_message = 'Profit Center cannot be blank'
END

END

Suda

Former Member
0 Kudos

Hi experts

I used the following code in my SP SBO_SP_TransactionNotification, which seems to be working for others when i read the other threads.

But this does not work for me at all. Am i missing something here ?

IF (@object_type = '20' AND @transaction_type= 'A')

BEGIN

IF EXISTS (SELECT DocEntry FROM [dbo].[PDN1] WHERE (OcrCode IS NULL OR OcrCode = '') AND DocEntry = @list_of_cols_val_tab_del)

BEGIN

SELECT @error =1, @error_message = 'Profit Center cannot be blank'

END

END

Thanks & Regards

Kanishka Wickrama

former_member204969
Active Contributor
0 Kudos

First you wanted to make mandatory the field in the puchase order.

Now your code is refering to object type =20 , which is goods receipt PO.

So what you really want?

Former Member
0 Kudos

HI Gordon & Joseph

I tried both the options you gave but nothing seems working. Do i have to do any settings change or something, i cant understand why it is not working.

Thanks & Regards

Kanishka Wickrama

Former Member
0 Kudos

Hi!

Try this

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
set @Error = 50
set @error_message = N'Please Fill Section'
end
End

Former Member
0 Kudos

Try this:

U_PO is a UDF

-


IF @object_type='22' AND (@transaction_type='A' or @transaction_type='U')

BEGIN

IF EXISTS (SELECT U_PO FROM OPCH WHERE U_PO IS NULL AND docentry= @list_of_cols_val_tab_del)

SELECT @Error = 1, @error_message = 'No Purchase Order Number.'

END

-


Former Member
0 Kudos

up

Former Member
0 Kudos

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

Former Member
0 Kudos

HI

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

Thanks & Regards

Kanishka Wickrama

Former Member
0 Kudos

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

former_member204969
Active Contributor
0 Kudos

The purchase order object type is 22! try with this.

Former Member
0 Kudos

Hi Kanishka,

The object type for the Purchase order is "22" and you have selected "14". Update the same and then try..

Former Member
0 Kudos

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

Former Member
0 Kudos

You may check these threads:

Thanks,

Gordon

former_member583013
Active Contributor
0 Kudos

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

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Kanishka,

Use stored procedure to make a field mandatory.

*Close the thread if issue solved.

Regards

Jambulingam.P

Former Member
0 Kudos

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

Former Member
0 Kudos

This message was moderated.