Need sequence on resultset without using ROWNUM
I need to query some data from a SQLServer 2000 database (which don't
have analytic SQl capibilities) and load it into Oracle 10g Warehouse. It must be
done in a query, SQLServer don't do cursor very well. So I need a ANSI standard Query.
I need a way of putting a sequential number on a result set. SQLServer does not have ROWNUM.
I need a slick equivalent of: select rownum, value1, value2 from <some table>
Can't use ROWNUM
Only for MS SQL Server:
set nocount on
if exists (select * from sysobjects where type = 'U' and name = 'test')
begin
drop table test
end
/* Create TEST table */
create table test
id_test int identity not null,
string char (7),
constraint pk_test primary key (id_test)
set identity_insert test on
insert into test (id_test, string)
values (1,'string1')
insert into test (id_test, string)
values (4,'string2')
insert into test (id_test, string)
values (12,'string3')
insert into test (id_test, string)
values (17,'string4')
insert into test (id_test, string)
values (29,'string5')
insert into test (id_test, string)
values (31,'string6')
insert into test (id_test, string)
values (42,'string7')
insert into test (id_test, string)
values (45,'string8')
insert into test (id_test, string)
values (61,'string9')
set identity_insert test off
go
/* Solution #1, Create VIEW */
if exists (select * from sysobjects where type = 'V' and name = 'ranked_table')
begin
drop view ranked_table
end
go
create view ranked_table (rank, id_test, sting)
as
select (
select count(*)
from test as test_2
where test_2.id_test <= test_1.id_test
) as rank,
test_1.id_test,
test_1.string
from test as test_1
go
select *
from ranked_table
order by rank
go
/* Solution #2 STANDART ANSI-SQL (SELF-JOIN + GROUP BY)*/
select count (test_2.id_test) as rank, test_1.id_test, test_1.string
from test as test_1 inner join test as test_2 on
test_1.id_test >= test_2.id_test
group by test_1.id_test, test_1.string
order by rank
go
/* Solution #3 STANDART ANSI-SQL (SCALAR SUBQUERY IN SELECT-clause)*/
select test_3.rank, test_3.id_test, test_3.string
from (select test_1.id_test,
test_1.string,
(select count(*)
from test as test_2
where test_2.id_test <= test_1.id_test
) as rank
from test as test_1) as test_3
order by rank
go
/* Solution #4, TEMPORARY TABLE WITH IDENTITY-FIELD */
create table #rank_table
rank int identity not null,
id_test int null,
string char (7),
constraint pk_test primary key (rank)
go
insert into #rank_table (id_test, string)
select id_test, string
from test
order by id_test
select * from #rank_table
go
/* Solution #5, TABLE-TYPE VARIABLE WITH IDENTITY */
declare @rank_table table
rank int identity not null,
id_test int null,
string char (7)
insert into @rank_table (id_test, string)
select id_test, string
from test
order by id_test
select * from @rank_table
go
/* Solution #6, CURSOR */
declare @rank int,
@id_test int,
@string char (7)
declare rank_cursor cursor
for select id_test, string
from test
order by id_test
open rank_cursor
fetch next from rank_cursor into @id_test, @string
set @rank = 1
while (@@fetch_status <> -1)
begin
select @rank, @id_test, @string
set @rank = @rank + 1
fetch next from rank_cursor into @id_test, @string
end
close rank_cursor
deallocate rank_cursor
Similar Messages
-
Needs help to retrive the last row in a select query without using rownum
Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
1 select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
2 from emp
3 connect by mgr = prior empno
4* start with mgr is null
SQL> /
EMPNO ENAME MGR
7839 KING
7566 JONES 7839
7788 SCOTT 7566
7876 ADAMS 7788
7902 FORD 7566
7369 SMITH 7902
7698 BLAKE 7839
7499 ALLEN 7698
7521 WARD 7698
7654 MARTIN 7698
7844 TURNER 7698
7900 JAMES 7698
7782 CLARK 7839
7934 MILLER 7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data) -
Select statement without using Rownum or Rowid
Hi,
I have a requirement where I have delete the first 100 records from table without using the rownum or rowid.
Thanks to all for your time
NarainHi
delete from yourtab x where (select count(*) from yourtab where yourpk <= x.yourpk) < 101;HTH
Laurent Schneider
OCM DBA -
I need software to print without using the cable
I just got a replacement Officejet 6100. I want to print from anywhere in my home using the network. Please help me download the software to accomplish this.
Hi @Forrey,
Welcome to the HP Forums!
I understand that you want to print from anywhere in my home using the network with your HP Officejet 6100. I am happy to help!
To download the software, please see this website, HP Officejet Full Feature Software and Driver.
This guide will also help with setting up the connection, Setting Up the Printer for a Wired or Wireless network for the HP Officejet 6100 ePrinter Series.
Hope this resolves your issue, and thank you for posting!
RnRMusicMan
I work on behalf of HP
Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
Click the “Kudos Thumbs Up" to say “Thanks” for helping! -
Returning a subset of rows through a ResultSet WITHOUT rownum?
I am trying to figure out a way to get a subset of rows from a ResultSet (or ResultSet equivalent) without using rownum and without sending all the rows before the requested row over the wire.
My problem is this: I am not in control of the SQL that is sent to the database. It is autogenerated by a third party tool (TOPLink). Therefore using the rownum solution isn't practical. My steps of operation are:
1. Get SQL from TOPLink
2. Pass SQL through a Statement
3. Get resulting ResultSet
At this point, I want to say, "Mr. ResultSet, I only want rows 200-250." And I then want Mr. ResultSet to fetch only rows 200 to 250, and no others. I don't want to see rows 1 to 199 coming over the wire.
Anyone have any ideas? Is this possible at all? Also, if there's a way to do this through the TOPLink mechanisms (ScrollableCursors and ReportQuery objects and whatnot), please do let me know. I have tried using the TOPLink facilities, and sure enough rows 1 to 199 flow across the network.
Thanks,
Michael Allen
[email protected]Hi Michael,
Is there some sort of selection criteria in which you could use return the required 200-250 rows of data? If so, I would embed that into the TopLink query.
Another option is using the ORDER BY operator. Without order, constructing a query of elements 200-250 twice would not guarentee that they would be the same elements.
You can also construct your own SQL statement and execute it directly on a TopLink session.
Darren Melanson
Strategic Implementation Consultant
Oracle Canada.
I am trying to figure out a way to get a subset of rows from a ResultSet (or ResultSet equivalent) without using rownum and without sending all the rows before the requested row over the wire.
My problem is this: I am not in control of the SQL that is sent to the database. It is autogenerated by a third party tool (TOPLink). Therefore using the rownum solution isn't practical. My steps of operation are:
1. Get SQL from TOPLink
2. Pass SQL through a Statement
3. Get resulting ResultSet
At this point, I want to say, "Mr. ResultSet, I only want rows 200-250." And I then want Mr. ResultSet to fetch only rows 200 to 250, and no others. I don't want to see rows 1 to 199 coming over the wire.
Anyone have any ideas? Is this possible at all? Also, if there's a way to do this through the TOPLink mechanisms (ScrollableCursors and ReportQuery objects and whatnot), please do let me know. I have tried using the TOPLink facilities, and sure enough rows 1 to 199 flow across the network.
Thanks,
Michael Allen
[email protected] -
How Oracle returns queries & using rownum
Hi, I need to limit query results using rownum, but my question is regarding how Oracle retrieves its data.
Assume I have a table containing 500 records and my query without using rownum will retrieve 62 of those records. The actual query will use rownum and limit results to 20.
I have a JSP that will display those first 20. It has a simple feature for pagination, a "next" button that will retrieve the next results. So far simple enough, going forwards is easy. But how about going back.
I am trying to work out the SQL for using a "previous" button, so for example, say records 40-60 are being displayed, and say the first record on that page has a primary key value of 200, what should the SQL be to retrieve the previous 20 records using rownum ? I ask because if I do:
select * from tablename where pri_key < 200 and rownum <=20;
I know it will retrieve 20 records, but would the query fetch its results from the beginning of the table or would it count backwards from 200 ? If it is the first way, how could I word the SQL query to go backwards from 200 ? I am pretty sure it will start from the beginning and thats what I don't want. I know there are pagination tags for jsp out there but I want to do this myself.
Thanks
Kevin
Message was edited by:
MrVenFirst, you need to understand that rownum is only assigned when a record is selected for output, it has nothing to do with any sort of internal order of the table (like insertion order). The same row can have a different rownum even for two invocations of the same query on the same data if the optimizer chooses a different access path. The only way to get a repeatable set of rownum is to sort the records by some field.
Second, any SQL statement you issue will be executed essentially in isolation. Oracle has no idea what query you executed previously. So, your query:
SELECT *
FROM tablename
WHERE pri_key < 200 and
rownum <=20;will select a random set of 20 rows wih a primary key less than 200. It is likely to be the first (i.e. lowest values of the pk) rows, but that is not guaranteed.
The cannonical way to paginate rows is something like:
SELECT col1, col2, ...
FROM (SELECT col1, col2, ..., rownum rn
FROM (SELECT col1, col2, ...
FROM table
WHERE <conditions>
ORDER BY pk) ti
WHERE rownum <= :maxrownum) to
WHERE rn >= :minrownumThe innermost query (with the <condition>) selects the appropriate rows and sorts them, in this case by the pk.
The middle query (rownum <- :maxrownum) discards the rows that would be after the last record you want to display. By using the maxrownum here, it gives Oracle information that allows it to do a fast sort on the inner query if possible.
In a fast sort, Oracle will get the first maxrownum rows from the query and sort them, then when it gets the next row, it checks if it is less than the highest value already found. If it is, it slots it into the correct place and discards the highest value, otherwise it discards that row.
The outermost query simply discards the records where the row number after sorting is less than the minimum value.
Another alternative may be:
SELECT col1, col2, ...
FROM (SELECT col1, col2, ...,
ROW_NUMBER() OVER(ORDER BY pk) rn
FROM table
WHERE <conditions>)
WHERE rn BETWEEN :minrownum AND :maxrownumdepending on your database version, and your actual query.
Note tha pagination like this is expensive.
HTH
John
The outermost -
Java.sql.SQLException: Invalid column index Query: while using ROWNUM
hi ,
i am getting the invalid column index query error while executing following query .i m able to run it properly without using rownum but when i append rownum i m getting error.i m using apache queryrunner for execution of query.
java.sql.SQLException: Invalid column index Query: select * from (
SELECT
TO_CHAR(A.REQ_FOR_RATING_ID) RFQID,
TO_CHAR(F.COV_PLAN_ID) COVPLANID,
B.FIRM_NAME FIRMNAME,
B.PRIMARY_ZIP_CD ZIP,
A.PRODUCR_CD PRODUCERCD,
A.PRODUCR_NAME PRODUCER,
H.COV_NAME COVDESP,
C.SALE_OFFC_CD SALEOFFCCD,
C.USR_OFFC_NAME USROFFC,
C.USR_NAME USR,
C.USR_REP_CD USRREPCD,
to_char((SELECT TO_CHAR(COUNT(EMP_NBR)) COUNT FROM ROSTR_DATA WHERE ROSTR_ID = F.ROSTR_ID)) AS count,
TO_CHAR(B.SIC_CD) SICCD,
F.INDSTRY_TYPE_IND INDTYPEIND,
TO_CHAR(F.MANL_SIC_FCTR_NBR) MANSICFACTOR,
TO_CHAR(F.UW_OVERD_SIC_FCTR_NBR) UWOVERDSICFACTOR,
TO_CHAR(G.AREA_FCTR_NBR) STRAREAFACTOR,
G.COV_ID COVID,
F.PLAN_APPRVL_STATUS_CD PLANAPPRVLCD,
F.PLAN_PROGRS_STATUS_CD PLANPROGRESSSTATUSCD ,
F.PLAN_SALE_ASSMNT_CD PLANSALEASSMTCD,
F.CREATD_DT CREATEDDT,
NVL(to_char(F.PLAN_RELSED_DT),' ') PLANRELSEDDT,
TO_CHAR(F.PLAN_RELSED_BY_ID) PLANRELSEDBYID,
TO_CHAR(F.PROPOSD_EFF_DT) PROPOSDEFFECTIVEDT,
TO_CHAR(A.GRACE_PERIOD_NBR) GRACEPERIOD,
A.RNWL_15_MONTH_IND FIFTEENMONTHRNWLIND ,
I.CO_DESC_TXT COMPANYNAME ,
NVL(to_char(F.PLAN_APPRVL_DT),' ') approvedDt,
(Select U.USR_NAME from USR_DETL U WHERE U.USR_ID = F.PLAN_RELSED_BY_ID) as planRelsedByName,
(Select U.USR_NAME from USR_DETL U WHERE U.USR_ID = F.PLAN_APPRVR_ID) as approvedByName,
'' createdByName,
ROWNUM rnum
FROM
REQ_FOR_RATING A,
FIRM B,
USR_DETL C,
SALE_OFFICE D,
QUOTE_SCENRIO E,
QUOTE_COV G,
COV_PLAN F,
COV_LKUP H,
CO_LKUP I
WHERE
A.FIRM_ID = B.FIRM_ID AND
A.SALE_REP_ID = C.USR_ID AND
C.SALE_OFFC_CD = D.SALE_OFFC_CD AND
A.REQ_FOR_RATING_ID=E.REQ_FOR_RATING_ID AND
E.QUOTE_SCENRIO_ID=G.QUOTE_SCENRIO_ID AND
G.QUOTE_COV_ID=F.QUOTE_COV_ID AND
G.COV_ID=H.COV_ID AND
I.CO_CD = F.CO_CD AND
TO_CHAR(F.CREATD_DT,'YYYYMMDD') > TO_CHAR(TO_DATE('07/16/2007', 'MM/DD/YYYY HH24:MI:SS'),'YYYYMMDD') AND
TO_CHAR(F.CREATD_DT,'YYYYMMDD') < TO_CHAR(TO_DATE('10/16/2007', 'MM/DD/YYYY HH24:MI:SS'),'YYYYMMDD')
and rownum <=?) where rnum >=? Parameters: [07/15/2007 00:00:00, 10/15/2007 23:59:59, 1117, 1]That's a SQL fault, not a JDBC/Java fault.
-
Download and execute jars without using javaws
Hi
I need to download and execute jars from remote computer. I hava jnlp file, but I strongly need to execute jars without using java web start.
What is the best way to do this task?
Thanks in advance :)
Edited by: joekidd on Aug 3, 2009 5:55 AMjoekidd wrote:
The easiest the best:)The easiest way is to hire the programmers who made the Jar, to consult on your behalf to install the program, or advise on its installation. BTW - you said earlier.. "strongly need to execute jars without using java web start." Why? What advantage does that provide?
So I download needed jars, add them to classpath and run my application (I get all information from jnlp file and pass them to vm and my application).
But following exception occurs "Exception in thread "main" java.lang.NoClassDefFoundError: javax/jnlp/ServiceManager". What should I do?Get in contact with those programmers, because this app. is dependant(1) on functionality that is only available to web start apps.
(1) Unless they put that call in there, just to ensure no one can run the app. outside web start. ;-) -
Need to take rownum highest value without using grouping functions
Hi
I want to display highest value in the rownum column and customer details without using grouping functions like max or count
this below query gives me all rownum values and customer details
SELECT ROWNUM ROWNUM_1, CUSTOMER_NO, CUSTOMER_NAME, CUSTOMER_DOJ, CUSTOMER_MOBILENO FROM CUSTOMER;
can any one help me.The above query won't work as it's missing "from" cluase in the inner select statement.
And even if corrected it willl print rownum values thrice: value "1",max_rownum, max_rownum followed by customer details.
Below is the simple query to retrieve max row_num along with the corresponding customer details.
select * from (SELECT ROWNUM ROWNUM_1, CUSTOMER_NO, CUSTOMER_NAME, CUSTOMER_DOJ, CUSTOMER_MOBILENO FROM CUSTOMER order by rownum_1 desc) where rownum<=1 ; -
Help needed Displaying ALV Secondary list without using oops concept
Hi Experts
Help needed Displaying ALV Secondary list without using oops concept.
its urgent
regds
rajasekharhi chk this code
******************TABLES DECLARATION*****************
TABLES : VBAP,MARA.
*****************TYPE POOLS**************************
TYPE-POOLS : SLIS.
****************INTERNAL TABLES**********************
DATA : BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
END OF IT_VBAP.
****************TEMPORARY VARIABLES******************
DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
*****************FIELD CATALOG***********************
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
****************LAYOUT*******************************
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
***************VARIANT*******************************
DATA : G_VARIANT LIKE DISVARIANT.
****************SAVE*********************************
DATA : G_SAVE(1) TYPE C.
*****************EVENTS******************************
DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
G_EVENTS TYPE SLIS_T_EVENT.
******************PF STATUS**************************
DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
******************USER COMMAND************************
DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
R_UCOMM LIKE SY-UCOMM.
****************SELECTION SCREEN************************
SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
***************AT SELECTION SCREEN*********************
AT SELECTION-SCREEN.
PERFORM VALIDATE.
**************START-OF-SELECTION**************************
START-OF-SELECTION.
PERFORM GET_DETAILS.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM VARIANT.
PERFORM SAVE.
PERFORM EVENTS.
PERFORM ALV_DISPLAY.
*********************FORMS*******************************************
*& Form validate
text
--> p1 text
<-- p2 text
FORM VALIDATE .
SELECT SINGLE VBELN
FROM VBAP
INTO V_VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'enter valid vbeln'.
ENDIF.
ENDFORM. " validate
*& Form get_details
text
--> p1 text
<-- p2 text
FORM GET_DETAILS .
SELECT VBELN
POSNR
MATNR
FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'no details found'.
ENDIF.
ENDFORM. " get_details
*& Form fieldcat
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-OUTPUTLEN = 10.
WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-OUTPUTLEN = 6.
WA_FIELDCAT-SELTEXT_L = 'ITEM'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-OUTPUTLEN = 18.
WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " fieldcat
*& Form LAYOUT
text
--> p1 text
<-- p2 text
FORM LAYOUT .
WA_LAYOUT-ZEBRA = 'X'.
ENDFORM. " LAYOUT
*& Form VARIANT
text
--> p1 text
<-- p2 text
FORM VARIANT .
CLEAR G_VARIANT.
G_VARIANT-REPORT = SY-REPID.
ENDFORM. " VARIANT
*& Form SAVE
text
--> p1 text
<-- p2 text
FORM SAVE .
CLEAR G_SAVE.
G_SAVE = 'A'.
ENDFORM. " SAVE
*& Form EVENTS
text
--> p1 text
<-- p2 text
FORM EVENTS .
CLEAR XS_EVENTS.
XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENTS-FORM = 'TOP_OF_PAGE'.
APPEND XS_EVENTS TO G_EVENTS.
ENDFORM. " EVENTS
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
WRITE :/ ' INTELLI GROUP'.
ENDFORM. "TOP_OF_PAGE
*& Form ALV_DISPLAY
text
--> p1 text
<-- p2 text
FORM ALV_DISPLAY .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = PF_STATUS
I_CALLBACK_USER_COMMAND = USER_COMMAND
I_STRUCTURE_NAME =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = G_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ALV_DISPLAY
*& Form SET_PF_STATUS
text
FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'Z50651_PFSTATUS' EXCLUDING EXTAB.
ENDFORM. "SET_PF_STATUS
*& Form SET_USER_COMMAND
text
FORM SET_USER_COMMAND USING R_UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DC'.
READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
SELECT SINGLE MTART
FROM MARA
INTO V_MTART
WHERE MATNR = IT_VBAP-MATNR.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
ELSE.
WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
WRITE :/ 'MATERIAL TYPE :' , V_MTART.
ENDIF.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CLOSE'.
CALL TRANSACTION 'SE38'.
ENDCASE.
REPORT Z_ALV_INTERACTIVE MESSAGE-ID ZMSG_50651
LINE-SIZE 100
LINE-COUNT 60
NO STANDARD PAGE HEADING.
******************TABLES DECLARATION*****************
TABLES : VBAP,MARA.
*****************TYPE POOLS**************************
TYPE-POOLS : SLIS.
****************INTERNAL TABLES**********************
DATA : BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
END OF IT_VBAP.
****************TEMPORARY VARIABLES******************
DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
*****************FIELD CATALOG***********************
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
****************LAYOUT*******************************
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
***************VARIANT*******************************
DATA : G_VARIANT LIKE DISVARIANT.
****************SAVE*********************************
DATA : G_SAVE(1) TYPE C.
*****************EVENTS******************************
DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
G_EVENTS TYPE SLIS_T_EVENT.
******************PF STATUS**************************
DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
******************USER COMMAND************************
DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
R_UCOMM LIKE SY-UCOMM.
****************SELECTION SCREEN************************
SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
***************AT SELECTION SCREEN*********************
AT SELECTION-SCREEN.
PERFORM VALIDATE.
**************START-OF-SELECTION**************************
START-OF-SELECTION.
PERFORM GET_DETAILS.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM VARIANT.
PERFORM SAVE.
PERFORM EVENTS.
PERFORM ALV_DISPLAY.
*********************FORMS*******************************************
*& Form validate
text
--> p1 text
<-- p2 text
FORM VALIDATE .
SELECT SINGLE VBELN
FROM VBAP
INTO V_VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'enter valid vbeln'.
ENDIF.
ENDFORM. " validate
*& Form get_details
text
--> p1 text
<-- p2 text
FORM GET_DETAILS .
SELECT VBELN
POSNR
MATNR
FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'no details found'.
ENDIF.
ENDFORM. " get_details
*& Form fieldcat
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-OUTPUTLEN = 10.
WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-OUTPUTLEN = 6.
WA_FIELDCAT-SELTEXT_L = 'ITEM'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-OUTPUTLEN = 18.
WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " fieldcat
*& Form LAYOUT
text
--> p1 text
<-- p2 text
FORM LAYOUT .
WA_LAYOUT-ZEBRA = 'X'.
ENDFORM. " LAYOUT
*& Form VARIANT
text
--> p1 text
<-- p2 text
FORM VARIANT .
CLEAR G_VARIANT.
G_VARIANT-REPORT = SY-REPID.
ENDFORM. " VARIANT
*& Form SAVE
text
--> p1 text
<-- p2 text
FORM SAVE .
CLEAR G_SAVE.
G_SAVE = 'A'.
ENDFORM. " SAVE
*& Form EVENTS
text
--> p1 text
<-- p2 text
FORM EVENTS .
CLEAR XS_EVENTS.
XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENTS-FORM = 'TOP_OF_PAGE'.
APPEND XS_EVENTS TO G_EVENTS.
ENDFORM. " EVENTS
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
WRITE :/ ' INTELLI GROUP'.
ENDFORM. "TOP_OF_PAGE
*& Form ALV_DISPLAY
text
--> p1 text
<-- p2 text
FORM ALV_DISPLAY .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = PF_STATUS
I_CALLBACK_USER_COMMAND = USER_COMMAND
I_STRUCTURE_NAME =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = G_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ALV_DISPLAY
*& Form SET_PF_STATUS
text
FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING EXTAB.
ENDFORM. "SET_PF_STATUS
*& Form SET_USER_COMMAND
text
FORM SET_USER_COMMAND USING R_UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DC'.
READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
SELECT SINGLE MTART
FROM MARA
INTO V_MTART
WHERE MATNR = IT_VBAP-MATNR.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
ELSE.
WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
WRITE :/ 'MATERIAL TYPE :' , V_MTART.
SUBMIT SLIS_DUMMY WITH P_MATNR EQ IT_VBAP-MATNR
WITH P_MTART EQ V_MTART.
ENDIF.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CLOSE'.
CALL TRANSACTION 'SE38'.
ENDCASE.
plz reward if useful -
Asynchronous, but need Ack without using BPM and IDocs.
Hi Experts,
I would like to do a scenario i.e., "Asynchronous communication, but need Acknowledgement without using BPM and also without using IDocs whether it is sender side or receiver side". Please help me.
Thanks in advance
Srihari.Without using BPM will be little longer process. But the alternative way is to add one more receiver in the receiver determination and send some file to that location with the actual mapping getting executed for the actual receiver. and in the second interface you can get the file created at second receiver back to the source location. But this will be little long as compared to synchronous scenarios.
Flow:
Source
Receiver 1--> Actual mapping as per requirement
Receiver 2(For Ack)--> Create a mapping with blank file sent to Receiver
Receiver 2-->File Adapter--> Source through 2nd mapping/interface and keep the File adapter pooling interval around 5 sec or less so that you can get the file back to source location.
Regards
Anand -
Increment a number without using sequence in Mapping
Hi,
Is there anyway to increment a number without using oracle sequence generator in OWB? I am using version 10.2.0.4.
Please let me know.
Thanks,
SivaPerhaps it would help if you were more specific on what you wanted to do. I mean, there are many ways to generate sequences of numbers in Oracle. For example:
select level as seq_num from dual connect by level < 100;
to get the integers from 1 to 100. If you are dealing with order of rows within subsets of a query, take a look into analytic functions like rank().
But "Ways to increment a number"? Sure:
create function increment( x in number) returns number is begin if x is not null then return x+1; else return null; end if; end;
Now call your increment function!
Not sure what you are trying to accomplish, and can't help much without knowing.
Sorry. -
Hello! I'm out of the country and all my iWeb information is on my computer at home. Now I need to make changes on the webpage... how can i do that without using the computer i made the page on? Thank you!!
iWeb uses the domain.sites2 files to store its assets.
You'll find it here :
~/Library/Application Support/iWeb/
where ~ is your Home directory.
If you take a computer with you, you have to store that file in the same location.
It's not different from taking documents with you if you want to edit them.
A solution is to remotely control your computer at home.
TeamViewer, LogMeIn, Apple Remote Desktop or any VNC application you can use, like "Chicken of the VNC". -
what happens if you never realised you needed your serial number, then your ipod was stolen and you need it...where can if find it without using my ipod
please help me!!
thanksSee:
iPod: How to find the serial number
And this previous discussion:
iPod touch Serial number help?: Apple Support Communities -
Hi,am not able to open PDF Files in Mozilla Firefox without using plugins...I need Solution
Hello,
Please see the support article below for full information on viewing PDF in Firefox:
[[View PDF files in Firefox without downloading them]]
If you want to use Firefox's built in PDF viewer (i.e. not a plugin) then you will need to ensure that any PDF plugins are uninstalled from Firefox and that 'Preview in Firefox' is selected as the Action for PDF files (see screenshot below).
I hope that helps. Let me know if not.
Maybe you are looking for
-
I have read the other threads and tried what they suggested and am still unable to solve this. I am using OSX 10.7.5 I have tried uninstalling and reinstalling firefox. This did not work. Any suggestions?
-
Have been advised by my email provider (recently blocked account requiring password reset) that they will only reset the password after a proven anti virus and malware scan has been done on ipad and iphone. Is this necessary and if so what do i use
-
Dear All I have raised third party PO with reference to sale order PR number.With recpective PO i done invoice verification and its payment also done to vendor. But during billing if SD enter invoice document number in respective column they are faci
-
Illustrator 17.0.2 won't upgrade to 17.1.0
I'm trying to upgrade illustrator 17.0.2 to 17.1.0 on a mac with 10.8.5 Everytime I try from adobe application manager, I am told that another instance of adobe application manager is running and to close it. I have checked the activity monitor and I
-
I think I should just reinstall everything nothing works how do I do iy?