Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sql Query not generating table fields Post Reply Post New Topic
Author Message
cmboykin
Newbie
Newbie


Joined: 18 Aug 2011
Online Status: Offline
Posts: 4
Quote cmboykin Replybullet Topic: Sql Query not generating table fields
     Posted: 18 Aug 2011 at 5:04am
I have just enough knowledge to be dangerous to myself and my employer.
 
I have a sql query which I have added to the command and create the necessary parameter. However, when I try to find the field it states they are not mapped. And I do not have the option to map them. I can place other sql commands in and received data.  I  am using someonelse orginal report and modifying report to look at the financial group and different field to calculate ARChg. I could not figure how to filter on two different date source without having to us the query.
 
Do you see anything that would be prohibiting me from get my table fields?
 
Please Help!!!
 
--Accounts Receivable Summary by Financial Group report
DECLARE @ARChg TABLE (fgc CHAR(10), archg MONEY NOT NULL)
INSERT INTO @ARChg
            (fgc,
             archg)
SELECT a.financialgroup_id                                 AS fgc,
       Isnull(SUM(Isnull(cpt.invoicecpt_feeamount, 0)), 0) AS archg
FROM   lkup_financialgroup a
       JOIN bill_invoice bip
         ON ( a.financialgroup_id = bip.financialgroup_id )
            AND bip.invoice_recordstate = 0
            AND bip.invoice_id <> '0000000000'
       LEFT JOIN bill_invoicecpt cpt
         ON ( bip.invoice_id = cpt.invoice_id )
            AND ( cpt.invoicecpt_recordstate = 0
                   OR cpt.invoicecpt_recordstate IS NULL )
            AND cpt.invoicecpt_postdate < {?Start Date}
            AND cpt.invoicecpt_id <> '0000000000'
WHERE  a.financialgroup_recordstate = 0
       AND a.financialgroup_id <> '0000000000'
GROUP  BY a.financialgroup_id
----------  
DECLARE @ARPay TABLE (fgc CHAR(10), arpay MONEY NOT NULL)
INSERT INTO @ARPay
            (fgc,
             arpay)
SELECT a.financialgroup_id                            AS fgc,
       Isnull(SUM(Isnull(bp.payment_payment, 0)) +
              SUM(Isnull(bp.payment_adjustment, 0)) + SUM
              (Isnull(bp.payment_adjustment1, 0)), 0) AS arpay
--same as Pay_Adj_Total
FROM   lkup_financialgroup a
       JOIN bill_invoice bip
         ON ( a.financialgroup_id = bip.financialgroup_id )
            AND bip.invoice_recordstate = 0
            AND bip.invoice_id <> '0000000000'
       JOIN "TopsData"."dbo".bill_payment bp
         ON ( bip.invoice_id = bp.invoice_id )
            AND bp.payment_dateposted < {?Start Date}
            AND bp.payment_recordstate = 0
            AND bp.payment_id <> '0000000000'
WHERE  a.financialgroup_recordstate = 0
       AND a.financialgroup_id <> '0000000000'
GROUP  BY a.financialgroup_id
----------
INSERT INTO @ARChg
            (fgc,
             archg)
SELECT fgc,
       arpay
FROM   @ARPay p
WHERE  NOT EXISTS (SELECT * FROM @ARChg WHERE fgc = p.fgc)
----------
DECLARE @Chg TABLE (fgc CHAR(10), chg MONEY NOT NULL)
INSERT INTO @Chg
            (fgc,
             chg)
SELECT a.financialgroup_id                                 AS fgc,
       Isnull(SUM(Isnull(cpt.invoicecpt_feeamount, 0)), 0) AS chg
FROM   lkup_financialgroup a
       JOIN bill_invoice bip
         ON ( a.financialgroup_id = bip.financialgroup_id )
            AND bip.invoice_recordstate = 0
            AND bip.invoice_id <> '0000000000'
       JOIN bill_invoicecpt cpt
         ON ( bip.invoice_id = cpt.invoice_id )
            AND cpt.invoicecpt_postdate >= {?Start Date}
            AND cpt.invoicecpt_postdate < Dateadd(DAY, 1, {?End Date})
            AND ( cpt.invoicecpt_recordstate = 0
                   OR cpt.invoicecpt_recordstate IS NULL )
            AND cpt.invoicecpt_id <> '0000000000'
WHERE  a.financialgroup_recordstate = 0
       AND a.financialgroup_id <> '0000000000'
GROUP  BY a.financialgroup_id
----------
DECLARE @Pay_Pat TABLE (fgc CHAR(10), pay_pat MONEY NOT NULL, adj_pat MONEY NOT NULL)
INSERT INTO @Pay_Pat
            (fgc,
             pay_pat,
             adj_pat)
SELECT a.financialgroup_id                AS fgc,
       SUM(Isnull(bp.payment_payment, 0)) AS pay_pat,
       SUM(Isnull(bp.payment_adjustment, 0)) + SUM(
       Isnull(bp.payment_adjustment1, 0))
                                          AS adj_pat
FROM   lkup_financialgroup a
       JOIN bill_invoice bip
         ON ( a.financialgroup_id = bip.financialgroup_id )
            AND bip.invoice_recordstate = 0
            AND bip.invoice_id <> '0000000000'
       JOIN bill_payment bp
         ON ( bip.invoice_id = bp.invoice_id )
            AND bp.payment_dateposted >= {?Start Date}
            AND bp.payment_dateposted < Dateadd(DAY, 1, {?End Date})
            AND bp.payment_recordstate = 0
            AND bp.payment_id <> '0000000000'
