How to get select query for crystal report in c# code
In C#, (Visual Studio 2008 ) I need to use the native Crystal Reports objects to get the complete SQL statement as it appears when you view it in Crystal Reports.
In Crystal Reports 12.0, Go to "Database > Show SQL Query..." ... That is what I need to get via C# code. I can get bits and pieces of parameter info etc but I just want the whole SQL statement.
How to get this?
Hi Ganesh,
It's simple to use RAS, include the assemblies and use this to open your report document:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.DataSetConversion;
using CrystalDecisions.ReportAppServer.DataDefModel;
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ISCDReportClientDocument rptClientDoc;
To open the report use:
object rptName = openFileDialog.FileName;
rpt.Load(rptName.ToString());
rptClientDoc = rpt.ReportClientDocument;
Then to get the SQL set the log on info:
rptClientDoc.DatabaseController.LogonEx("10.50.212.77,1433", "xtreme", "sa", "password");
GroupPath gp = new GroupPath();
string tmp = String.Empty;
rptClientDoc.RowsetController.GetSQLStatement(gp, out tmp);
MessageBox.Show(tmp, "Data Source Set and SQL Statement", MessageBoxButtons.OK, MessageBoxIcon.Information);
Thank you
Don
Similar Messages
-
Select Query in Crystal Report
Dear all,
I have a report to be developed in which i have to fire more than 2 select quires. I am adding this quires in "Add Command" window, it doesn't give any error but gives output of first query only.
I have tried to use multiple commands in report but the query fields are not having any common field in it so i am not able to link it.
Is there any other way to use more than one query in crystal report?
Thanks in advance.
Ashish TambeDear Charles,
I am willing to develop a report in which i need to select diff data from diff table such as OOPR,ORDR,OINV and many more.based on diff conditions and it may happen that a query can give more than 2-3 records then i need to make summation for that. On the basis of this summation and some more formulas in CR i need to make some conclusions.
This cannot be done in single query. so i need to fire more than one select query.
Regards,
Ashish Tambe -
How to write selection Query for the following requirment.
Hi All,
I am new to ABAP, I need a help ,
I need to select all plants(WERKS) from MARC at Plant/Material level,
then I need to take all sales organozation(VKORG) from T001w,
then I need the company code(BUKRS) from TVKO based on VKORG,
then I need the currency key(WAERS) from T001 based on BUKRS,
Can any one help me in writing selection Query for the same?
Thanks All,
Debrup.Hi,
Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
If you struck up anywhere revert back.
Regards
Karthik D -
Selection Screen for crystal report ?
Hi to all,
Is it possible to create selection screen using Crystal report designer alone ?
I came to know that we can give selection parameteres using SELECT EXPERT option in desginer.
Can we create selection screen for user input like we have in abab (selection screen) ?.
Is it possible to check authorization using Crystal report designer ?
If anyone knows anything .... remotely connected with the question I asked please reply.
Waiting for reply.
Regards,
Surya.Surya,
To do what you are wanting, you will want to do the following:
1) Create parameters. Open the Field Explorer > right click Parameter Fields > fill in the necessary fields o create the desired parameter.
2) Add the parameter to the Select Expert.
2a) If you are using a SQL Command to generate your data set you will need to add the parameter name to the Parameter List of the Command and add it the selection criteria of the SQL statement.
Something like this:
WHERE f.FieldName = {?ParameterName}
HTH,
Jason -
How to create PLD_Items table for Crystal Reports
Hi experts,
Im trying to use the variable 130 for a report but in crystal reports, in some SAP Standard Reports the table PLD_Items appears, my question is how to create this structure for my report, i know that is an ADO.NET connection based on an XML file, but i dont know from where i can take this value can any one help me please?
Best Regards
DaveIf this is CR for B1, please post to SAP Business One Application
Alternatively see the SCN Site Index for the correct SCN Space for your product / component.
- Ludek
SCN Moderator -
How to get Opening Balance for Stock Report in Crystal Report?
Dear Experts,
I am using SAP B1 8.82.
I am new to crystal report and now trying to do a monthly stock report with the following format:
Species BatchNum OpeningBal QtyInKD QtyInRD QtyInCD Adj ClosingBal
ABC T1234 17.43 10.16 17.43 0.00 0.00 10.16
ClosingBal = OpeningBal + QtyInKD - QtyInRD - QtyInCD + Adj
Parameters:
- DateFrom
- DateTo
- WarehouseFrom
- WarehouseTo
I am having problem in defining formula to get the opening balance for each item. The report is grouped by species, whscode & batchNum.
Anyone please share with me how to write the formula for opening balance in stock report.
Thanks.
Best Regards,
LengHi
Check the below discussion it may helps you
Opening Stock Batchwise
With Regards
Balaji Sampath -
Complete novice needs help getting SQL Query into Crystal Reports XI
Post Author: MissMarnie
CA Forum: Data Connectivity and SQL
So I was given an intro level web course and a monster reference guide in prep to format a report. One of our developers wrote me everything I need for the report into a SQL Query and now I'm supposed to format it in CR XII literally do not know what to do from here. I'm able to set up the correct server as a datasource, if that's useful, but I don't know how to make the querey into a bunch of formattable fields in CR. If anyone can walk me through this, I'd be so grateful. I've attempted to look up SQL query in both the help and the book but I keep hitting a wall. The help dialog says things like "press this button" with no reference to what "this button" is. I'm sure it's obvious to the knowledgeable but I'm in a complete fog. Thanks in advancePost Author: synapsevampire
CA Forum: Data Connectivity and SQL
IF you're trying to get assistance with setting up a query as the source for a report, try posting your Crystal version and the database type.
Different software works differently.
In CR 9 and above, under the connection to the database you'll see Add Command. Select that and you can paste the query in.
As for not knowing how to generate a report, that requires experience, there's no generic solution of course..
-k -
How to write select query for all the user tables in database
Can any one tell me how to select the columns from all the user tables in a database
Here I had 3columns as input...
1.phone no
2.memberid
3.sub no.
I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
I am trying for this query since 30days...
Help me please....any kind of help is appreciated.....Hi,
user13113704 wrote:
... i need to include the symbol (') for the numbers(values) to get selected..
eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
Starting in Oracle 10, you can also use Q-notation:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
-- Run preliminary query to generate main query
SPOOL c:\my_sql_dir\all_ah_t.sql
SELECT 'select call time, record, agn from '
|| owner
|| '.'
|| table_name
|| ' where phone_no = ''6186759765'' and memberid = j34563298'
|| CASE
WHEN ROW_NUMBER () OVER ( ORDER BY owner DESC
, table_name DESC
) = 1
THEN ';'
ELSE ' UNION ALL'
END AS txt
FROM all_tables
WHERE SUBSTR (table_name, 1, 4) = 'AH_T'
ORDER BY owner
, table_name
SPOOL OFF
-- Restore SQL*Plus features that interfere with raw output (if desired)
SET FEEDBACK ON
SET PAGESIZE 50
-- Run main query:
@c:\my_sql_dir\all_ah_t.sql
so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"? -
How to write select query for this
Hi,
I had a html form and in the for i had drop down box and it needs to select multiple values from the drop down box. When i select multiple values then i have to write the SQL select statement query .
When i try to write the select statement and trying to run i am getting error.
select * from Table
where emo_no = '1,2,3'
this is how i write query please suggest me how to write query for selecting multiple values from the drop down box.
Thanksselect * from Table
where emo_no in ( 1,2,3)
for integer values
select * from Table
where emo_no in ('1','2','3')
for characters
If we talk about large scale applications that may have millions of records, I would suggest this.
declare @t table (v int)
insert into t (v) values (1)
insert into t (v) valves (2)
insert into t (v) values (3)
select *
from table
inner join @t t on table.emo_no = t.v
Using "in" for a where clause is not so bad for filtering on a few values, but if you are filtering a lot of rows and a lot of values (emo_no) the performance degrades quickly for some reasons beyond the scope of this.
This is just one solution, I'll through this out as well, instead of an in memory (@t) table, doing a disk based temp table (#t) and creating an index on the column "v".
create table #t (v int)
insert into #t (v) values (1)
insert into #t (v) valves (2)
insert into #t (v) values (3)
create index ix_t on #t (v)
select *
from table
inner join #t t on table.emo_no = t.v
drop table #t
Pardon any syntax errors and careful using a drop statement.
Sometimes in memory tables work better than disk temp tables, it takes some testing and trial and error depending on your datasets to determine the best solution.
Probably too much info ;-)
Byron Mann
[email protected]
[email protected]
Software Architect
hosting.com | hostmysite.com
http://www.hostmysite.com/?utm_source=bb -
How to get actual error from Crystal Report
We are using Crystal report in web service.
We faced some problem due to crystal report unexpected error.
Refer the below error message.
Xception E NSF NSFZ1100 20100608 145511565 GPRAB0 : GPRZ10 GUEC0001 [1] AbstractService Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Xception E NSF NSFZ1100 20100608 145511972 GPRAB0 : GPRZ10 GUEC0001 [1] AbstractService at System.Windows.Forms.MessageBox.ShowCore(IWin32Window owner, String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, Boolean showHelp)
at System.Windows.Forms.MessageBox.Show(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
at CrystalDecisions.Windows.Forms.CrystalReportViewer.HandleExceptionEvent(Object eventSource, Exception e, Boolean suppressMessage)
at CrystalDecisions.Windows.Forms.CrystalReportViewer.HandleExceptionEvent(Object eventSource, Exception e)
at CrystalDecisions.Windows.Forms.ReportDocumentBase.GetLastPageNumber()
at CrystalDecisions.Windows.Forms.ReportDocumentBase.GetLastPage()
at CrystalDecisions.Windows.Forms.DocumentControl.ShowLastPage()
at CrystalDecisions.Windows.Forms.PageView.ShowLastPage()
at Biz.Nissan.Cats.CORE.REPORT.LibCrystalReport.TotalPageCount(ReportDocument Rpt)
at Biz.Nissan.Cats.CORE.REPORT.LibCrystalReport.Print(BaseReport RptDefinition)
at Biz.Nissan.Cats.CORE.REPORT.MCTLIST260Print.Print(IFData ifData)
at Biz.Nissan.W3.CATS.BC.Service.DistributeService.ExecuteMpp()
How we get the actual error from crystal report?
Thanks in AdvanceSame as
crystal report unexpected error in Web service (IIS)
Closing this thread.
Ludek -
Internal tables & select query for clasical report
hello all,
i am a novice in ABAP.i need to retrive data from 4 DB tables to do a classical report. i declared internal tables as below and then retrieved the data as per the below select statements. is there any other way in which i can do the same with a comparitively lesser amt of code.
data: begin of i_vbak occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
waerk like vbak-waerk,
end of i_vbak.
data: begin of i_vbap occurs 0,
vbeln like vbap-vbeln,
kwmeng like vbap-kwmeng,
posnr like vbap-posnr,
vrkme like vbap-vrkme,
netpr like vbap-netpr,
end of i_vbap.
data: begin of i_lips occurs 0,
vbeln like lips-vbeln,
vgpos like lips-vgpos,
vrkme like lips-vrkme,
lfimg like lips-lfimg,
end of i_lips.
data: begin of i_vbep occurs 0,
vbeln like vbep-vbeln,
posnr like vbep-posnr,
edatu like vbep-edatu,
end of i_vbep.
data: begin of i_out occurs 0,
kunnr like vbak-kunnr,
vbeln like vbak-vbeln,
kwmeng like vbap-kwmeng,
netpr like vbap-netpr,
waerk like vbak-waerk,
vrkme like vbap-vrkme,
lfimg like lips-lfimg,
posnr like vbep-posnr,
edatu like vbep-edatu,
end of i_out.
RETRIVING THE DATA INTO INTERNAL TABLE *
select vbeln kunnr waerk from vbak into table i_vbak where kunnr in
s_kunnr and vbeln in s_vbeln.
select vbeln kwmeng posnr vrkme netpr from vbap into table i_vbap for
all entries in i_vbak where vbeln = i_vbak-vbeln.
select vbeln vgpos vrkme lfimg from lips into table i_lips for all
entries in i_vbak where vbeln = i_vbak-vbeln and vgpos in s_vgpos.
select vbeln posnr edatu from vbep into table i_vbep for all entries in
i_vbak where vbeln = i_vbak-vbeln.
<b>Points are guaranteed for good answers.</b>
Thanks in advance
seenuHi,
If u will use in ALV means how many tables u want u can put it. After that u can maintain one internal table that's enough. Afterthat put select queries after that display the internal table fileds.
If u will ALV report means u have to code same coding for every report slight changes only there.
Herewith i am sending sample ALV REPORT it is useful for u.
REPORT CODING:
REPORT YMS_COLOURALV NO STANDARD PAGE HEADING.
TYPE-POOLS: SLIS, ICON.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF IMARA OCCURS 0,
LIGHT(4) TYPE C,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
COLOR_LINE(4) TYPE C,
TCOLOR TYPE SLIS_T_SPECIALCOL_ALV, "cell
END OF IMARA.
DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM WRITE_REPORT.
Get_Data
FORM GET_DATA.
WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'ABC'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for ABC'.
APPEND IMARA.
WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'DEF'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for DEF'.
APPEND IMARA.
WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'GHI'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for GHI'.
APPEND IMARA.
LOOP AT IMARA.
IF SY-TABIX = 1.
IMARA-COLOR_LINE = 'C410'. " color line
ENDIF.
IF SY-TABIX = 2. " color CELL
CLEAR XCOLOR.
XCOLOR-FIELDNAME = 'MTART'.
XCOLOR-COLOR-COL = '3'.
XCOLOR-COLOR-INT = '1'. " Intensified on/off
XCOLOR-COLOR-INV = '0'.
APPEND XCOLOR TO IMARA-TCOLOR.
ENDIF.
MODIFY IMARA.
ENDLOOP.
ENDFORM. "get_data
WRITE_REPORT
FORM WRITE_REPORT.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
PERFORM BUILD_FIELD_CATALOG.
CALL ABAP LIST VIEWER (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT
TABLES
T_OUTTAB = IMARA.
ENDFORM. "write_report
BUILD_FIELD_CATALOG
FORM BUILD_FIELD_CATALOG.
DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
CLEAR: FIELDCAT. REFRESH: FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Status'.
FC_TMP-FIELDNAME = 'LIGHT'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '4'.
FC_TMP-ICON = 'X'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Number'.
FC_TMP-FIELDNAME = 'MATNR'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '18'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Type'.
FC_TMP-FIELDNAME = 'MTART'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '10'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material'.
FC_TMP-FIELDNAME = 'MAKTX'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '40'.
FC_TMP-EMPHASIZE = 'C610'. " color column
APPEND FC_TMP TO FIELDCAT.
ENDFORM. "build_field_catalog
Thanks,
Shankar -
How do I install UFL for Crystal Report XI for use on BOE InfoView XI 3.1?
I have a Crystal XI Report that uses a UFL that was created by someone else. The library works just fine on my machine but I need to put this report out in BOE InfoView XI 3.1 for users. The library is Java Class.
I have tried to put the library onto the BOE server but the folder structure, etc. is different on the BOE server.
Could use some help on this.
Thanks in advance.I have a license for Crystal XI on my desktop and that is all.
We have licensing for BOE Repository to store and execute Crystal Reports. When I run a published Crystal Report the view panel in InfoView displays Crystal Report 2008 logo.
Crystal Reports with UFL work on my machine because I can follow the documentation for Crystal Java UFL's (which is the same as the note you referenced), but that documentation is useless for BOE InfoView because Crystal Reports on the BOE InfoView server is entirely different. -
How to get "Selected" color for custom toolbar buttons?
RH 8.0.2.208
RoboHelp HTML
WebHelp output
I'm getting flack from internal QA folks about the custom toolbar buttons not having the same "selected" color as the default buttons (Contents, Index). I've copied the background color info from the <btnselected></btnselected> section for the built-in Contents to the <btnselected></btnselected> section for a custom toolbar button, but RH is ignoring it.
Any hints?
LeonYou could try using the raw converter. Open one file and edit it (File>Open, pick the image and choose Camera Raw as the format before you click Open). Then open the next image and click the little four-lined square on the upper right side of the ACR window and choose Previous Conversion from the flyout menu.
-
Error Query for Crystal Report
Hi Everyone
I have an error with my Crystat Reports
state = "TOR"
If rdo_WSO.Checked = True Then
With Frm_Print
.strReport = "Filter"
.strWhere = "{TblTORGrad.TORWithoutSO} = '' and {TblTORGrad.Course}='" & ComboBox2.SelectedValue & "' and {TblTORGrad.DateApplied} like '" & ComboBox1.SelectedValue & "*'"
End With
Else
With Frm_Print
.strReport = "Filter"
.strWhere = "{TblTORGrad.TORWithSO} = '' and {TblTORGrad.Course}='" & ComboBox2.SelectedValue & "' and {TblTORGrad.DateApplied} like '" & ComboBox1.SelectedValue & "*'"
End With
Error Says "A string is requiredd here details error kind error in file CrystalReport1 {D6562CE5-995A-4371-88F0-A199B7C28}.rpt Error Formula Record_Selection: {TblTORGrad.DateApplied}like '*" A string is required here. Details: errorKindTry it in the Report Designer first, whatever Date field type you are using needs to be converted to a string for comparison, exactly what the error indicates.
Don -
Hi All,
I need to modify the SQL for retrieving assets from assets tab and assets in merchandising in 10.1.2. I found the class for SQLQuery builder, but I want to change the SQL.
Could you anyone please how to solve this.
Thanks & Regards,
BalaHi All,
I need to modify the SQL for retrieving assets from assets tab and assets in merchandising in 10.1.2. I found the class for SQLQuery builder, but I want to change the SQL.
Could you anyone please how to solve this.
Thanks & Regards,
Bala
Maybe you are looking for
-
How to I get the total number of songs listed in my Itunes library to display?
With recent versions of I Tune intallations I no longer receive the total number of songs listed in my Libary. I am using I Tunes v. 11.1.3.8 on windows 7. TodonKansas
-
Is this really a java bug?
# An unexpected error has been detected by HotSpot Virtual Machine: # SIGSEGV (0xb) at pc=0x8d22d623, pid=12929, tid=2293337008 # Java VM: Java HotSpot(TM) Server VM (1.5.0_06-b05 mixed mode) # Problematic frame: # [thread 2106588080 also had an erro
-
Hi Folks, I would like to know which configuration path in SPRO is used to define IDoc number range
-
Table Names...Tricky
This is the scenerio: 1) i have a table name: GEOCODECI 2) i have used DESC all_tables, dba_tables, user_tables, tab, v$session, v$database, and by using select table_name able to see both my other tables and their respected owner. 3) However i can n
-
How do I sync individual TV shows from a whole season on my iphone?
I purchased the entire season of a TV show, but when I can't figure out how to get only chosen episodes on my iphone (unless I choose "sync lastest episode" or "unwatched") I want to be able to choose a specific episode to upload to phone, but in the