cancel
Showing results for 
Search instead for 
Did you mean: 

how to make Mandatory field

Former Member
0 Kudos

Dear experts,

Is there any stored procedure to make the "dimension"(cost center) as mandatory field in the invoices and production orders?

Thanks& regards

Hiren

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hiren,

You can check the below for AP Invoice: for other documents, you may change the table name and update the object type too:

To get the object type, you can refer:

SAP Business One Objects ID and Menu ID List - Business One - SCN Wiki

If

@transaction_type  IN  (N'A', N'U') AND (@Object_type = N'18')

begin

if

exists (SELECT T0.docnum FROM dbo.OPCH T0 INNER

JOIN

dbo.PCH1 T1 ON T1.DOCENTRY =

T0

.docENTRY

WHERE

t1.OcrCode is null

and

T0.DOCENTRY = @list_of_cols_val_tab_del)

select

@Error = 1, @error_message =

'You cannot add invoice without selecting the Cost Center!!'

End

Thanks,

Joseph

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Joseph,

For invoice it is working but for production order this SP is not working. could you please help me

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

For production order:

If

@transaction_type  IN  (N'A', N'U') AND (@Object_type = N'202')

begin

if

exists (SELECT T0.docnum FROM dbo.OPCH T0 INNER

JOIN

dbo.PCH1 T1 ON T1.DOCENTRY =

T0

.docENTRY

WHERE

t1.OcrCode is null

and

T0.DOCENTRY = @list_of_cols_val_tab_del)

select

@Error = 1, @error_message =

'You cannot Production order without selecting the Cost Center!!'

End

Thanks.

Former Member
0 Kudos

Hi Nagarajan,

You would need to replace the OPCh and PCH1 tables in your TN

If

@transaction_type  IN  (N'A', N'U') AND (@Object_type = N'202')

begin

if

exists (SELECT T0.docnum FROM dbo.OWOR T0 INNER

JOIN

dbo.WOR1 T1 ON T1.DOCENTRY =

T0

.docENTRY

WHERE

t1.OcrCode is null

and

T0.DOCENTRY = @list_of_cols_val_tab_del)

select

@Error = 1, @error_message =

'You cannot Production order without selecting the Cost Center!!'

End

Thanks,

Joseph

kothandaraman_nagarajan
Active Contributor
0 Kudos

Sorry. Just copied your TN, forgot change table.