Append row in end of table?
Hi,
I have an ALV table with default "Append row" "Delete Row" buttons. When i give append row initially, then a new row is added to the end of the table. But when i give field sorting (Ascending order), and then go for Append row, a new row which is added to the top of the table. User want this to be added always in the end of the table. Can anyone please help me on this? ...
Thanks,
Sathishkumar GS
Code for your reference : (Taken from the thread mentioned earlier)
DATA display_function TYPE REF TO cl_salv_wd_function.
LR_FUNCTION_SETTINGS->IF_SALV_WD_FUNCTION_SETTINGS~CREATE_FUNCTION(
EXPORTING
ID = 'BTN_DISPLAY_DET'
RECEIVING
VALUE = display_function ).
* set button and tool tip text
LV_BUTTON_TEXT = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '007' ).
CREATE OBJECT lo_own_button.
lo_own_button->set_text( LV_BUTTON_TEXT ).
LV_BUTTON_Tooltip = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '008' ).
CALL METHOD LO_OWN_BUTTON->SET_TOOLTIP
EXPORTING
VALUE = LV_BUTTON_Tooltip.
display_function->set_editor( lo_own_button ).
Similar Messages
-
How to append row in internal table for perticular condition
Hi,
I have 4 records in my internal table and i want to append row
after second row when condition will match.
please guide me.
thanks in advancs
regards
SNDhi,
using key word INDEX u can insert a record in aspecified position as
if internal table is with header line.
INSERT <internaltable> index SY_INDEX [or index no if u know where to insert]
with out header line.
INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u know where to insert]
if condition is true.
insert itab index 2.
endif.
if helpful reward some points.
with regards,
Suresh.A -
CONVERTING ROWS OF AN INTERNAL TABLE TO COLUMNS OF ANOTHER INTERNAL TABLE
Hi,
I hv an internal table itab as below with 3 columns.
name age place
sandeep 24 delhi
ajay 22 bangalore
abhishek 25 mumbai
internal table itab can have any number of rows.
from this internal table i want to make another internale table itab_new as
sandeep ajay abhishek
24 22 25
delhi bangalore mumbai
thanksHi,
Check this example:
data:p_temp(30) TYPE c value 'ztmp_projectreport'.
*data declaration
DATA: it_tab TYPE filetable,
gd_subrc TYPE i,
answer TYPE c.
TYPES: BEGIN OF t_abapcode,
row(72) TYPE c,
END OF t_abapcode.
DATA: it_abapcode TYPE STANDARD TABLE OF t_abapcode INITIAL SIZE 0.
data:it_prps like prps occurs 0 with header line.
data:colum(20) type c.
data:ncol type i.
data:ccol type c.
select * into corresponding fields of table
it_prps from prps where
append 'report ztmp_projectreport' to it_abapcode.
append 'data:begin of it_prps2,' to it_abapcode.
ncol = 1.
loop at it_prps.
ccol = ncol.
concatenate 'colum' ccol '(20)' into colum.
concatenate colum 'type c,' into it_abapcode.
add 1 to ncol.
endloop.
append 'data:end of it_prps2.' to it_abapcode.
'All your code here to fill the internal table and alv grid
'End of all your code
INSERT REPORT p_temp FROM it_abapcode.
SUBMIT (p_temp) AND RETURN.
DELETE REPORT p_temp.
Please provide points -
I have code that has the line "rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row". Every once in a while the macro crashes on this line. It doesn't happen regularly or with a pattern. The entire code is below. I have several
modules that use this line of code. Any ideas?
Function ImportScores()
Dim RecSet As DAO.Recordset
Dim objXLAppln As Excel.Application
Dim objWBook As Excel.Workbook
Dim rowNum As Variant
Dim i As Integer
Dim j As Integer
Dim StrPathFile As String, strFile As String, strPath As String
Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
'show dialogue box
strBrowseMsg = "Select the EXCEL file:"
'set directory to load files from
strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
'run strFilter function
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:=strBrowseMsg, _
Flags:=ahtOFN_HIDEREADONLY)
If StrPathFile = "" Then
MsgBox "No file was selected.", vbOK, "No Selection"
Exit Function
End If
'Set Excel application object. Critical for macro to run properly. Do not change.
Set objXLAppln = New Excel.Application
'Open workbook and worksheet to load data.
With objXLAppln
Set objWBook = .Workbooks.Open(StrPathFile)
objXLAppln.Visible = True
End With
Set RecSet = CurrentDb.OpenRecordset("Performance_Scores")
'Copy data from Excel cells to Access fields
objXLAppln.Sheets("Performance_Attributes").Select
rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row
objXLAppln.Range("A10").Select
'Add records to table from Excel
With RecSet
For i = 0 To rowNum - 9
RecSet.AddNew
RecSet.Fields("CIP_ID").value = objXLAppln.ActiveCell.Offset(i, 0).value
RecSet.Fields("5YearScore").value = objXLAppln.ActiveCell.Offset(i, 53).value
RecSet.Fields("10YearScore").value = objXLAppln.ActiveCell.Offset(i, 54).value
RecSet.Fields("15YearScore").value = objXLAppln.ActiveCell.Offset(i, 55).value
RecSet.Fields("20YearScore").value = objXLAppln.ActiveCell.Offset(i, 56).value
RecSet.Update
Next i
End With
'Close everything
RecSet.Close
objWBook.Close SaveChanges:=False
objXLAppln.Quit
Set RecSet = Nothing
Set objWBook = Nothing
Set objXLAppln = Nothing
End FunctionI rewrote as below.
But rather than doing it this way, I would create a linked table to this workbook and import the data using an Append query.
Function ImportScores()
Const FOOTER_ROWS_TO_SKIP As Integer = 10
Const COL_CIP_ID As Integer = 1
Const COL_5YEARSCORE As Integer = 54
Dim RecSet As DAO.Recordset
Dim objXLAppln As Excel.Application
Dim objWBook As Excel.Workbook
Dim objXLSheet As Excel.Worksheet
Dim rowNum As Variant
Dim row As Integer
Dim j As Integer
Dim StrPathFile As String, strFile As String, strPath As String
Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
'show dialogue box
strBrowseMsg = "Select the EXCEL file:"
'set directory to load files from
strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
'run strFilter function
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
Filter:=strFilter, OpenFile:=True,
DialogTitle:=strBrowseMsg,
Flags:=ahtOFN_HIDEREADONLY)
'StrPathFile = "C:\Users\Tom\Documents\test.xlsx" 'testonly
If StrPathFile = "" Then
MsgBox "No file was selected.", vbOK, "No Selection"
Exit Function
End If
'Set Excel application object. Critical for macro to run properly. Do not change.
Set objXLAppln = New Excel.Application
'Open workbook and worksheet to load data.
With objXLAppln
Set objWBook = .Workbooks.Open(StrPathFile)
objXLAppln.Visible = True
Set objXLSheet = objXLAppln.Sheets("Performance_Scores")
End With
rowNum = objXLSheet.UsedRange.Rows.Count
'Add records to table from Excel
Set RecSet = CurrentDb.OpenRecordset("Performance_Scores", dbOpenDynaset)
With RecSet
For row = 1 To rowNum - FOOTER_ROWS_TO_SKIP
RecSet.AddNew
RecSet.Fields("CIP_ID").Value = objXLSheet.Cells(row, COL_CIP_ID).Value
RecSet.Fields("5YearScore").Value = objXLSheet.Cells(row, COL_5YEARSCORE).Value
'etc.
RecSet.Update
Next row
End With
'Close everything
RecSet.Close
objWBook.Close SaveChanges:=False
objXLAppln.Quit
Set RecSet = Nothing
Set objWBook = Nothing
Set objXLAppln = Nothing
End Function
-Tom. Microsoft Access MVP -
Inserting 10 million rows in to a table hangs
HI through toad iam using a simple for loop to insert 10 million rows into a table by saying
for i in 1 ......10000000
insert.................
It hangs ........ for lot of time
is there a better way to insert the rows in to the table....?
i have to test for performance.... and i have to insert 50 million rows in its child table..
practically when the code moves to production it will have these many rows...(may be more also) thats why i have to test for these many rows
plz suggest a better way for this
Regards
rajMust be a 'hardware thing'.
My ancient desktop (pentium IV, 1.8 Ghz, 512 MB), running XE, needs:
MHO%xe> desc t
Naam Null? Type
N NUMBER
A VARCHAR2(10)
B VARCHAR2(10)
MHO%xe> insert /*+ APPEND */ into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:04:09.71
MHO%xe> drop table t;
Tabel is verwijderd.
Verstreken: 00:00:31.50
MHO%xe> create table t (n number, a varchar2(10), b varchar2(10));
Tabel is aangemaakt.
Verstreken: 00:00:01.04
MHO%xe> insert into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:02:44.12
MHO%xe> drop table t;
Tabel is verwijderd.
Verstreken: 00:00:09.46
MHO%xe> create table t (n number, a varchar2(10), b varchar2(10));
Tabel is aangemaakt.
Verstreken: 00:00:00.15
MHO%xe> insert /*+ APPEND */ into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:01:03.89
MHO%xe> drop table t;
Tabel is verwijderd.
Verstreken: 00:00:27.17
MHO%xe> create table t (n number, a varchar2(10), b varchar2(10));
Tabel is aangemaakt.
Verstreken: 00:00:01.15
MHO%xe> insert into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:01:56.10Yea, 'cached' it a bit (ofcourse ;) )
But the append hint seems to knibble about 50 sec off anyway (using NO indexes at all) on my 'configuration'. -
How to process a block for each row in an internal table....
Hi experts....
In po approval workflow the scenario is like this.... for each po there may be more than one approver. approvers list i am maintaining in the ztable. list of approvers(no of approvers) is decided by the po value. I have collected these approvers into internal table. now i have to process a block ( approving or rejecting the po... )in the workflow for each row in the internal table.
how can i do this. based on the decision of the 1st approver approves the po then it should go to next approver in the internal table...otherwise end the workflow.....
Please help me......i have created an internal table in the workflow container in which i am getting the list of approvers....
how can i loop the internal table in the workflow...?
how can i know the index of the loop in the workflow.....(will sy-index work here....? so that i can use loop until step in the main workflow to call the subworkflow..so that if sy-index is greater than no of entires in the itab then i can come out of the loop) -
XMLIndex: finding indexed XPaths and the number of rows in the path table
Hi,
I am storing non-schema-based binary XMLs in an XMLType column in 11g (11.1.0.6.0) and would like to index the XMLs either partially or fully using XMLIndex. I'm expecting to have a large number (tens of millions) of XML documents and have some concerns about the size of the XMLIndex path table.
In short, I am worried that the path table might grow unmanageable large. In order to avoid this and to plan for table partitioning, I would like to create a report of all indexed XPaths in an XMLIndex and to find out how many times each path is actualized in the path table. I would do this for a representative XML sample.
I have been creating XMLIndexes with different exclude/include paths, gathering stats with DBMS_STATS (estimate_percent = 100) and selecting the number of rows in the path table through USER_TABLES.
If anyone knows a more straightforward way of doing this all advice is very much appreciated.
Best Regards,
Rasko LeinonenThanks Marco,
I managed to get out all indexed paths using the following SQL. It took a while to understand how the join the XDB.X$PT39CW6BJR8W4VVE0G0LLGA0OCR5 and XDB.X$QN39CW6BJR8W4VVE0G0LLGA0OCR5 tables together but got there in the end. This helps to clarify which XPaths are being currently indexed by the XMLIndex.
begin
for v_row in (select PATH from XDB.X$PT39CW6BJR8W4VVE0G0LLGA0OCR5)
loop
declare
v_i BINARY_INTEGER := 1;
v_id raw(8);
v_len BINARY_INTEGER := 2;
v_skip BINARY_INTEGER := 1;
begin
while v_i < utl_raw.length(v_row.path) and
v_i + v_len <= utl_raw.length(v_row.path)
loop
v_i := v_i + v_skip;
v_id := utl_raw.substr(v_row.path, v_i, v_len);
--dbms_output.put_line(v_id);
for v_row2 in (select LOCALNAME, flags from XDB.X$QN39CW6BJR8W4VVE0G0LLGA0OCR5
where ID = v_id )
loop
if rawtohex(v_row2.flags) = '01'
then
dbms_output.put('@');
end if;
dbms_output.put(v_row2.localname);
if v_i + v_len < utl_raw.length(v_row.path)
then
dbms_output.put('/');
end if;
end loop;
v_i := v_i + v_len;
end loop;
dbms_output.put_line('');
end;
end loop;
end;
Example output:
RUN
RUN/@accession
RUN/@alias
RUN/@instrument_model
RUN/@run_date
RUN/@run_center
RUN/@total_data_blocks
RUN/EXPERIMENT_REF
RUN/EXPERIMENT_REF/@accession
RUN/EXPERIMENT_REF/@refname
RUN/DATA_BLOCK
RUN/DATA_BLOCK/@name
RUN/DATA_BLOCK/@total_spots
RUN/DATA_BLOCK/@total_reads
RUN/DATA_BLOCK/@number_channels
RUN/DATA_BLOCK/@format_code
RUN/DATA_BLOCK/@sector
RUN/DATA_BLOCK/FILES
RUN/DATA_BLOCK/FILES/FILE
RUN/DATA_BLOCK/FILES/FILE/@filename
RUN/DATA_BLOCK/FILES/FILE/@filetype
RUN/RUN_ATTRIBUTES
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE/TAG
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE/VALUE -
The row structure of the table BANFTAB is incorrect
Dear Experts,
I get right here the error message
The row structure of the table BANFTAB is incorrect
ZBANFN is a table type and has the line tab BANFN.
Can you pls tell me what is wrong here ?
FUNCTION Z_CHANGE_EBAKZ_FLAG.
*"*"Lokale Schnittstelle:
*" CHANGING
*" VALUE(BANFTAB) TYPE ZBANFN
data lt_eban type table of eban.
data ls_eban type eban.
SELECT * FROM eban into table lt_eban where BANFN IN BANFTAB AND EBAKZ EQ 'X'.
IF SY-SUBRC IS INITIAL.
LOOP AT lt_eban INTO ls_eban .
ls_eban-EBAKZ = ' '.
modify eban from ls_eban.
ENDLOOP.
ENDIF.
ENDFUNCTION.Hello,
You have to use a ranges table in this case.
FUNCTION Z_CHANGE_EBAKZ_FLAG.
*"*"Lokale Schnittstelle:
*" CHANGING
*" VALUE(BANFTAB) TYPE ZBANFN
data:lt_eban type table of eban.
data:ls_eban type eban.
data:
l_r_banfn type range of banfn,
l_wa_banfn like line of l_r_banfn,
l_wa_banftab like likne of BANFTAB.
loop at banftab into l_wa_banftab.
l_wa_banfn-sign = 'I'.
l_wa_banfn-option = 'EQ'.
l_wa_banfn-low = l_wa_banftab-banfn.
append l_wa_banfn into l_r_banfn.
clear l_wa_banfn.
endloop.
SELECT * FROM eban into table lt_eban
where
BANFN IN L_R_BANFN "BANFN IN BANFTAB
AND EBAKZ EQ 'X'.
IF SY-SUBRC IS INITIAL.
LOOP AT lt_eban INTO ls_eban .
ls_eban-EBAKZ = ' '.
modify eban from ls_eban.
ENDLOOP.
ENDIF.
ENDFUNCTION.
or you can use FOR ALL ENTRIES :
FUNCTION Z_CHANGE_EBAKZ_FLAG.
*"*"Lokale Schnittstelle:
*" CHANGING
*" VALUE(BANFTAB) TYPE ZBANFN
data lt_eban type table of eban.
data ls_eban type eban.
SELECT * FROM eban into table lt_eban
FOR ALL ENTRIES IN BANFTAB "--> Add this
where BANFN = BANFTAB-BANFN
AND EBAKZ EQ 'X'.
IF SY-SUBRC IS INITIAL.
LOOP AT lt_eban INTO ls_eban .
ls_eban-EBAKZ = ' '.
modify eban from ls_eban.
ENDLOOP.
ENDIF.
ENDFUNCTION.
Try this & let me know in case of any issues.
BR,
Suhas
Edited by: Suhas Saha on Feb 10, 2009 5:43 PM -
Trigger in mutation - Update another rows in the same table with a trigger
Hi ,
I try to do a before update trigger on a table , but the trigger is in mutation. I understand why it do that but my question is :
How can I update other rows in the same table when a UPDATE is made on my table??????
Here is my trigger :
CREATE OR REPLACE TRIGGER GDE_COMPS_BRU_5 BEFORE
UPDATE OF DEPARTEMENT--, DISCIPLINE, DEG_DEMANDE, CE_ETAB
ON GDEM.COMPOSITION_SUBV
FOR EACH ROW
Organisme : FQRNT-FQRSC
Date de création : 14-07-2011
Date de modification :
Modifié par :
Auteur : Johanne Plamondon
Description : Ce déclencheur s'executera lors de la modification
du responsable dans la table COMPOSITION_SUBV
DECLARE
V_OSUSER V$SESSION.OSUSER%TYPE;
V_PROGRAM V$SESSION.PROGRAM%TYPE;
V_TERMINAL V$SESSION.TERMINAL%TYPE;
V_MACHINE V$SESSION.MACHINE%TYPE;
V_MODULE V$SESSION.MODULE%TYPE;
V_LOGON_TIME V$SESSION.LOGON_TIME%TYPE;
V_AUDIT_ID NUMBER;
vSEQ NUMBER;
i NUMBER;
vID DEMANDE.ID%TYPE;
BEGIN
begin
SELECT OSUSER, PROGRAM, TERMINAL,MACHINE,MODULE, LOGON_TIME
INTO V_OSUSER,V_PROGRAM,V_TERMINAL,V_MACHINE,
V_MODULE,V_LOGON_TIME
FROM V$SESSION
WHERE TYPE = 'USER'
AND USERNAME = USER
AND LAST_CALL_ET IN (0,1)
AND ROWNUM < 2;
exception when others then null; end;
IF NVL(:NEW.SC_PART,' ') = 'CHC' THEN
SELECT COUNT(*)
INTO i
FROM DEMANDE
WHERE DEM_REF = :NEW.DEM_ID
AND PER_NIP = :NEW.PER_NIP;
IF i = 1 THEN
SELECT ID
INTO vID
FROM DEMANDE
WHERE DEM_REF = :NEW.DEM_ID
AND PER_NIP = :NEW.PER_NIP;
UPDATE COMPOSITION_SUBV
SET --CE_ETAB = :NEW.CE_ETAB,
--DISCIPLINE = :NEW.DISCIPLINE,
DEPARTEMENT = :NEW.DEPARTEMENT,
--DEG_DEMANDE = :NEW.DEG_DEMANDE,
DATE_MODIF = SYSDATE,
USER_MODIF = V_OSUSER
WHERE DEM_ID = vID
AND PER_NIP = :NEW.PER_NIP
AND ANNEE = :NEW.ANNEE;
END IF;
END IF;
/*EXCEPTION
WHEN OTHERS THEN
NULL;*/
END;A standard disclaimer, the mutating trigger error is telling you that you really, really, really don't want to be doing this. It generally indicates a major data model problem when you find yourself in a situation where the data in one row of a table depends on the data in another row of that same table. In the vast majority of cases, you're far better off fixing the data model than in working around the problem.
If you are absolutely sure that you cannot fix the data model and must work around the problem, you'll need
- A package with a collection (or global temporary table) to store the keys that are modified
- A before statement trigger that initializes the collection
- A row-level trigger that adds the keys that were updated to the collection
- An after statement trigger that iterates over the data in the collection and updates whatever rows need to be updated.
If you're on 11g, this can be simplified somewhat by using a compound trigger with separate before statement, row-level, and after statement sections.
Obviously, though, this is a substantial increase in complexity over the single trigger you have here. That's one of the reasons that it's generally a bad idea to work around mutating table exceptions.
Justin -
Inserting rows in PL/SQl table
Hi,
I have a PL/SQl table which i populated through bulk collect and now i am trying to loop through the table (actually quite a few nested loops) ... Now inside one of my loops i might need to insert a new row by splitting field in the existing row in the table. Can I insert the row in the pl/sql table within the loop without affecting the 'FOR i IN tab.first..tab.last' loop ??
Also what would be the index of such a row inserted in the table. Can I access it with tab.last+1 (doesnt look like it can be done if i insert in the various levels of loops).
OR
If I insert the rows insde the nested loops , then I can access the new rows once I close all the loops and open a fresh loop ??. Will the new rows be at the last of the table.
Any help will be appreciated ...user2309906 wrote:
Hi,
I have a PL/SQl table which i populated through bulk collect and now i am trying to loop through the table (actually quite a few nested loops) ... Now inside one of my loops i might need to insert a new row by splitting field in the existing row in the table. Can I insert the row in the pl/sql table within the loop without affecting the 'FOR i IN tab.first..tab.last' loop ??
Also what would be the index of such a row inserted in the table. Can I access it with tab.last+1 (doesnt look like it can be done if i insert in the various levels of loops).
OR
If I insert the rows insde the nested loops , then I can access the new rows once I close all the loops and open a fresh loop ??. Will the new rows be at the last of the table.
Any help will be appreciated ...With an associative array:
SQL> ed
Wrote file afiedt.buf
1 declare
2 type t_arr is table of varchar2(10) index by pls_integer;
3 v_arr t_arr;
4 v_cnt number := 0;
5 begin
6 -- populate the associative array
7 for i in (select ename from emp)
8 loop
9 v_cnt := v_cnt + 1;
10 dbms_output.put_line('Populating: '||i.ename);
11 v_arr(v_cnt) := i.ename;
12 end loop;
13 -- now process the associative array
14 for i in v_arr.first .. v_arr.last
15 loop
16 dbms_output.put_line('Processing: '||i||':'||v_arr(i));
17 if v_arr(i) IN ('KING','TURNER','JAMES') then
18 v_arr(v_arr.last+1) := v_arr(i)||to_char(i);
19 dbms_output.put_line('Added: '||v_arr.last||':'||v_arr(i));
20 end if;
21 end loop;
22 -- now what's in the associative array?
23 for i in v_arr.first .. v_arr.last
24 loop
25 dbms_output.put_line('Result: '||i||':'||v_arr(i));
26 end loop;
27* end;
SQL> /
Populating: SMITH
Populating: ALLEN
Populating: WARD
Populating: JONES
Populating: MARTIN
Populating: BLAKE
Populating: CLARK
Populating: SCOTT
Populating: KING
Populating: TURNER
Populating: ADAMS
Populating: JAMES
Populating: FORD
Populating: MILLER
Processing: 1:SMITH
Processing: 2:ALLEN
Processing: 3:WARD
Processing: 4:JONES
Processing: 5:MARTIN
Processing: 6:BLAKE
Processing: 7:CLARK
Processing: 8:SCOTT
Processing: 9:KING
Added: 15:KING
Processing: 10:TURNER
Added: 16:TURNER
Processing: 11:ADAMS
Processing: 12:JAMES
Added: 17:JAMES
Processing: 13:FORD
Processing: 14:MILLER
Processing: 15:KING9
Processing: 16:TURNER10
Processing: 17:JAMES12
Result: 1:SMITH
Result: 2:ALLEN
Result: 3:WARD
Result: 4:JONES
Result: 5:MARTIN
Result: 6:BLAKE
Result: 7:CLARK
Result: 8:SCOTT
Result: 9:KING
Result: 10:TURNER
Result: 11:ADAMS
Result: 12:JAMES
Result: 13:FORD
Result: 14:MILLER
Result: 15:KING9
Result: 16:TURNER10
Result: 17:JAMES12
PL/SQL procedure successfully completed.With standard array (PL/SQL table):
SQL> ed
Wrote file afiedt.buf
1 declare
2 type t_arr is table of varchar2(10);
3 v_arr t_arr;
4 v_cnt number := 0;
5 begin
6 -- populate the pl/sql table
7 select ename bulk collect into v_arr from emp;
8 -- now process the pl/sql table
9 for i in v_arr.first .. v_arr.last
10 loop
11 dbms_output.put_line('Processing: '||i||':'||v_arr(i));
12 if v_arr(i) = 'KING' then
13 v_arr.extend;
14 v_arr(v_arr.last) := 'PRESIDENT';
15 end if;
16 end loop;
17 -- now what's in the pl/sql table?
18 for i in v_arr.first .. v_arr.last
19 loop
20 dbms_output.put_line('Result: '||i||':'||v_arr(i));
21 end loop;
22* end;
SQL> /
Processing: 1:SMITH
Processing: 2:ALLEN
Processing: 3:WARD
Processing: 4:JONES
Processing: 5:MARTIN
Processing: 6:BLAKE
Processing: 7:CLARK
Processing: 8:SCOTT
Processing: 9:KING
Processing: 10:TURNER
Processing: 11:ADAMS
Processing: 12:JAMES
Processing: 13:FORD
Processing: 14:MILLER
Processing: 15:PRESIDENT
Result: 1:SMITH
Result: 2:ALLEN
Result: 3:WARD
Result: 4:JONES
Result: 5:MARTIN
Result: 6:BLAKE
Result: 7:CLARK
Result: 8:SCOTT
Result: 9:KING
Result: 10:TURNER
Result: 11:ADAMS
Result: 12:JAMES
Result: 13:FORD
Result: 14:MILLER
Result: 15:PRESIDENT
PL/SQL procedure successfully completed.
SQL>So, in answer to your questions...
Inserting additional rows in the array during the loop will effect the "last" value and alter the array. If you need to avoid this effect, store the "last" value in a variable and loop up to that value of the variable.
New rows will generally be additional rows on the end of the array unless you are using associative arrays which will then depend on how you reference the rows in the array. -
How to update multiple row using procedure in table
Hi,
create or replace procedure TESTLEDGER1(var_date varchar2)
as
var_date1 date;
CURSOR C1 IS
select DISTINCT ta.accountid,day PROCESSDATE,
(NVL(payment,0))PAYMENT,NVL(TOTALDUE,0)TOTALDUE,NVL(currentbillamount,0)CURBILL,NVL(srf,0)SRF,NVL(sbpnt,0)sbpnt,
NVL(srv,0)SRV,NVL(sbf,0)SBF,NVL(SBV,0)SBV,NVL(EF,0)EF,NVL(EV,0)EV,NVL(TSRV,0)TSRV,
NVL(tsub,0)TSUB,NVL(teqe,0)TEQE,NVL(DT,0)DT,
NVL(A.dep,0)RDEP,NVL(B.DEP,0)PDEP,
NVL(pnt,0)PNT,NVL(eqp,0)EQP,NVL(dtr,0)DTR,NVL(drf,0)DRF,NVL(unadj,0)UNADJ
from
(select DISTINCT day ,accountid
from
syntblmaccount, tblmtime where yyyy =2010)ta,
(SELECT accountid,
SUM(srfee)srf,
SUM(srvat)srv,
SUM(subfee)sbf,
SUM(subvat)sbv,
SUM(eqefee)ef,
SUM(eqevat)ev,
SUM(ttlsrv)tsrv,
SUM(ttlsub)tsub,
SUM(ttleqe)teqe,
SUM(dep)dep,
SUM(dt)dt,trunc(fromdate)fromdate
FROM VWDT_v2
GROUP BY accountid,trunc(fromdate)
)a,
(SELECT accountid,
SUM(pnt)pnt,
SUM(subpnt)sbpnt,
SUM(eqpnt)eqp,
SUM(dep)dep,
SUM(DEPTRANSFER)dtr,
SUM(DEPREFUNDED)drf,
SUM(unadj)unadj,trunc(paymentdate)paymentdate
FROM vwkt_v4
GROUP BY accountid,trunc(paymentdate)
)b,
(SELECT ACCOUNTID,REFUND,trunc(createdate) createdate FROM vwrefund)F,
( SELECT ACCOUNTID,
TRUNC(CREATEDATE)CREATEDATE,
sum(TOTALDUE)/100 TOTALDUE,sum(currentbillamount)currentbillamount
FROM SYNTBLTDEBITDOCUMENT
group by ACCOUNTID, TRUNC(createdate))debit,
(SELECT ACCOUNTID accountid,TRUNC(createdate)CREATEDATE, SUM(totalamount)PAYMENT
from syntbltcreditdocument
where CREDITDOCUMENTTYPEID IN ('CDT01','CDT04')
-- AND ACCOUNTID='ACC000003014'
group by accountid,TRUNC(createdate))credit
where ta.accountid=a.accountid(+)
and ta.accountid=b.accountid(+)
--and ta.accountid=pay.accountid(+)
and ta.accountid=debit.accountid(+)
and ta.accountid=credit.accountid(+)
and ta.accountid=f.accountid(+)
and ta.day=a.fromdate(+)
--and ta.day=pay.createdate(+)
and ta.day=debit.createdate(+)
and ta.day=credit.createdate(+)
and ta.day=b.paymentdate(+)
and ta.day=f.createdate(+)
and trunc(ta.day)=to_date(var_date,'DD-MON-YY');
begin
select distinct processdate into var_date1 from ledgerdetail;
FOR V1 IN C1 LOOP
UPDATE LEDGERDETAILtest
SET PAYMENT=v1.payment,
TOTALDUE=v1.TOTALDUE,
CURBILL=v1.curbill,
SRF=v1.srf,
SBPNT=v1.sbpnt,
SRV=v1.srv,
SBF=v1.sbf,
SBV=v1.sbv,
EF=v1.ef,
EV=v1.ev,
TSRV=v1.tsrv,
TSUB=v1.tsub,
TEQE=v1.teqe,
DT=v1.dt,
PDEP=v1.rdep,
PNT=v1.pnt,
EQP=v1.eqp,
DTR=v1.dtr,
DRF=v1.drf,
UNADJ=v1.unadj
where accountid=v1.accountid
and processdate=v1.processdate;
--DBMS_OUTPUT.PUT_LINE('INSERTED ROW');
commit;
end loop;
end;
I have created above procedure to update table column....but i am getting run time error....
Error report:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "CRESTELVIEWSPRD501.TESTLEDGER1", line 70
ORA-06512: at line 1
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
how to resolve this error...
Pl give me solution...
thanks in advance.Hi:
You have to make sure that join condition joins one record to one record not to a group of records.
Saad,
http://saadnayef.blogspot.com/ -
Compare two rows in a same table
Dear all
I need to compare two rows in the same table, I dont know hoe to do it in pl/sql. Some one please help me on this.
example:
tr br price
xya0001 ama7 12
xya0003 ama6 14
xya0004 ama7 16
in the table tr is a unique value for each row, I need to compare price column and see whether the first value is less or greater than the next value and, if it is greater put the corresponding br value to a variable and if it is smaller put the corresponding br value to another variable. I dont know a method to do it, as I'm new to pl/sql. Some one please help me in thisnot sure what you intend to do as you have mentioned that "TR" is unique and you just want to compare each record with just the next record. Hope below query helps. The value "G" or "L" in flag would indicate if the current records price is greater than or less than the price in next record.
select tr,br,price,col4, case when price> col4 then 'G' when price< col4 then 'L' end flag from (
select tr,br,price,lag(price,1,0) over(order by tr) col4 from testcomp
) -
Append rows to existing xls file
Hello Friends,
I have a problem with gui_download. I am working on ECC6.0.
I need to append some rows to existing xls file. I am using gui_download but it not working properly.
I am giving append = 'X' also it is not appending rows it is overwriting the existing rows.
Please help in the regard.
Thanks in advance.
Krishna Yerram.Hi,
BOOK2 is laready existed excel file
Please make sure that X is captail
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = C:\BOOK2.XLS
FILETYPE = 'ASC'
APPEND = 'X'
tables
data_tab = data_tab
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards
jana -
Read first row of the internal table
Dear All,
Please let me know how to read the first row of the internal table?
I used following read statement but it is not working
READ TABLE t_cdhdr INDEX 1.Hi,
i think you are not reading an internal table
according to your code i think you are reading a type
which may be declared as types...
types are declared just for reference
eg
types: begin of t_cdhdr .
include strucuture cdhdr .
types: end of t_cdhdr .
types: t_it_cdhdr type standard table of t_cdhdr.
data: git_t_cdhdr type t_it_cdhdr.
data: gwa_t_cdhdr type t_cdhdr.
now have to fill the iternal table
and
read table git_t_cdhdr into gwa_t_cdhdr index 1.
reward points if helpful
thanks & regards,
venkatesh -
No. of Rows in an internal table
Dear Friends,
Please let me know which ABAP System Field shall give me the no. of rows in an internal table. If it is sy-dbcnt kindly provide an example on how to use it in a program.
Regards,
Alok.Hi Alok,
Use the Describe Statement.
Sample Program :
*TABLES ZVIJIRANK.
*DATA : BEGIN OF IT OCCURS 10.
*INCLUDE STRUCTURE zvijirank.
*DATA : END OF IT.
*data : lines1(4) type n,
knd type c,
n type i.
*select * from zvijirank into table it.
**describe table zvijirank lines lines1. -
> Describe statement is only used for Internal Tables.....
*write : / 'BEFORE DESENDING'.
*LOOP AT IT.
*WRITE : / IT-REG_NO , IT-NAME.
*ENDLOOP.
*ULINE.
*describe table it lines lines1. "-----> To find No Of lines
Write : lines1.
Thanks.
Message was edited by:
Viji
Maybe you are looking for
-
TS5198 Unsupported hardware only mentioned after release?
I'm very upset that these unsupported displays were not mentioned before I upgraded to Mavericks... Now, since I upgraded, my perfectly working, beautiful acrylic Cinema Display (which was totally fine under 10.8) is no longer usable with my system -
-
Field name while fetching its content from db table dynamically.
Hi Experts, I am new to ABAP and I have a situation as follows. I have a table say ztable where there are seven fields monday,tuesday,wednesday,thursday,friday and saturday. Depending on the current calender day i have to fetch the content. Suppose
-
IDOC_ADAPTER - ATTRIBUTE_INV_SND_SERV
I´ve read all the thread regarding this problem, but I still can't solve it. My interface is synchronic from an Idoc. it goes through a BPM and then reaches a WebService The messagge arrives perfectly but the ACK has the following error: IDOC_ADAPTER
-
Synchronous Read of files within FlowN structure
Hello again, I was wondering whether it would be possible to do a number of synchronous reads within a FlowN structure. Essentially, I have a list of file names which I want to loop through. For each file name, I then want to invoke a synchronous fil
-
Dreamweave cs3 install problem
Currently running DW8 on Windows Vista, I thought I would have a look at CS3. I downloaded the trial version of DW CS3 and ran it. After extracting the files, the setup starts ('Initializing Adobe setup') but then immediately disappears with no messa