cancel
Showing results for 
Search instead for 
Did you mean: 

SP_TN based on Business partner properties

Former Member
0 Kudos

Dear Experts,

I have small requirement.

In Business partner master data, defined as properties 1 & 2.

My requirement as Based on business partner properties A/R credit Memo need to be a control.

Example :

Properties 1 as 'Yes' & While adding credit memo as ' 01 Warehouse' or if Properties 2 as 'Yes' & while adding credit memo as '02 warehouse'

Please help me to provide SP_TN for this case.

Accepted Solutions (1)

Accepted Solutions (1)

gaurav_bali
Active Participant
0 Kudos

Hi Mohamed

Try below query

IF @object_type = N'14' AND ( @transaction_type = N'A')

Begin

    DECLARE @MyCursorOP CURSOR

    declare @LineNumOP VarChar(20)

    declare @WhsCode VarChar(200)

    declare @Prop1 VarChar(200)

    declare @Prop2 VarChar(200)

    SET @MyCursorOP = CURSOR FAST_FORWARD

    FOR SELECT T1.LineNum,T1.WhsCode,T2.QryGroup1,T2.QryGroup2

                from ORIN T0

                inner join RIN1 T1 on T0.DocEntry = T1.DocEntry

                inner join OCRD T2 on T0.CardCode = T2.CardCode where T0.DocEntry = @list_of_cols_val_tab_del

    OPEN @MyCursorOP

    FETCH NEXT FROM @MyCursorOP

    INTO @LineNumOP,@WhsCode,@Prop1,@Prop2

    WHILE @@FETCH_STATUS = 0

    BEGIN

        if ((@WhsCode <> '01 Warehouse' and @Prop1 = 'Y') or (@WhsCode <> '02 Warehouse' and @Prop2 = 'Y'))

        BEGIN

           SELECT @Error = 12

           SELECT @error_message = 'Warehouse code doesnt matches with BP Property at line -'+convert(nvarchar(200),(@linenumop+1))

        END

        FETCH NEXT FROM @MyCursorOP

        INTO @LineNumOP,@WhsCode,@Prop1,@Prop2

    END

    CLOSE @MyCursorOP

    DEALLOCATE @MyCursorOP         

End

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Could you please help me for this.

narayanis
Active Contributor
0 Kudos

Hi,

You can try this

Declare @WhsCode as nvarchar(100)

Declare @Prop1 as varchar(100)

Declare @prop2 as varchar(100)

if @object_type = 14 and @transaction_type in ('A' , 'U')

     Begin

          select @Whscode = t1.whscode,@Prop1 = t2.QryGroup1 , @Prop2= t2.QryGroup2

          from orin t0 inner join rin1 t1 on t0.docentry = t1.docentry

          inner join ocrd t2 on t0.cardcode = t2.cardcode where t0.docentry =list_of_cols_val_tab_del

          if (@Whscode <> '01' and @prop1 = 'Y') or (@whscode <> '02' and @Prop2 = 'Y')

          Begin

               Set @Error = -10

               Set @Error_Message = 'Please Match Warehouse With BP Property'

          End

     End

Hope this will help  you.

Regards

Narayani