cancel
Showing results for 
Search instead for 
Did you mean: 

Sales order stored procedure

former_member229757
Participant
0 Kudos

Hi Experts,

I need to validate the sales order through SP.

If i choosing a sales order BP code as 'C137680' then i need to select my UDF field U_Material as 'Inside' option is mandatory. I am not suppose to choose other options.

I have created the below SP its adding without blocking(If i create other UDF options also)

IF @transaction_type in(N'A', N'U') AND @object_type = '17'
BEGIN
if exists (Select CardCode from ORDR T0 where t0.CardCode='C137680' and
t0.U_Materials = ('INSIDE')
and t0.DocEntry=@list_of_cols_val_tab_del )
begin
SET @error = 10
SET @error_message = N'Inside is mandatory'
end
END

Thanks

Vinoth

Former Member
0 Kudos

Hello sahajfunctional2,

Uses if not exists.

Regards,

Taseeb Saeed

Whatsapp : 00923364127880

Accepted Solutions (0)

Answers (3)

Answers (3)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Your stored procedure is working if you change condition <> 'INSIDE'. Make sure, you have added above stored procedure in correct company.

Regards,

Nagarajan

former_member229757
Participant
0 Kudos

Hi Nagaraj,

I have tried all the possibilities and correct company but above is not working.

Thanks

Vinoth

Abdul
Active Contributor
0 Kudos

Hello

You want use ti select inside if customer code is 'C137680' if this is the case then you need to have condition in query where t0.CardCode='C137680' and t0.U_Materials <> ('INSIDE') then your query returns values in transaction procedure and system will stop.

Try the below code

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

BEGIN
if exists (Select CardCode from ORDR T0 where t0.CardCode='C137680' and
t0.U_Materials <> ('INSIDE')
and t0.DocEntry=@list_of_cols_val_tab_del )
begin
SET @error = 10
SET @error_message = N'Inside is mandatory'
end
END

former_member229757
Participant
0 Kudos

Hello

I have tried not equal(<>) also still its not blocking if i select other options.

My sales order is adding without blocking.

Thanks

Vinoth

jose_valenzuela
Discoverer
0 Kudos

Hola buen día,

también puedes usarlo a través del case

CASE WHEN T0.CardCode = 'C137680' AND T0.U_Materials <> 'INSIDE'

THEN 'ESCRIBIR MENSAJE DE ERROR' END

¿Esta validación solo aplicara para el cliente 'C137680', o podría haber mas clientes?

Te recomiendo que agregues un UDF en la OCRD, el cual te sirva para indicar si quieres que aplique o no la validación, de esta manera lo haces mas configurable.

Saludos.