I would like to know how I can catch this error and put it into a table. Is this possible?

I would be glad of any help.

Insert into STK_ALLOCATION_TEMP

(STKAL_ID -- Transaction ID. Used to group transaction detail lines together. Unique and auto generated in Dimensions. See the section on Usage for more details ,STKAL_LINE_NO -- Stock allocation line number. See the section on Validation. ,STKAL_ORDER_DETAIL_LINK -- Unique identifier for the ordered stock line Table: ORD_DETAIL, Field: OD_PRIMARY ,STKAL_QUANTITY -- Amount of stock allocated to this line. See the section on Usage for more details ,STKAL_USER_ID -- ID of the user populating this table ,STKAL_MULTI_SUBANALYSIS_LINK -- Link to STK_SUBANALYSIS_SERIAL_TEMP , STKSUBSNO_ID field ,STKAL_SERIAL_NUMBER ,STKAL_ORDER_TYPE) -- ‘S’ = Sales Order, ‘W’ = Works Orders

Values

(1 -- STKAL_ID Transaction ID. Used to group transaction detail lines together. Unique and auto generated in Dimensions. See the section on Usage for more details ,1 -- STKAL_LINE_NO Stock allocation line number. See the section on Validation. ,9 -- STKAL_ORDER_DETAIL_LINK Unique identifier for the ordered stock line Table: ORD_DETAIL, Field: OD_PRIMARY ,-2 -- STKAL_QUANTITY Amount of stock allocated to this line. See the section on Usage for more details ,'sa' -- STKAL_USER_ID ID of the user populating this table ,1 --STKAL_MULTI_SUBANALYSIS_LINK ,'<multiple>' ,'S') -- STKAL_ORDER_TYPE ‘S’ = Sales Order, ‘W’ = Works Orders

exec AA_STK_ALLOCATION_POST_S @PS_TRN_TEMP_ID=1 -- Use of this parameter needs care when using. See the section on Usage for more details. ,@PS_USER_ID='SA' -- ID of user calling procedure. Must be a valid user within Dimensions with the correct permissions via their security profiles.

EXEC dbo.Aa_stk_allocation_post_s @PS_TRN_TEMP_ID = @stkal_id -- Use of this parameter needs care when using. See the section on Usage for more details. , @PS_USER_ID = 'WMS' -- ID of user calling procedure. Must be a valid user within Dimensions with the correct permissions via their security profiles., @PS_Proccess_Status = @Proccess_Status out

IF @Proccess_Status <> 0 BEGIN INSERT INTO UDEF_DISPATCHER_ERROR_LOG_STK_ALLOCATION_TEMP SELECT TOP 100 PERCENT [STKAL_ID] ,[STKAL_LINE_NO] ,[STKAL_SUB_LINE_NO] ,[STKAL_STATUS] ,[STKAL_ORDER_DETAIL_LINK] ,[STKAL_QUANTITY] ,[STKAL_USER_ID] ,[STKAL_SUBANALYSIS] ,[STKAL_MULTI_SUBANALYSIS_LINK] ,[STKAL_SERIAL_NUMBER] ,[STKAL_CUSTOMER_CODE] ,[STKAL_ORDER_NUMBER] ,[STKAL_REQUIRED_DATE] ,[STKAL_QUANTITY_TO_DELIVER] ,[STKAL_QUANTITY_ALLOCATED] ,[STKAL_QUANTITY_OS_TO_ALLOCATE] ,[STKAL_ORDER_TYPE] ,( CASE WHEN [STKAL_STATUS] = 0 THEN 'No error.' WHEN [STKAL_STATUS] = 1 THEN 'Order detail does not exist.' WHEN [STKAL_STATUS] = 2 THEN 'Order Detail no longer requires allocation.' WHEN [STKAL_STATUS] = 3 THEN 'Over allocation or de-allocation attempted.' WHEN [STKAL_STATUS] = 4 THEN 'Not currently used.' WHEN [STKAL_STATUS] = 5 THEN 'Serial number already assigned.' WHEN [STKAL_STATUS] = 6 THEN 'Not enough stock.' WHEN [STKAL_STATUS] = 7 THEN 'Serial number not available.' WHEN [STKAL_STATUS] = 8 THEN 'Serial number does not exist.' WHEN [STKAL_STATUS] = 9 THEN 'Sub analysis is no longer permitted.' WHEN [STKAL_STATUS] = 10 THEN 'Sub analysis does not exist.' WHEN [STKAL_STATUS] = 11 THEN 'could not allocate as no sub analysis was specified.' WHEN [STKAL_STATUS] = 12 THEN 'Total multiple quantities do not match detail line quantity.' WHEN [STKAL_STATUS] = 13 THEN 'Unspecified error.' WHEN [STKAL_STATUS] = 14 THEN 'Serial number does not belong to the specified sub analysis.' WHEN [STKAL_STATUS] = 15 THEN 'Security level access to stock denied.' WHEN [STKAL_STATUS] = 16 THEN 'Security level access to stock sub analysis denied.' WHEN [STKAL_STATUS] = 17 THEN 'Unable to find an inward movement to get a FIFO cost price from.' WHEN [STKAL_STATUS] = 18 THEN 'cannot allocate stock to a Works Order that is closed, merged or complete.' WHEN [STKAL_STATUS] = 19 THEN 'cannot de-allocate from a sub-analysis that the order was not allocated to.' ELSE '' END ) ,Getdate() FROM [STK_ALLOCATION_TEMP] WHERE Isnull(STKAL_STATUS, '') <> 0 AND [STKAL_ID] = @stkal_id