cancel
Showing results for 
Search instead for 
Did you mean: 

Create Stored procedure in Work order to avoid negative numbers

0 Kudos

Good day experts, im new on this, im studying SQL because i have cero to none

Consultor created T0.[U_end_date], T0.[U_end_time], T0.[U_start_time], T0.[U_Startdate] to capture labor time and date form operators.

But operators start to type for example Start Date: 10/09/2021 start time: 11:00 P.M and End Date: 10/09/2021 End time: 02:00 A.M

This is causing negative numbers.

How can i create a Store Procedure to avoid this.

i started figuring this but im not sure if its correct or what im missing

if @object_type = '60'

begin

if @transaction_type in ('A','U')

begin

declare @U_startdate datetime

declare @U_end_date datetime

Select @U_startdate from IGE1.docentry where TransType='60'

Select @U_end_date from IGE1.docentry where TransType='60'

IF @U_startdate+ @U_end_date = -1

Begin

set @error_message ='Wrong End Date'

end

end

end

chubchub
Explorer

use military time format

0 Kudos

Hello, thanks for your hint, do you have an example on how to do this? i will really appreciate your help, there is a lot of examples on SQL but i understood that SAP detect different time format.

Accepted Solutions (1)

Accepted Solutions (1)

staseeb
Active Participant

Hello,

I guess you also have to validate the Time fields, end time should be greater than start time of the Start and End Dates are same.

Regards,

Taseeb Saeed

0 Kudos

Thanks a lot for your response, i tried with this, but still cant validate, there is a way different that SAP read date?
Im searching in internet but im new in SQL and stored procedures and its kind of difficult to fin information, i will really appreciate your help!

if @object_type = '60'

begin

if @transaction_type in ('A','U')

begin

declare @U_startdate datetime

declare @U_end_date datetime

declare @U_start_time int

declare @U_end_time int

Select @U_startdate= U_start_time from IGE1 a where a.docentry = @list_of_cols_val_tab_del and a.ItemCode ='Labor'

Select @U_end_date = U_end_date from IGE1 a where a.docentry = @list_of_cols_val_tab_del and a.ItemCode ='Labor'

Select @U_start_time = U_start_time from IGE1 a where a.docentry = @list_of_cols_val_tab_del and a.ItemCode ='Labor'

Select @U_end_time = U_end_time from IGE1 a where a.docentry = @list_of_cols_val_tab_del and a.ItemCode ='Labor'

IF (@U_start_time > @U_end_time and @U_startdate = @U_end_date) or (@U_end_date < @U_startdate)

Begin

set @error_message ='Wrong End Date'

end

end

end

Answers (0)