How to get the result set in batches
I have a query which results into large data. This data i want to display in a group of 20. After every 20 records i want to add header and footer to it.
Is it possible to get the result set data into batch of 20 ? means can i specify start and end index of query ?
regards
Manisha
What I am saying is that a big query with lots of
joins will probably be slow, and as such would be a
ripe candidate for batching the responses, if it were
not possible to speed/optimize it. Batching is nice
to look at for the user, but is not a solution for
performance problems. In essence it is irrelevant
that it adds a little performance deficit, as it
appears to be running a lot quicker, and gives more
feedback to the user.Then let me say it again....
- "Join" is a term that applies to a method of doing queries in the database....
- Query 1 which uses a join and returns 15 rows
- Query 2 which does not use a join and returns 1500 rows.
Given the above then Query 1 will provide better overall performance for the system than Query 2 in a properly configured database.
If it doesn't then the database is not set up correctly.
And again this will be irrespective of whether the query is scrollable or not.
Similar Messages
-
How to get the results for given Bind Variable
Hi
Can any one help me how to get the result rows from the View Object after executing the view object query by setting bind variable?
snippet as follows
viewObject.setNamedWherClauseParams("name","hei");
viewObject.executeQuery();
How to get the results from viewObject is my question..?
Thanks in advanceShould be something like
while (vo.hasNext()){
Row r = vo.next();
r.getAttribute....
You might want to read the "most commonly used methods" appendix in the ADF Developer Guide. -
Call function in background task... How to get the result?
I want to use Call function in background task parameter.
But I cannot find the result of this function. (No export parameter, no table result, no exception)
How to get the result of this function module? Correct or not?Hi Heinz,
You can check the result in SM58 transaction.
For more information pls. refer this thread :
No IMPORTING parameters allowed in CALL FUNCTION IN BACKGROUND TASK
Best regards,
Prashant -
Af:query - How to get the result rowsets
Hi,
I have a requirement where i need to search the db rows on and append the results the adf rich table on each search.
For this i am using af:query component. And trying to get the result rows for the named criteria.
String mexpr = "#{bindings.DestinDescVOCriteriaQuery.processQuery}";
processMethodExpression(mexpr, queryEvent, QueryEvent.class);
ViewCriteriaManager vcm = getDestinDescViewObj().getViewCriteriaManager();
ViewCriteria vc = vcm.getViewCriteria("DestinDescVOCriteria");
getDestinDescViewObj().applyViewCriteria(vc);
AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
adfFacesContext.addPartialTarget(tblDestinDesc);
However on each click of search the rows searched in the previous attempt are not retained.
Can anyone let me know how to get the result from named criteria and append it the table?
Thanks
AjayCan anyone help?
-
how can i do with labview program,when i have 20 different values,and 1 want to add it with constant value.and how to get the results?
Why do the 20 values have to be different? The same code should work even if some are equal.
What do you mean by "get the result"? The result is available at the output terminal and all you need is a wire to get it where you need it. That could be an indicator, another operation, or even a hardware device.
What is the data type of the 20 values? An array? A cluster? A bunch of scalars? A waveform? Dynamic data?
LabVIEW Champion . Do more with less code and in less time . -
How to get the results in one line
Hi
if i use the script below i get the name of path and then : and in next line i get the results.is there a way to get the results from every path after the : and not in the next line?
another question - is there a way that the script will not show the server name on every path?
(Get-Counter -ListSet LogicalDisk).PathsWithInstances | Get-Counter
THCIf you take you script and pipe it to get member, it will give you a list of various script properties.
(Get-Counter -ListSet LogicalDisk).PathsWithInstances | Get-Counter | get-member
You will see that the object type returned by "Get-Counter" is Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet.
TypeName:
Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSampleSet
Name MemberType Definition
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
CounterSamples Property Microsoft.PowerShell.Commands.GetCounter.Perfo...
Timestamp Property datetime Timestamp {get;set;}
Readings ScriptProperty System.Object Readings {get=$strPaths = ""...
You can try grabbing different properties, and they will print out differently, displaying the data on the same line in some cases. For example, pipe your output to a "foreach-object" block, and then for each object print out the CounterSamples property.
(Get-Counter -ListSet LogicalDisk).PathsWithInstances | Get-Counter | foreach-object { ($_).CounterSamples }
This should all print on one line now. However, you also asked if there was a way to not have the server print out on every line. The way to control the format of these outputs is to use the "format-table" cmdlet. So you would pipe your output to format-table
and then give it various options. This is how you would pipe it (without any options).
(Get-Counter -ListSet LogicalDisk).PathsWithInstances |
Get-Counter | object { ($_).CounterSamples | format-table }#OR USE YOUR ORIGINAL CODE(Get-Counter -ListSet LogicalDisk).PathsWithInstances |
Get-Counter | format-table }
Now, it's up to you to give format-table the options you want. With no options, output will look unchanged. To see what options are available to you, use get-help.
get-help format-table
I hope this helps!
Thank for all the info... -
How to return the result set of multiple select statements as one result set?
Hi All,
I have multiple select statements in my stored procedure that I want to return as one result set
for instance
select id from tableA
union
select name from table b
but union will not work because the result sets datatypes are not identical so how to go about this ?
ThanksYou have to CAST or CONVERT (or implicitly convert) the columns to the same datatype. You must find a datatype that both columns can be converted to without error. In your example I'm guessing id is an int and name is a varchar or nvarchar.
Since you didn't convert the datatypes, SQL will use its data precedence rules and attempt to convert name to an int. If any row contains a row that has a value in name that cannot be converted to an int, you will get an error. The solution is
to force SQL to convert the int to varchar. So you want something like
select cast(id as varchar(12)) from tableA
union
select name from tableb
If the datatypes are something other that int or varchar, you must find a compatable datatype and then convert one (or both) of the columns to that datatype.
Tom -
We have a GUI swing screen in which we have navigation buttons.
when the user clicks the previous ,next, last,first buttons we have to show the records accordingly.
The min. size of the database is around 1 million.and each row has 60 columns.
Our approach is screen--->servlet-->ejb beans --->database.
since the database is huge how to hold the values, and where, without affecting the performance.
If we get the resultset it holds all the data.since the data size is huge,we are looking for a solution.The user may browse through the data ,edit the data and delete the data.
we have to perform accordingly. Also, if, for example, user1 is seeing record no.1 & user 2 has modified record no.3 in the meanwhile, when user1 goes to record no.3, he should see the
modified record. In short, the user should always see the latest values.
please give us the best approach to solve this problem.
Also this is in a multi user environment.It seems like you need to look at threads to update current values in the display and narrow the result set that you retrieve to match the criteria needed for display. You might consider making the method to change values a syncronized one.
-
It is required to get the result set from the last query.
I need this SP to return the result set from the last query.
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
alter proc spQ_GetASCBillingRateIDs2
@ScheduleID CHAR(15),
@startdate smalldatetime,
@enddate smalldatetime
as
set nocount on
truncate table tbltmpgroup
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbltmptbltest]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tbltmptbltest]
exec sp_CreateTblTmpGroup
insert into tbltmpgroup
SELECT DISTINCT
case when pd.billparent = 'N' then org.eligibleorgid
else isnull(af.parentid, org.eligibleorgid) end as billorgid,
pd.individualbill , pd.cobrabill, pd.billparent,
org.eligibleorgid, org.polid, org.orgpolicyid,
pp.planid, pp.rateid,
ps.ascinvoicedate,
case when ps.ascclaimfromdate > @startdate then ps.ascclaimfromdate
else @startdate end as premiumrundayFrom,
case when ps.ascclaimtodate < @enddate then ps.ascclaimtodate
else @enddate end as premiumrundayTo,
fts.effdate, fts.termdate,
case when fts.effdate > @startdate then fts.EffDate
else @startdate end as ascStartDate,
case when fts.termdate < @enddate then fts.termdate
else @enddate end as ascEndDate
FROM premiumschedule ps (nolock)
inner join orgpolicy org (nolock)
on org.ascinvoicerungroup between ps.premiumrundayfrom and ps.premiumrundayto
inner join FundingTypeStatus fts
on fts.orgpolicyid = org.orgpolicyid
and fts.fundtype = 'ASC'
and ((fts.effdate between @startdate and @enddate)
or (fts.termdate between @startdate and @enddate)
or (fts.effdate < @startdate and fts.termdate > @enddate))
inner join eligibilityorg o (nolock)
on org.eligibleorgid = o.eligibleorgid
inner join policydef pd (nolock)
on pd.polid = org.polid
inner join policyplans pp (nolock)
on pp.polid = org.polid
inner join program p (nolock)
on pd.programid = p.programid
left join orgaffiliation af with (nolock)
on org.eligibleorgid = af.childid
WHERE ps.premiumscheduleid = @ScheduleID
AND org.orgpolicyid <> ''
go
SELECT DISTINCT z.rateid, e.enrollid, z.ascstartdate, z.ascenddate
into tbltmptbltest FROM enrollment E (nolock)
inner join tbltmpgroup z
on e.rateid = z.rateid
go
CREATE UNIQUE CLUSTERED INDEX IDXTempTable ON tbltmptbltest(enrollid)
create index IDXTemptableDates on tbltmptbltest(ascstartdate,ascenddate)
go
select distinct t.*
from tbltmpgroup t
where rateid in (
select distinct t.rateid from VW_ASC_Billing)
order by billorgid
set nocount off
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GOPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules (you have no idea).
Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
What you did post is bad SQL.
The prefix “tbl-” is a design flaw called tibbling and we do not do it. We seldom use temp tables in RDBMS; it is how magnetic tape file programmers fake scratch tapes.
If the schema is correct, then SELECT DISTINCT is almost never used.
Your “bill_parent” looks like a assembly language bit flag; we never use those flags in SQL.
“Funding_Type_Status” is an absurd name for a table. A status is a state of being, not an entity. A type is an attribute property. So this table ought to be column that is either a “funding_type” or “funding_status” (with the time period for the state of being
shown in other columns). But this hybrid is not possible in a valid data model.
Want to try again, with DDL and some specs?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
DbGetQuery = How to get the results to display?
I am using the following
sqldata <- dbGetQuery(con," select sysdate from dual")
How do I get the result to display?
summary(sqldata) displays the values
if I do dbSendQuery then fetch show the results
help(dbSendQuery) and help(dbGetQuery) go to the same page! dbSendQuery
The documentation says dbGetQuery will connect, get the records and clear; maybe the clear happens before the display?!Hello Amin,
Here is the way to display the result from the query you provided:
Assign the result of the query to object 'sqldata':
R> sqldata <- dbGetQuery(con," select sysdate from dual")
Type the object name at the R prompt:
R> sqldata
SYSDATE
1 2014-04-28 14:45:14
Sherry -
How to get the record set into array?
Hi,
I want to get the record set into array in the procedure and do the processing of the array later in procedure.
below is the stored procedure i am working on:
procedure bulk_delete_group(p_group_id in Array_GroupListID) as
begin
for i in p_group_id.first..p_group_id.last loop
--Here I have to get the list of user id before deleting group
SELECT user_id into *<SOME ARRAY>* FROM group_members WHERE group_id = p_group_id(i);
DELETE group WHERE group_id = p_group_id(i);
--Process the user id array after group deletion..
end loop;
end bulk_delete_group;
Thanks in advance
AdityaSomething like this ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.20
satyaki>
satyaki>
satyaki>select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10
7777 SOURAV SLS 14-SEP-08 45000 3400 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 4450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 7000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
13 rows selected.
Elapsed: 00:00:02.37
satyaki>
satyaki>create type np is table of number;
2 /
Type created.
Elapsed: 00:00:03.32
satyaki>
satyaki>Create or Replace Procedure myProc(myArray np)
2 is
3 i number(10);
4 rec emp%rowtype;
5 Begin
6 for i in 1..myArray.count
7 loop
8 select *
9 into rec
10 from emp
11 where empno = myArray(i);
12
13 dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename);
14 end loop;
15 End myProc;
16 /
Procedure created.
Elapsed: 00:00:00.88
satyaki>
satyaki>
satyaki>declare
2 v np:=np(9999,7777);
3 begin
4 myProc(v);
5 end;
6 /
Employee No:9999 Name:SATYAKI
Employee No:7777 Name:SOURAV
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.30
satyaki>Regards.
Satyaki De. -
How to get the result of a method on a page
I use JDeveloper 11g
I want the result of a method (String) in the ApplicationModule on a page (jspx)
What I have done is:
1. make a method (getValue) in the ApplicationModule Algemeen (also in Client interface)
2. make a pagedef-file with executables and bindings, see
<executables>
<invokeAction id="doGetValue" Binds="getValue"
Refresh="renderModel"/>
<variableIterator id="variables" Refresh="renderModel">
<variable Type="java.lang.String" Name="getValueReturn"
IsQueriable="false" IsUpdateable="0"
DefaultValue="${bindings.getValue.result}"/>
</variableIterator>
</executables>
<bindings>
<methodAction id="getValue" RequiresUpdateModel="true"
Action="invokeMethod" MethodName="getValue"
IsViewObjectMethod="false" DataControl="AlgemeenDataControl"
InstanceName="AlgemeenDataControl.dataProvider"
ReturnName="AlgemeenDataControl.methodResults.getValue_AlgemeenDataControl_dataProvider_getValue_result"/>
<attributeValues IterBinding="variables" id="ValueReturn">
<AttrNames>
<Item Value="getValueReturn"/>
</AttrNames>
</attributeValues>
</bindings>
3. on the page (jspx) I have an outputText-component:
<h:outputText value="#{bindings.ValueReturn.inputValue}"/>
But, it does not work, I don't get the result of the method on the screen.
Who can help me with this?Hi,
Simple example below:
Suppose you have this method in AppmoduleImpl:
public void testHello( ) {
return "Hello";
1.After you expose this to clientInterface,drop this method on the jspx page as ADF Parameter
form
2.Drop the return String as outputText
3.Run the page,click on the commandButton & the outputText returns 'Hello'
Regards,
Shantala -
How to get the resulting XML as string
Hello,
I think my question is very simple but i'm new in this area.
What i'm try to do is to parse a XML document with the DOM parser. Then i manipulate the DOM tree. After finishing the process i want to get the resulting XML document as an InputStream to give to another application for storing back into the database.
Until know i print the resulting XML to System.out or I write it to a file.
Do you know where i can find more information about this? Sample code??
Thanks!<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jinyu Wang ([email protected]):
You can try following code. It is not the simplest way, but it works for me:
// Print to temp buffer
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(baos);
Xml_doc.print(output);
String outtemp=baos.toString();
System.out.println(outtemp);
include following line for the lib:
import java.io.*;<HR></BLOCKQUOTE>
Many thanks for the reply. It works! -
How to get the variable set by c:set in Scriptlet ?
Hello,
I set up some variables by <c:set> and struts tag <bean:size>, and the values should be considered as integers. How can I use the variables in math expression?
When I try to use the variables in scriptlets, I got compile errors in the getAttribute lines.
My code:
<bean:size id="listSize" name="list" /> <c:set var="pageSize" value="${20}" />
<c:set var="pageBegin" value="${param.pageBegin}" />
<%
int ls = (Integer)pageContext.getAttribute("listSize");
int ps = (Integer)pageContext.getAttribute("pageSize");
int totalPages = (int)Math.ceil((double)ls / ps);
%>xiaoxuan_li wrote:Hello,
I set up some variables by <c:set> and struts tag <bean:size>, and the values should be considered as integers. How can I use the variables in math expression?
When I try to use the variables in scriptlets, I got compile errors in the getAttribute lines.
My code:
<bean:size id="listSize" name="list" />
<c:set var="pageSize" value="${20}" />
<c:set var="pageBegin" value="${param.pageBegin}" />
<%
bq. int ls = (Integer)pageContext.getAttribute("listSize"); \\ int ps = (Integer)pageContext.getAttribute("pageSize"); \\ int totalPages = (int)Math.ceil((double)ls / ps);
%>I finally find the errors, I change the getAttribute() lines to the following, and the program runs well, although I'm still curious of if there is a better way to get the value of totalPages by using JSTL tags, instead of scriptlets.
<%
bq. {color:#ff0000}Number {color}ls = {color:#ff0000}(Number){color}pageContext.getAttribute("listSize"); \\ {color:#ff0000}Number {color}ps = {color:#ff0000}(Number){color}pageContext.getAttribute("pageSize");
%> -
How to control the result of a batch input
Hi everyone,
We have a program that update the item category in the sales orders, after that using a batch input the system executes the va02 transaction to update the order, after the order has been updated we have to make the materials movement.
Th eproblrm is that I need to know how can I control if the batch input has been executed correctly or not, because in that case the materials movement must not be executed.
If help, the code is the following:
FORM Batch_VA02.
data: begin of bdcdata occurs 0.
include structure bdcdata.
data: end of bdcdata.
data: campo(20) type c.
data: campopos(20) type c.
data: campomarcar(20) type c.
data: campocambiar(20) type c.
loop at PA1 where sel = 'X'. "ya está en un loop, al estar en en
LANZAR_BATCH
refresh bdcdata.
Primera pantalla, introducir número pedido y enter.
perform p TABLES BDCDATA using 'SAPMV45A' '0102' .
perform c TABLES BDCDATA using 'VBAK-VBELN' pa1-pedid.
perform c TABLES BDCDATA using 'BDC_OKCODE' '/00'.
Segunda pantalla. Pulsar "Aprovisionamiento".
perform p TABLES BDCDATA using 'SAPMV45A' '4001'.
perform c TABLES BDCDATA using 'BDC_OKCODE' '=T05'.
Antes de la tercera pantalla hay que posicionarse.
perform p TABLES BDCDATA using 'SAPMV45A' '4001'.
perform c TABLES BDCDATA using 'BDC_OKCODE' '=POPO'.
Introducir número de posición
campo = '01'.
perform posicion changing campo.
perform p TABLES BDCDATA using 'SAPMV45A' '0251'.
Inicio modificación Chema Campos 28.06.2007 (CAU 58283)
perform c TABLES BDCDATA using 'RV45A-POSNR' pa1-posic.
if global_pos_nueva is initial.
perform c TABLES BDCDATA using 'RV45A-POSNR' pa1-posic.
else.
perform c TABLES BDCDATA using 'RV45A-POSNR' global_pos_nueva.
endif.
clear global_pos_nueva.
Fin modificación Chema Campos 28.06.2007 (CAU 58283)
perform c TABLES BDCDATA using 'BDC_OKCODE' '=POSI'.
move 'VBAP-BEDAE(01)' to campopos.
move 'RV45A-VBAP_SELKZ(01)' to campomarcar.
move 'VBAP-BEDAE(01)' to campocambiar.
Antes de la tercera pantalla hay que posicionarse.
campo = '01'.
perform posicion changing campo.
do.
if campo > '10'. "hay que paginar.
perform p TABLES BDCDATA using 'SAPMV45A' '4001'.
perform c TABLES BDCDATA using 'BDC_OKCODE' '=P+'.
campo = campo - 10.
endif.
condense campo.
if campo+1(1) eq space.
concatenate '0' campo into campo.
endif.
if campo <= '10'.
exit.
endif.
enddo.
condense campo.
clear: campopos, campomarcar, campocambiar.
concatenate 'VBAP-BEDAE(0' campo ')' into campopos.
concatenate 'RV45A-VBAP_SELKZ(0' campo ')' into campomarcar.
concatenate 'VBAP-BEDAE(0' campo ')' into campocambiar.
Tercera pantalla. Introducir valor ZRES y grabar.
perform p TABLES BDCDATA using 'SAPMV45A' '4001'.
perform c TABLES BDCDATA using 'BDC_CURSOR' campopos.
"posicionamos
perform c TABLES BDCDATA using campomarcar 'X'.
"marcamos
perform c TABLES BDCDATA using campocambiar 'ZRES'.
"actualizamos valor
perform c TABLES BDCDATA using 'BDC_OKCODE' '=SICH'.
CALL TRANSACTION 'VA02' USING bdcdata UPDATE c_update
MESSAGES INTO messa MODE modo.
"A" temporalmete visible pra pruebas en integración
COMMIT WORK AND WAIT.
WAIT UP TO 2 SECONDS.
endloop.
ENDFORM. " Batch_VA02
Thanks everyonehi,
after executing va02 check for sy-subrc, if it is not equal to 0 .
catch the errors into BDCmsg of structure BDCMSGCOLL and there open session for error records and u can transfer them into file aslo.
ex:
REPORT zsr_report
NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZRASH.
*--Internal Table for Data Uploading.
DATA : BEGIN OF IT_FFCUST OCCURS 0,
KUNNR(10),
BUKRS(4),
KTOKD(4),
ANRED(15),
NAME1(35),
SORTL(10),
STRAS(35),
ORT01(35),
PSTLZ(10),
LAND1(3),
SPRAS(2),
AKONT(10),
END OF IT_FFCUST.
*--Internal Table to Store Error Records.
DATA : BEGIN OF IT_ERRCUST OCCURS 0,
KUNNR(10),
EMSG(255),
END OF IT_ERRCUST.
*--Internal Table to Store Successful Records.
DATA : BEGIN OF IT_SUCCUST OCCURS 0,
KUNNR(10),
SMSG(255),
END OF IT_SUCCUST.
*--Internal Table for Storing the BDC data.
DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*--Internal Table for storing the messages.
DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_FLAG1(1) VALUE ' ',
"Flag used for opening session.
V_TLINES LIKE SY-TABIX,
"For storing total records processed.
V_ELINES LIKE SY-TABIX,
"For storing the no of error records.
V_SLINES LIKE SY-TABIX.
"For storing the no of success records.
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
V_SESNAM LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
*-- Form to upload flatfile data into the internal table.
PERFORM FORM_UPLOADFF.
TOP-OF-PAGE.
WRITE:/ 'Details of the error and success records for the transaction'
ULINE.
SKIP.
END-OF-SELECTION.
*-- Form to Generate a BDC from the Uploaded Internal table
PERFORM FORM_BDCGENERATE.
*--To write the totals and the session name.
PERFORM FORM_WRITEOP.
FORM FORM_UPLOADFF .
*--Variable to change the type of the parameter file name.
DATA : LV_FILE TYPE STRING.
LV_FILE = V_FNAME.
*--Function to upload the flat file to the internal table.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = IT_FFCUST
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC = 0.
*--Deleting the headings from the internal table.
DELETE IT_FFCUST INDEX 1.
*--Getting the total number of records uploaded.
DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
ENDIF.
ENDFORM. " form_uploadff
FORM FORM_BDCGENERATE .
*--Generating the BDC table for the fields of the internal table.
LOOP AT IT_FFCUST.
PERFORM POPULATEBDC USING :
'X' 'SAPMF02D' '0105',
' ' 'BDC_OKCODE' '/00' ,
' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
'X' 'SAPMF02D' '0110' ,
' ' 'BDC_OKCODE' '/00',
' ' 'KNA1-ANRED' IT_FFCUST-ANRED,
' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
' ' 'KNA1-SORTL' IT_FFCUST-SORTL,
' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
'X' 'SAPMFO2D' '0120',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0125',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0130',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0340',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0360',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0210',
' ' 'KNB1-AKONT' IT_FFCUST-AKONT,
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0215',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0220',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0230',
' ' 'BDC_OKCODE' '=UPDA'.
*--Calling the transaction 'fd01'.
CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
MESSAGES INTO IT_CUSTMSG.
IF SY-SUBRC <> 0.
*--Populating the error records internal table.
IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_ERRCUST.
CLEAR IT_ERRCUST.
*--Opening a session if there is an error record.
IF V_FLAG1 = ' '.
PERFORM FORM_OPENSESSION.
V_FLAG1 = 'X'.
ENDIF.
*--Inserting the error records into already open session.
IF V_FLAG1 = 'X'.
PERFORM FORM_INSERT.
ENDIF.
*--Populating the Success records internal table.
ELSE.
IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_SUCCUST.
CLEAR IT_SUCCUST.
ENDIF.
*--Displaying the messages.
IF NOT IT_CUSTMSG[] IS INITIAL.
PERFORM FORM_FORMATMSG.
ENDIF.
*--Clearing the message and bdc tables.
CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
ENDLOOP.
*--Getting the total no of error records.
DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
*--Getting the total no of successful records.
DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
*--Closing the session only if it is open.
IF V_FLAG1 = 'X'.
PERFORM FORM_CLOSESESS.
ENDIF.
ENDFORM. " Form_bdcgenerate
FORM POPULATEBDC USING VALUE(P_0178)
VALUE(P_0179)
VALUE(P_0180).
IF P_0178 = 'X'.
IT_CUSTBDC-PROGRAM = P_0179.
IT_CUSTBDC-DYNPRO = P_0180.
IT_CUSTBDC-DYNBEGIN = 'X'.
ELSE.
IT_CUSTBDC-FNAM = P_0179.
IT_CUSTBDC-FVAL = P_0180.
ENDIF.
APPEND IT_CUSTBDC.
CLEAR IT_CUSTBDC.
ENDFORM. " populatebdc
*& Form FORM_OPENSESSION
Form to Open a session.
FORM FORM_OPENSESSION .
*--Variable to convert the given session name into reqd type.
DATA : LV_SESNAM(12).
LV_SESNAM = V_SESNAM.
*--Opening a session.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = LV_SESNAM
HOLDDATE = '20040805'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
IF SY-SUBRC <> 0.
WRITE :/ 'Session not open'.
ENDIF.
ENDFORM. " FORM_OPENSESSION
*& Form FORM_INSERT
fORM TO INSERT ERROR RECOED INTO A SESSION.
FORM FORM_INSERT .
*--Inserting the record into session.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FD01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = IT_CUSTBDC
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF SY-SUBRC <> 0.
WRITE :/ 'Unable to insert the record'.
ENDIF.
ENDFORM. " FORM_INSERT
*& Form FORM_CLOSESESS
Form to Close the Open Session.
FORM FORM_CLOSESESS .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " FORM_CLOSESESS
*& Form FORM_FORMATMSG
Form to format messages.
FORM FORM_FORMATMSG .
*--Var to store the formatted msg.
DATA : LV_MSG(255).
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = SY-LANGU
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = LV_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE :/ LV_MSG.
ENDIF.
ULINE.
ENDFORM. " FORM_FORMATMSG
*& Form form_writeop
To write the totals and the session name.
FORM FORM_WRITEOP .
WRITE :/ 'Total Records Uploaded :',V_TLINES,
/ 'No of Error Records :',V_ELINES,
/ 'No of Success Records :',V_SLINES,
/ 'Name of the Session :',V_SESNAM.
ULINE.
Maybe you are looking for
-
Hi, I am trying to connect an iPod touch 3rd (ios 5.1.1) generation to control my KEYNOTE's presentations in my iPad2 (ios 6.1.3). I activated bluetooth in both but they do not see each other. Is there any specific procedure to allow the connection o
-
How can I increment a dynamic value each time the request is sent?
One of my requests is passing a sequence number which gets incremented every time the request is sent. The sequence number is incremented in javascript on the client; the html looks something like this: target=target+"&sequenceNumber="+sequenceNumber
-
Free News Slider Webpart on Sharpoint 2010
Hi all, I Need a Free Slider News Webpart for Sharepoint 2010 Thanks in Advance
-
Input in Parent Currency Level
Hi, Is it possible to open input (without journal) in value other than "<Entity Currency"> ? For what dimension is it possible to open input? For what I know, it is possible to input in Entity. Is it possible also to open input in parent account , va
-
ListCellRenderer wont update until selected
Hi, I wonder if anyone could help, I have been implementing a ListCellRenderer, and have just changed it to inherit DefaultListCellRenderer. However, either way the JList will only update when an (or any for that matter) element is selected in it. Th