WHERE  bp.payment_paymentby = 'P'
       AND a.financialgroup_recordstate = 0
       AND a.financialgroup_id <> '0000000000'
GROUP  BY a.financialgroup_id,
          bp.payment_paymentby
----------
DECLARE @Pay_Ins TABLE (fgc CHAR(10), pay_ins MONEY NOT NULL, adj_ins MONEY NOT NULL)
INSERT INTO @Pay_Ins
            (fgc,
             pay_ins,
             adj_ins)
SELECT a.financialgroup_id,
       SUM(Isnull(bp.payment_payment, 0)) AS pay_ins,
       SUM(Isnull(bp.payment_adjustment, 0)) + SUM(
       Isnull(bp.payment_adjustment1, 0))
                                          AS adj_ins
FROM   lkup_financialgroup a
       JOIN bill_invoice bip
         ON ( a.financialgroup_id = bip.financialgroup_id )
            AND bip.invoice_recordstate = 0
            AND bip.invoice_id <> '0000000000'
       JOIN bill_payment bp
         ON ( bip.invoice_id = bp.invoice_id )
            AND bp.payment_dateposted >= {?Start Date}
            AND bp.payment_dateposted < Dateadd(DAY, 1, {?End Date})
            AND bp.payment_recordstate = 0
            AND bp.payment_id <> '0000000000'
WHERE  bp.payment_paymentby = 'I'
       AND a.financialgroup_recordstate = 0
       AND a.financialgroup_id <> '0000000000'
GROUP  BY a.financialgroup_id,
          bp.payment_paymentby
----------
SELECT lf.financialgroup_id          AS fgc,
       lf.financialgroup_description AS fgc_name,
       Isnull(s1.archg, 0)           AS archg,
       Isnull(s2.arpay, 0)           AS arpay,
       Isnull(s3.chg, 0)             AS charges,
       Isnull(p2.pay_pat, 0)         AS pay_pat,
       Isnull(p2.adj_pat, 0)         AS adj_pat,
       Isnull(i2.pay_ins, 0)         AS pay_ins,
       Isnull(i2.adj_ins, 0)         AS adj_ins,
       Isnull(s2.arpay, 0)           AS 'Pmts and Adjs Total'
FROM   @ARChg s1
       LEFT JOIN @ARPay s2
         ON ( s2.fgc = s1.fgc )
       LEFT JOIN (SELECT p.fgc
                  FROM   @ARChg g
                         LEFT JOIN @ARPay p
                           ON ( p.fgc = g.fgc )) s
         ON ( s.fgc = s1.fgc )
       LEFT JOIN @Chg s3
         ON ( s3.fgc = s1.fgc )
       LEFT JOIN (SELECT c.fgc
                  FROM   @ARChg g
                         LEFT JOIN @Chg c
                           ON ( c.fgc = g.fgc )) sc
         ON ( sc.fgc = s1.fgc )
       LEFT JOIN (SELECT p1.fgc
                  FROM   @ARChg g
                         LEFT JOIN @Pay_Pat p1
                           ON ( g.fgc = p1.fgc )) sp1
         ON ( s1.fgc = sp1.fgc )
       LEFT JOIN (SELECT i1.fgc
                  FROM   @ARChg i
                         LEFT JOIN @Pay_Ins i1
                           ON ( i.fgc = i1.fgc )) sp2
         ON ( s1.fgc = sp2.fgc )
       LEFT JOIN @Pay_Pat p2
         ON s1.fgc = p2.fgc
       LEFT JOIN @Pay_Ins i2
         ON s1.fgc = i2.fgc
       LEFT JOIN lkup_financial lf
         ON ( lf.financialgroup_id = s1.fgc )
ORDER  BY lf.financialgroup_description
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 18 Aug 2011 at 6:27am
try data
verify database
a mapping box should come up
sharona
IP IP Logged
cmboykin
Newbie
Newbie


Joined: 18 Aug 2011
Online Status: Offline
Posts: 4
Quote cmboykin Replybullet Posted: 18 Aug 2011 at 6:46am
I have tried that when I do that I get
map field box.
 
With no options to map the map or unmap buttons are greyed out.
 
 
 
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 18 Aug 2011 at 7:11am
have you set the datasource to the dataset then verified. sometimes you need to log off the attached server, log on, set the datset and verify.
 
sharona
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 18 Aug 2011 at 7:12am
what happens when you start a new report with the command do you get the fields in the rpt, if so it may be a setting on the report
sharona
IP IP Logged
cmboykin
Newbie
Newbie


Joined: 18 Aug 2011
Online Status: Offline
Posts: 4
Quote cmboykin Replybullet Posted: 18 Aug 2011 at 7:26am
I have done all the above. I have started multiple new reports, still nothing.  This is really weird because I can paste other queries in that command and get data. I'm not that strong of a coder to start from the beginning with this report.
IP IP Logged
cmboykin
Newbie
Newbie


Joined: 18 Aug 2011
Online Status: Offline
Posts: 4
Quote cmboykin Replybullet Posted: 18 Aug 2011 at 7:28am
Sharona I appreciate your help, I am so deperate I am thinking of hiring an outside person to redo this report. I needed this like yesterday. Any suggestions.
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 18 Aug 2011 at 8:02am
make sure the properites on the report are not read only.
post your issue here, this is a good crystal site also.
look towards the bottom for the


Edited by sharona - 18 Aug 2011 at 8:03am
sharona
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum