Skip to Content
author's profile photo Former Member
Former Member

Problema con SP, para Libro Mayor

Que tal!

me doy otra vuelta para pedir ayuda con este SP:

USE [SBO_DESARROLLO]
GO
/****** Object:  StoredProcedure [dbo].[SP_LibroMayor]    Script Date: 03/30/2011 17:16:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[SP_LibroMayor] 
	@FechaIni datetime,	
	@FechaFin datetime,
	@Nivel int	

AS
BEGIN
	SET NOCOUNT ON; 

/*LIBRO MAYOR CELULARSTAR S.A. DE C.V.*/

CREATE TABLE #MAYOR3 
                                                   (
                                                    Cuenta nvarchar(15),
                                                    Nombre nvarchar(100),
                                                    SI numeric(19,06),
                                                    Debe numeric(19,6),
                                                    Haber numeric(19,6),
                                                    SF numeric(19,6)
                                                   );
INSERT INTO #MAYOR3
                                               SELECT A.[Account] 'No.Cta',
                                                               A1.[AcctName] 'NombredelaCuenta',
                                                              (select sum(B.[Credit])-sum(B.[Debit])
                                                               from JDT1 B 
																 left join OACT B1 on B.[Account] = B1.[AcctCode]
															   where B.[TaxDate]   between (DATEADD(MONTH,-1,@FechaIni)) and (DATEADD(MONTH,-1,@FechaFin)) and 
															                 B1.[AcctCode] = A1.[AcctCode] ) 'Saldo Inicial',
                                                               sum(A.[Credit])'Debe',
                                                               sum(A.[Debit])'Haber',
                                                              0.00 'Saldo Final'                                                                                
FROM JDT1 A
													LEFT JOIN OACT A1 ON A.[Account] = A1.[AcctCode]
											   WHERE A.[TaxDate]  BETWEEN @FechaIni AND @FechaFin AND
											                    A1.[Levels] = @Nivel
											    GROUP BY A.[Account], A1.[AcctName], A1.[AcctCode]
											    ORDER BY A.[Account]

SELECT Cuenta,
                Nombre,
                SI,
                Debe,
                Haber,
                SI+Debe-Haber 'SF'
FROM #MAYOR3
DROP TABLE #MAYOR3
END

En SQL corre de maravilla, explico, en en Query Manager de SAP puse esta consulta:

/*SELECT FROM [dbo].[JDT1] T0*/
DECLARE @FechaIni AS DATETIME
/* WHERE */SET @FechaIni = /* T0.TaxDate */ '20110301'  

/*SELECT FROM [dbo].[JDT1] T0*/
DECLARE @FechaFin AS DATETIME/* 
WHERE */SET @FechaFin = /* T0.TaxDate */ '20110315' 

/*SELECT FROM [dbo].[OACT] T1*/
DECLARE @Nivel as int
/*WHERE*/SET @Nivel = /*T1.Level*/'4'

EXEC [dbo].[SP_LibroMayor] @FechaIni, @FechaFin, @Nivel

con los datos asignados ahi a las variables la consulta se ejecuta de manera correcta, pero si yo pongo los comodines para capturar variables de SAP ('[%0]'), me devuelve la cinta roja con el msg 'Contrato de Servicios - OCTR'

Si alguien tiene idea, Gracias por la ayuda

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Mar 31, 2011 at 07:19 PM

    Como lo pones en SAP con las variables?

    Puedes poner el codigo con las variables en SAP ? sin datos en codigo duro?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 24, 2011 at 05:19 PM

    Encontre la solución en otro foro luego subo la respuesta

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Pablo Coca

      Hola Pablo,

      Aquí tenes los querys con los que logro ejecutar cualquier SP desde el query manager:

      DECLARE @Int int,
                         @StartDate datetime,
                         @EndDate datetime;
      
      
      SET @Int = (SELECT TOP 1 T0.[DocNum] FROM OINV T0 WHERE T0.[TaxDate] BETWEEN '[%0]' AND '[%1]')
      
      
      SET @StartDate = '[%0]'
      SET @EndDate = '[%1]';
      
      
      exec dbo.[LibrodeConsumidorFinal] @StartDate, @EndDate
      
      
      /*SELECT FROM [dbo].[OINV] T0*/
      DECLARE @Fecha as datetime
      /*WHERE */SET @Fecha = /* T0.TaxDate */ '[%0]' 
      
      
      /*SELECT FROM [dbo].[OINV] T0*/
      DECLARE @Fecha2 as datetime
      /*WHERE */SET @Fecha2 = /* T0.TaxDate */ '[%1]' 
      
      
      /*SELECT FROM [dbo].[OITM] T0*/
      DECLARE @Articulo varchar(100)
      /*WHERE */SET @Articulo = /* T0.ItemCode */ '[%2]' 
      
      
      EXEC [dbo].[SP_KARDEX] @Fecha, @Fecha2, @Articulo
      

      Si necesitas mas variables, únicamente decláralas basándote en la sintaxis de las otras.

      Cualquiera de los dos debe ejecutar tu SP, caso contrario envíame un correo (alexander.281187(at)gmail.com) con tu SP y el codigo que estas dejando en el query manager.

      Quedo a la orden para tus comentarios.

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.