Query in a table with similary fields
Hi,<br>
I have a table with fields like :<br>
- DB_AMOUNT_01<br>
- DB_AMOUNT_02<br>
- DB_AMOUNT_03<br>
- CR_AMOUNT_01<br>
- CR_AMOUNT_02<br>
- CR_AMOUNT_03</p>
I would like to create a function like :<br>
AMOUNT(PERIOD)</p>
If I choose 1, the query would do :<br>
DB_AMOUNT_01 + CR_AMOUNT_01</p>
If I choose 2, the query would do :<br>
DB_AMOUNT_02 + CR_AMOUNT_02</p>
Is it possible ?<br>
Ideally, I would rather not use IF, THEN, ELSE like :<br>
<font face="Courier New" size="2">IF MyChoose = 1 THEN<br>
ELSEIF MyChoose = 2 THEN<br>
ELSE<br>
END IF</font></p>
I prefer to be able to write somethings like :<br>
<font face="Courier New" size="2">SELECT DB_AMOUNT || MyChoose + CR_AMOUNT || MyChoose</font></p>
Thank you very much.</p>
<font color="#008080"><i><b>Patrick</b></i></font>
try this:
create or replace function my_amount( period in varchar2) return number
as
v_str varchar2(100);
v_str2 varchar2(1000);
v_amount number;
begin
v_str := 'DB_AMOUNT_'||period || ' + ' || ' CR_AMOUNT_' || period;
v_str2 := 'SELECT SUM(' || v_str || ' ) FROM myTable ';
EXECUTE IMMEDIATE v_str2 INTO v_amount;
return v_amount;
end my_amount;
This is intended to be pseudo-code to show the flow of logic. You can modify v_str2 to write the SQL according to your needs ... just make sure that the SQL returns only one record. Also, you may want to add Exception handling.
The input period is in format '01' or '02' if the period is in single digits.
Shakti
http://www.impact-sol.com
Developers of Guggi Oracle - Tool for DBAs and Developers
Similar Messages
-
Understanding logminer results -- inserting row into table with CLOB field
In using log miner I have noticed that inserts into rows that contain a CLOB (I assume this applies to other LOB type fields as well, have only tested with CLOB so far) field are actually recorded as two DML entries.
--the first entry is the insert operation that inserts all values with an EMPTY_CLOB() for the CLOB field
--the second entry is the update that sets the actual CLOB value (+this is true even if the value of the CLOB field is not being set explicitly+)
This separation makes sense as there may be separate locations that the values are being stored etc.
However, what I am tripping over is the fact the first entry, the Insert, has a RowId value of 'AAAAAAAAAAAAAAAAAA' which is invalid if I attempt to use it in a flashback query such as:
SELECT * FROM PERSON AS OF SCN #####' where RowId = 'AAAAAAAAAAAAAAAAAA'The second operation, the Update of the CLOB field, has the valid RowId.
Now, again, this makes sense if the insert of the new row is not really considered "+done+" until the two steps are done. However, is there some way to group these operations together when analyzing the log contents to know that these two operations are a "+matched set+"?
Not a total deal breaker, but would be nice to know what is happening under the hood here so I don't act on any false assumptions.
Thanks for any input.
To replicate:
Create a table with CLOB field:
CREATE TABLE DEVUSER.TESTTABLE
ID NUMBER
, FULLNAME VARCHAR2(50)
, AGE NUMBER
, DESCRIPTION CLOB
);Capture the before SCN:
SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL;Insert a new row in the test table:
INSERT INTO TESTTABLE(ID,FULLNAME,AGE) VALUES(1,'Robert BUILDER',35);
COMMIT;Capture the after SCN:
SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL;Start logminer session with the bracketing scn values and options etc:
EXECUTE DBMS_LOGMNR.START_LOGMNR(STARTSCN=>2619174, ENDSCN=>2619191, -
OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + -
DBMS_LOGMNR.COMMITTED_DATA_ONLY + DBMS_LOGMNR.NO_ROWID_IN_STMT + DBMS_LOGMNR.NO_SQL_DELIMITER)Query the logs for the changes in that range:
SELECT
commit_scn, xid,operation,table_name,row_id
,sql_redo,sql_undo, rs_id,ssn
FROM V$LOGMNR_CONTENTS
ORDER BY xid asc,sequence# ascResults:
2619178 0C00070028000000 START AAAAAAAAAAAAAAAAAA set transaction read write
2619178 0C00070028000000 INSERT TESTTABLE AAAAAAAAAAAAAAAAAA insert into "DEVUSER"."TESTTABLE" ...
2619178 0C00070028000000 UPDATE TESTTABLE AAAFEXAABAAALEJAAB update "DEVUSER"."TESTTABLE" set "DESCRIPTION" = NULL ...
2619178 0C00070028000000 COMMIT AAAAAAAAAAAAAAAAAA commitEdited by: 958701 on Sep 12, 2012 9:05 AM
Edited by: 958701 on Sep 12, 2012 9:07 AMScott,
Thanks for the reply.
I am inserting into the table over a database link.
I am using the new version of HTML Db (2.0)
HTML Db is connected to an Oracle 10 database I think, however the table I am trying to insert data into (via the database link) is in an Oracle 8 database - this is why we created a link to it as we couldn't have the HTML Db interacting with the Oracle 8 database directly due to compatibility problems (or so I've been told)
Simon -
How to convert internal table with dynamic fields to XML
Dear all,
I met a problem like the following:
The aim is to transform the following parameter to XML
IT_FIELD stores the dynamic filed name of the internal table,with these fields, the dynamic internal can be created by cl_abap_tabledescr=>create(it_field)
IT_VALUE stores the value of the internal table dynamically created with dynamic fields.
For example
IT_FIELD =>
line1: FIELD1
line2: FIELD2
line3: FIELD3,
three lines in this internal table.
dynamically created internal table structure FIELD1 FIELD2 FIELD3
And IT_VALUE=>
1 2 3 (First line)
11 22 33
two lines of data.
Do you have any idea about how to transform the IT_VALUE to XML here? And also the transformed XML to the IT_VALUE.( we may need remember IT_FIELD here for later XML to IT_VALUE.)
Hope I describe the problem clearly.
Any inputs will be appreciated.
Edited by: Max Tang on Jan 12, 2009 3:46 PM
Edited by: Max Tang on Jan 12, 2009 4:14 PMHi,
you need to implement a bit of coding for that.
With the 'do varying' statement abap provides a loop over those fields. Within this loop you can build up a new internal table with one entry for each period and amount.
kind regards
Siggi
PS: I am not very familiar with CO, but I guess there will be a standard extractor for that. -
...but when I fill a table with merge fields, it ends up creating multiple entries for the same address, rather than one table full of each address. Please help.
Thanks!That is a quirk of Pagesthat it applies only one record per page.
There is a way around this:
http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=245&highlight=labels &mforum=iworktipsntrick
Peter -
Subform with table with expanding fields - please help!
I am a new user of LiveCycle Designer ES and need help with a form. I've made so many changes within the form that I have now lost track and don't know where to start to fix the following two issues:
The form itself is one Master Page that needs to repeat, based on the amount of data entered. This is not happening.
Within the form is a Table with expanding fields. It is when the last field is full that I need a new page created.Also, as the table expands, it overwrites the Footer, which is a subform. The footer is set to have a top margin (.25).
Any assistance would be much appreciated. Thank you!Looks like a cross post. see other thread here...
http://forums.adobe.com/thread/489453?tstart=0 -
How to update database table with key field?
Hello Experts,
I have a database table with following fields
MATNR - Key
SSOUR - Key
KUNNR - Key
MENG1
MENG2
MENG3
And this table contains records like...
MSD50001 R 1000001 5.30 2.30 5.25
MSD50002 R 1000002 5.30 2.30 5.25
MSD50003 R 1000003 5.30 2.30 5.25
MSD50005 R 1000004 5.30 2.30 5.25
MSD50004 R 1000005 5.30 2.30 5.25
I have an internal table with same fields of above database table.
MSD50001 A 1000001 5.30 2.30 5.25
MSD50002 A 1000002 5.30 2.30 5.25
MSD50003 A 1000003 5.30 2.30 5.25
MSD50005 A 1000004 5.30 2.30 5.25
MSD50004 A 1000005 5.30 2.30 5.25
MSD50006 A 1000006 5.30 2.30 5.25
I want to update the DB table with following internal table records.
If internal table records = db table records are same then Update....else insert from internal table to db table.
But here, SSOUR is key field so i am not able to use
MODIFY dbtab from itab.
It results me , entries in internal table are inserted into db table.
So i have double records.
Is there any statement which updates the key field? and if no fields in db table then insert it?
Regards
RHhi,
u cannot update akey field.u can update only non key fields by using key field as a selection criteria.For example if u go to sm30 if u enter any table for inserting values, the key field will always be greyed out it is not succumbed to chnges.but u can insert value into ,if ur inserting and in the insert staemnet if u have key field which is already present in the table it will return sy-subrc = 4 otherwise it will insert the record and return 0.
eg for update :
UPDATE zdm_wtyprof SET upload_status = 'S'
WHERE spart = wa_upd-spart.
here spart is the key field and it will update the status field in the table as S.
if updated succesfully it will return 0.
SIMILARLY U CAN USE select. -
Query on a table with indexed date field
I have a table with a date column which is indexed. If I run a query like "select column1 where date_field='20-JAN-04' for example it is fast and uses index.
If I run select column1 where date < '20-JAN-04' it is slow and doesnt use the index. I logged a TAR and Oracle told me that this is to be expected as not using the index in this case is the most effiecient way of doing the query.
Now my concept of an index is like the index of Yellow Pages(telephone directory) for example. In this example if I look for a name that is say "Halfords" or below, I can see all entries for Halfords and all the way to ZZZ in one block.
I just cant see , in a common sense way why Oracle wont use the index in this type of query.
GeorgeUsing the concept of a telephone directory is wrong. In a telephone directory you have all information order by the name. However in your table (if it is not an IOT) you don't have all information/rows ordered by your date_field. Rather think at the document "Oracle9i Database Concepts" and it's index.
Let's say you want to find all indexed words larger then "ISO SQL standard" (ok that doesn't make sense but it is just an example). So would it be faster to read the whole document or to lookup each word in the index and then read the entire page (Oracle block) to find the word.
It's not allways easy to know in advance if the query will be faster over the index or a full table scan. what you need to do is to well analyze (dbms_stats) the table and it's index, in most cases Oracle chooses the right way. You may also use the hint /*+ index(table_name index_name) */ and will see if it would be faster over the index or not.
A good document about that subject is:
http://www.ioug.org/tech/IOUGinDefense.pdf
HTH
Maurice -
How do I avoid ORA-01473 when querying hierarchial on tables with VPD predicates
My question is how to circumvent what seems to be a limitation i ORACLE, if at all possible. Please read on.
When using VPD (Virtual Private Database) predictaes on a table and performing a hierarchial query on that table I get the following error message:
ORA-01473: cannot have subqueries in CONNECT BY CLAUSE
My query may look like the folwing:
SELECT FIELD
FROM TABLE
START WITH ID = 1
CONNECT BY PRIOR ID = PARENT
As my predicate contains a query in it self, I suspect that the implicit augmentation of the predicate results in a query that looks like:
SELECT FIELD
FROM TABLE
START WITH ID = 1
CONNECT BY PRIOR ID = PARENT
AND OWNER IN (SELECT OWNER FROM TABLE2 WHERE ...)
at least, when executing a query like the one above (with the explicit predicate) I get the identical error message.
So my question is:
Do you know of any way to force the predicate to augment itslef onto the WHERE-clause? I would be perfectly happy with a query that looks like:
SELECT FIELD
FROM TABLE
START WITH ID = 1
CONNECT BY PRIOR ID = PARENT
WHERE OWNER IN (SELECT OWNER FROM TABLE2 WHERE ...)
or do you know of any fix/patch/release to ORACLE that allows you to include subqueries in the CONNECT BY-clause and eliminates the error message?The WHERE clause or AND clause applies to the line directly above it. Please see the examples of valid and invalid queries below, which differ only in the placement of the WHERE or AND clause. If this is not sufficient, please provide some sample data and desired output to clarify what you need.
-- valid:
SQL> SELECT empno,
2 mgr,
3 deptno
4 FROM emp
5 WHERE deptno IN
6 (SELECT deptno
7 FROM dept
8 WHERE dname = 'RESEARCH')
9 START WITH mgr = 7566
10 CONNECT BY PRIOR empno = mgr
11 /
EMPNO MGR DEPTNO
7788 7566 20
7876 7788 20
7902 7566 20
800 7902 20
-- invalid:
SQL>
SQL> SELECT empno,
2 mgr,
3 deptno
4 FROM emp
5 START WITH mgr = 7566
6 CONNECT BY PRIOR empno = mgr
7 WHERE deptno IN
8 (SELECT deptno
9 FROM dept
10 WHERE dname = 'RESEARCH')
11 /
WHERE deptno IN
ERROR at line 7:
ORA-00933: SQL command not properly ended
-- valid:
SQL>
SQL> SELECT empno,
2 mgr,
3 deptno
4 FROM emp
5 START WITH mgr = 7566
6 AND deptno IN
7 (SELECT deptno
8 FROM dept
9 WHERE dname = 'RESEARCH')
10 CONNECT BY PRIOR empno = mgr
11 /
EMPNO MGR DEPTNO
7788 7566 20
7876 7788 20
7902 7566 20
800 7902 20
-- invalid:
SQL>
SQL> SELECT empno,
2 mgr,
3 deptno
4 FROM emp
5 START WITH mgr = 7566
6 CONNECT BY PRIOR empno = mgr
7 AND deptno IN
8 (SELECT deptno
9 FROM dept
10 WHERE dname = 'RESEARCH')
11 /
FROM emp
ERROR at line 4:
ORA-01473: cannot have subqueries in CONNECT BY clause -
Error displaying a jpg file loaded into a table with blob field
This may not be the correct forum for this question, but if it isn't could someone direct me to the correct one.
I have created a table with a blob field in which I have loaded a jpg image. This appeared to work correctly, but when I try to display the image in internet explorer it comes back and tells me that it doesn't recognize the file type. Enclosed is the table create, load, and display pl/sql code. Can anyone tell me what I am doing wrong. Thanks. For the mime/header I used owa_util.mime_header('images/jpg') because my image is a jpg file.
The database is 10g
-- Create table
create table PHOTOS
IMAGEID NUMBER(10),
IMAGE BLOB,
IMAGE_NAME VARCHAR2(50)
load image
CREATE OR REPLACE PROCEDURE load_file ( p_id number, p_photo_name in varchar2) IS
src_file BFILE;
dst_file BLOB;
lgh_file BINARY_INTEGER;
BEGIN
src_file := bfilename('SNAPUNCH', p_photo_name);
-- insert a NULL record to lock
INSERT INTO photos (imageid, image_name, image)
VALUES (p_id , p_photo_name, EMPTY_BLOB())
RETURNING image INTO dst_file;
-- lock record
SELECT image
INTO dst_file
FROM photos
WHERE imageid = p_id AND image_name = p_photo_name
FOR UPDATE;
-- open the file
dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
-- determine length
lgh_file := dbms_lob.getlength(src_file);
-- read the file
dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
-- update the blob field
UPDATE photos
SET image = dst_file
WHERE imageid = p_id
AND image_name = p_photo_name;
-- close file
dbms_lob.fileclose(src_file);
END load_file;
display image
PROCEDURE display_image(p_id NUMBER) IS
Photo BLOB;
v_amt NUMBER DEFAULT 4096;
v_off NUMBER DEFAULT 1;
v_raw RAW(4096);
BEGIN
-- Get the blob image
SELECT image
INTO Photo
FROM PHOTOS
WHERE IMAGEID = p_id;
owa_util.mime_header('images/jpg');
BEGIN
LOOP
-- Read the BLOB
dbms_lob.READ(Photo, v_amt, v_off, v_raw);
-- Display image
htp.prn(utl_raw.cast_to_varchar2(v_raw));
v_off := v_off + v_amt;
v_amt := 4096;
END LOOP;
dbms_lob.CLOSE(Photo);
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
END;
The url I enter is: http://webdev:7777/tisinfo/tis.tiss0011.Display_Image?p_id=1Just a little more information. When I enter owa_util.mime_header('image/jpeg') I can't display the file. It just shows up with a red x for the file.
When I enter owa_util.mime_header('image/jpg') it displays the file, but in the format
¿¿¿¿JFIF¿¿-Intel(R) JPEG Library, version [2.0.16.48]¿¿C
This is the way I would expect it to look if I opened it with Notepad, or an application that doesn't recognize jpg files. Can anyone tell me what I am doing wrong?? Thanks. -
Dynamic creation of table with variable field-names
HI
I am looking for a way in order to create a table during runtime. The problem is that the field names of the table are provided in another table.
TO illustrate the case at hand, an example:
The initial table contains the fields
UserID - attribut_name - attribute_value
Example Data
d00587 - first_name - Jon
d00587 - last_name - Smith
d00587 - age - 48
d00127 - first_name - Jack
d00127 - last_name - Daniels
d00127 - position - Manager
Now I need to create a table per User that looks as follows:
for user d00587
first_name - last_name - age
**Values
Jon - Smith - 48
for user d00127
first_name - last_name - positioin
Jack - Daniels - Manager
I split the initial table by sorting it according to userID and then looping into an itab with an AT END OF userid, thus I receive the table per user:
Example iTab
UserID - attribut_name - attribute_value
Example Data
d00587 - first_name - Jon
d00587 - last_name - Smith
d00587 - age - 48
However I have no clue on how to create a new internal table with field-names = attribute_name.
Does anybody have an idea or example code for this?
Thanks a lot for your help,
Kind regards,
MingoloHello Minima
Here is some sample coding:
DATA:
gt_fcat type lvc_t_fcat,
gdo_data TYPE REF TO data.
FIELD-SYMBOLS:
<gt_itab> TYPE table.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'MARA'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
* I_STYLE_TABLE =
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = gdo_data
* E_STYLE_FNAME =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN gdo_data->* TO <gt_itab>.
In your case, you would call the function module with your tables (D00587, D00127). Remove all fields from the fieldcatalog that you do not need before calling the static method.
Regards
Uwe -
In OWB I need to update the target table with same field for match/update
In OWb I am trying to update the target table with the match and the update on the same field can this be done. I am getting a error match merge error saying you cannot update and match on the same field. But in SQl my select is
Update table
set irf = 0
where irf = 1
and process_id = 'TEST'
Hwo do i do this in OWB.table name is temp
fields in the table
field1 number
field2 varchar2(10)
field3 date
values in the table are example
0,'TEST',05/29/2009
9,'TEST',05/29/2009
0,'TEST1',03/01/2009
1,'TEST1',03/01/2009
In the above example I need to update the first row field1 to 1.
Update temp
set field1 = 1
where field1 = 0
and field2 = 'TEST'
when I run this I just need one row to be updated and it should look like this below
1,'TEST',05/29/2009
9,'TEST',05/29/2009
0,'TEST1',03/01/2009
1,'TEST1',03/01/2009
But when I run my mapping I am getting the rows like below the second row with 9 also is getting updated to 1.
1,'TEST',05/29/2009
1,'TEST',05/29/2009
0,'TEST1',03/01/2009
1,'TEST1',03/01/2009 -
Select query on a table with 13 million of rows
Hi guys,
I have been trying to perform a select query on a table which has 13 millions of entries however it took around 58 min to complete.
The table has 8 columns with 4 Primary keys looks like below:
(PK) SegmentID > INT
(PK) IPAddress > VARCHAR (45)
MAC Address > VARCHAR (45)
(PK) Application Name > VARCHAR (45)
Total Bytes > INT
Dates > VARCHAR (45)
Times > VARCHAR (45)
(PK) DateTime > DATETIME
The sql query format is :
select ipaddress, macaddress, sum(totalbytes), applicationname , dates,
times from appstat where segmentid = 1 and datetime between '2011-01-03
15:00:00.0' and '2011-01-04 15:00:00.0' group by ipaddress,
applicationname order by applicationname, sum(totalbytes) desc
Is there a way I can improve this query to be faster (through my.conf or any other method)?
Any feedback is welcomed.
Thank you.
MusTolls wrote:
What db is this?
You never said.
Anyway, it looks like it's using the Primary Key to find the correct rows.
Is that the correct number of rows returned?
5 million?
Sorted?I am using MySQL. By the way, the query time has been much more faster (22 sec) after I changed the configuration file (based on my-huge.cnf).
The number of rows returned is 7999 Rows
This is some portion of the my.cnf
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 800M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
log = /var/log/mysql.log
log-slow-queries = /var/log/mysqld.slow.log
long_query_time=10
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 6
Is there anything else I need to tune so it can be faster ?
Thanks a bunch.
Edited by: user578505 on Jan 17, 2011 6:47 PM -
Use of selection table with 4 fields
Hi everyone
Can someone please explain to me what is the use of the seltab 4 fields, how they are used and provide an example, cos Im kinda struggling understanding them...
Thanks in advance
AdamHi,
Explicity there is a selection table for select-options that is seltab and it have sign, low, high, and option.
Actually these values are also available in ranges.
Just to explain you go through this info.
What are the difference between SELECT-OPTIONS & RANGES?
Here both SELECT-OPTIONS & RANGES works for the same purpose. They both are used for the range selection from selection screen. The main diff. between them is, while we use SELECT-OPTIONS system implicitly creates the select options internal table which contains the fields of SIGN,OPTION,LOW & HIGH. But in case of RANGES, this internal table should be defined explicitly.
Eg. to SELECT-OPTIONS :
REPORT YARSELECT.
TABLES YTXLFA1.
SELECT-OPTIONS : VENDOR FOR YTXLFA1-LIFNR.
INITIALIZATION.
VENDOR-LOW = 1000. " It specifies the range starting value.
VENDOR-HIGH = 2000. " It specifies the range ending value.
VENDOR-OPTION = 'BT'. " specifies ranges value is in between.
VENDOR-SIGN = 'I'. "specifies both inclussive.
APPEND VENDOR.
SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB
WHERE LIFNR IN VENDOR.
Eg. to RANGES:
REPORT YARRANGE.
TABLES YTXLFA1.
RANGES: VENDOR FOR YTXFLA1-LIFNR.
SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB
WHERE LIFNR IN VENDOR.
Here with RANGES user has to design an internal table with fields -
SIGN,OPTION,LOW and HIGH EXPLICITLY.
>
Example:
select-options: bukrs for zstock-bukrs.
Should the user fill in 'ABFI' in BUKRS on the selection screen, BUKRS will look like this:
IEQABFI
This is because BUKRS is set as a table as follows:
begin of bukrs occurs 0,
SIGN(1) type c,
OPTION(2) type c,
LOW like bukrs,
HIGH like bukrs,
end of bukrs.
Now, when you create the following range, it will have the exact same fields set inside its table:
Ranges: bukrs for zstock-bukrs.
The difference is, because ranges doesn't show on the selection screen, you will have to fill it yourself, meaning you will have to fill bukrs-sign, bukrs-option, bukrs-low & bukrs-high all manually.
Some tips:
Sign is always I (for Include) or E (for Exclude)
Option can be a whole range, which includes:
EQ (Equal)
BT (Between))
CP (Contain Pattern)
So let's say you want to have the range check for all company codes not starting with AB, you will set your code as follow:
ranges: bukrs for zstock-bukrs.
bukrs-sign = 'E'. "Exclude
bukrs-option = 'CP'. "Pattern
bukrs-low = 'AB*'. "Low Value
bukrs-high = ''. "High Value
append bukrs.
Always remember to APPEND your range when you fill it, as the WHERE clause checks against the lines of the range table, not against the header line.
Hope this explains it well enough.
>
What does SIGN "I" & "E" mean?
The "I" stands for Include, and the "E" for Exclude.
The easiest way to learn how the range selections work is, create the following dummy program:
report dummy.
tables: mara.
select-options: matnr for mara-matnr.
start-of-selection.
loop at matnr.
write: / matnr-sign,
matnr-option,
matnr-low,
matnr-high.
endloop.
Run this program, and fill in a lot of junk into MATNR. Fill in some includes, some excludes, some ranges, etc., and you will soon realise how the system builds ranges (select-options). Once you know that, you can fill your own ranges quickly and efficiently.
Hope this info helps.
Regards,
Kumar. -
Dynamic Internal Table with Dynamic Fields
Hi all,
My scenario is fairly simple----
--> End user clicks a button on screen and he gets the list of HR tables.
--> Then selects a table and list of all the fields for that table gets displayed.
--> He/she selects the fields they want data to be retrieved for.
So, the requirement is, the dynamic internal table should get created with the fields selected.
The select statement should only retrieve fields which were selected by the end user
and from the table selected by the end user.
I believe the fields selected by end user can be passed by a variable of type string.
something like this---
select (fields)
from (p_table) " Table selected by end user
into dynamic internal table. " should contain columns selected by end user"
Appreciate your inputs and guidance.
Warm regards,
Hari KiranTYPE-POOLS :ABAP.
Parameters P_TAB TYPE DDOBJNAME.
DATA : GO_LINE_TYPE TYPE REF TO CL_ABAP_STRUCTDESCR,
GO_TABLE_DESC TYPE REF TO CL_ABAP_TABLEDESCR,
GS_COMPONENTS TYPE ABAP_COMPONENTDESCR,
GT_COMPONENTS TYPE ABAP_COMPONENT_TAB,
GR_TAB TYPE REF TO DATA,
GT_FIELDS TYPE TABLE OF DFIES WITH HEADER LINE.
FIELD-SYMBOLS: <GT_TABLE> TYPE TABLE,
<GS_TABLE> TYPE ANY,
<GV_VALUE> TYPE ANY.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = P_TAB
* FIELDNAME = ' '
* LANGU = SY-LANGU
* LFIELDNAME = ' '
* ALL_TYPES = ' '
* GROUP_NAMES = ' '
* UCLEN =
* IMPORTING
* X030L_WA =
* DDOBJTYPE =
* DFIES_WA =
* LINES_DESCR =
TABLES
DFIES_TAB = GT_FIELDS
* FIXED_VALUES =
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT GT_FIELDS.
CLEAR GS_COMPONENTS.
GS_COMPONENTS-NAME = GT_FIELDS-FIELDNAME.
GS_COMPONENTS-TYPE ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_NAME( GT_FIELDS-ROLLNAME ).
APPEND GS_COMPONENTS TO GT_COMPONENTS.
ENDLOOP.
GO_LINE_TYPE = CL_ABAP_STRUCTDESCR=>CREATE( GT_COMPONENTS ).
GO_TABLE_DESC = CL_ABAP_TABLEDESCR=>CREATE( GO_LINE_TYPE ).
CREATE DATA: GR_TAB TYPE HANDLE GO_TABLE_DESC.
ASSIGN: GR_TAB->* TO <GT_TABLE>.
SELECT * FROM (P_TAB) APPENDING CORRESPONDING FIELDS OF TABLE <GT_TABLE>.
LOOP AT <GT_TABLE> ASSIGNING <GS_TABLE>.
NEW-LINE.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <GS_TABLE> TO <GV_VALUE>.
IF SY-SUBRC NE '0'.
EXIT.
ENDIF.
WRITE : <GV_VALUE>.
ENDDO.
ENDLOOP. -
How to modify field symbol of type Index Table with other field symbol of type any.
Hello Experts,
How is it possible to update an filed symbol table of type Index table with other filed symbol table.
e.g.
Field symbol : <lt_table1> type Index table.
Field symbol : <lt_table2> type Index table.
after some code...at run time these table filled like following.
<lt_tabel1 > has value fore column like c11 , c12 , c13
<lt_table2> has value for column like C11 , C12 , C13 , C14 , C15 . some extra values from <lt_table1>
Now I want to be modify <table1> one entires like C12 with <table2 > col C12.
how I can achieve this.
Regards,
Chetan.Hi,
did you try ASSIGN COMPONENT xx OF STRUCTURE <IT_TABEL1> TO <IT_TABLE2>.
xx will contain the number of the column
or maybe, if you have the description with a field catalog or other, that will be easier ..
regards
Fred
Maybe you are looking for
-
Hi. I recently picked up an iPhone 4S and changed my old Apple ID from an extinct email address to a current one. Everything is good with the phone and I updated my iPad to OS5. I noticed that the phone and pad were not updating each other via cloud
-
How to find out the accounts for a particular IBUs?
Hi, I want to find out accounts for particular accounts. Regards, Jaya
-
How to install visual basic 6.0 in windows 8
Hi microsoft team, I recently download the visual basic 6.0 in my windows 8 laptop. But it is not working properly in my system. When i was run the visual basic program it will show "visual basic has stopped working window is checking solution for t
-
How to deal with Invoice after Down Payment
HI , I am testing Down payment for vendor and We have activated withholding tax in our company code . I was just wonder how system will behave if we have suppose 50 % of down payment . Complete process is as below Create a request in F-47 for 50
-
Data upload from xls to internal table
Suppose I have data in the form of a matrix and I need to upload the data into the database after validation. The excel sheet is of the format: Emp Empdept E1 E2 E3 E4 E5 E6 E7 E8 E9 E1 MEC 0 2 3