Creating a in and out stock report

  • Hi

    I have three tables : vligach (incoming goods) and vligven (orders - outgoing), vficart (table containg articles and stock).

    Now I have to create a report, looking like this :

    01/01/04 :

    Stock : 304

    In : 285

    Out : 311

    01/02/04 :

    Stock : 278 (= 304 + 285 - 311).

    How do I create such a report ?

    Kind regards and many thx in advance

    EL Jefe


    JV

  • Can this be a solution ?

    declare @Article as varchar(15)

    declare @Descrip as varchar(30)

    declare @Stock as numeric

    declare @Incoming as numeric

    declare @Outgoing as numeric

    declare @Monthly as numeric

    declare @SalesPrice as numeric

    declare @PurchasePrice as numeric

    declare TableCursor_Stock cursor for

    select codart,libel1, qtesto, month(now()), poids, priach

    from vficart

    where codfam like 'c%'

    order by codart

    set @month = month(now())

    set @Stock = vficart.qtesto

    set @SalesPrice = vficart.poids

    open TableCursor_Stock

    FETCH NEXT FROM TableCursor_Stock INTO  @Artikelcode, @Stock, @month

    WHILE @month <> '0'

     BEGIN

        do while  @@FETCH_STATUS <> -1

       @month = @month

       @Out = select sum(quanti) from vligven where codart = @article and month(dtfact) = @month

       @In = select sum(quanti) from vligach where codart = @article and month(dtfact) = @month

       @Stock = @Stock + @In - @Out  

       @month = @month

       --FETCH NEXT FROM TableCursor_Stock INTO @Article, @Stock, @In, @Out, @Month

       insert into tbl_cml_stock

       values (@Article, @Stock, @In, @Out, @Month, @Salesprice)

       @month = @month-1

      END

    END

    CLOSE TableCursor_NOBL

    DEALLOCATE TableCursor_Stock

    If yes, how do I get the results into an excel sheet ?

    Kind regards

    Jeffrey


    JV

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply