Skip to Content

correct my stored procedure

Dear all

I want to make project field as mandatory in all document for that i write this following stored procedure

no error in my stored procedure, but it is not working.

*******************************

Step : 1 Declare all variable

Step : 2

select @object_type = 22

select @table = case @object_type

when '22' then 'POR1'

when '15' then 'ODLN'

when '16' then 'ORDN'

when '13' then 'OINV'

when '14' then 'ORIN'

end

Step :3

set @CheckValue = 'SELECT min(isnull(Project, '')) FROM' + @table + 'where DocEntry =

@list_of_cols_val_tab_del'

Step :4

if (@CheckValue = '')

begin

SET @error_message = N'Project code Or Dimension Missing'

SET @error = 1

end

select @error, @error_message

************************

No error showing for this, but its allowing to add purchase order with out 'project code"

If i change step 3 as following its working correctly

set @CheckValue = (SELECT min(isnull(PO.Project, '')) FROM PCH1 PO where PO.DocEntry =

@list_of_cols_val_tab_del)

but i don't want to give table name directly in select statement

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 08:25 AM

    No error message may not prove it is working. You can not only use line table without header to establish an object.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 07:38 AM

    At least, when '22' then 'POR1' is wrong. You can only use OPOR but not POR1.

    Thanks,

    Gordon

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 08:35 AM

    Because I don't have any data to test, sorry for not able to help. What you can do might be to split complete conditions one by one. That is a good way to troubleshoot.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.