Filter rows based on Where condition AND-OR ?
Hi,
I have table "Table1" and columns are
Id
AddendumNo
ClaimNo
Description
1
A1
C1
D1
2
A1
C1
D2
3
A1
C2
D1
4
A2
C3
D3
5
A2
C1
D2
I have three controls in the UI.
If I give txtA1.Text =”A1” only then should be return Id- 1,2,3 records.
If I give txtC1.Text =”C1” only then should be return Id- 1,2,5 records.
If I give txtA1.Text =”A1” AND txtC1.Text =”C1” then should be return Id- 1,2 records.
If I give give txtA1.Text =”A1” AND txtC1.Text =”C1” AND txtD1.Text=”D1” then should be return Id-1 record.
Please help me to write dynamic sql query ?
Thank you.
HI
Try following code
CREATE PROC usp_dynamic_exec @where VARCHAR(Max)
AS
BEGIN
DECLARE @strQ AS NVARCHAR(max)
SET @strQ = 'Select * from yourTableName'
IF ISNULL(@where, '') <> ''
BEGIN
SET @strQ = @strQ + ' Where ' + @where -- where clause
END
EXECUTE sp_executesql @strQ
END
GO
Ref :http://technet.microsoft.com/en-us/library/ms188001.aspx
http://www.vishalseth.com/post/2008/07/10/Dynamic-SQL-sp_executesql.aspx
http://blog.sqlauthority.com/2013/03/28/sql-server-executing-dynamic-sql-sql-queries-2012-joes-2-pros-volume-4-query-programming-objects-for-sql-server-2012/
Mark as Answer if you find it useful
Shridhar J Joshi Thanks a lot
Similar Messages
-
Highligting rows based on multiple conditions
Hi,
I have to show a report with exceptions highlighted in RED color. Exceptions are based on some conditions:
If I have four columns in an answer request, two of which say "Level" and "Status".
based on the "Level" and "Status" column conditions I have to highlight entire row which satisfies any of the condition.
Ex: If I have Level=3,4,5 and Status= Y,N then for
Level=3 or Status=N is one exception.
Level=4,5 or Status=Y is another exception.
Based on this two column conditions I have to highlight entire row in the report.
Can we do this in OBIEE. Highlighting rows based on multiple conditions?
Thanks in advance!Thanks for the reply.
I have tried that already. I can highlight one specific field but not entire row.
If I keep on applying the conditional format for the other columns too then I can't apply the conditions.
Anyways, I have created a dummy column with the conditions in it and then applied that to the other fields and used conditional format to highlight the color. -
Filter/Redirect based on file extension and path
Posted this earlier on the NSAPI list, didn't get a response. Can some
one help?
Thanks
Immanuel
I am attempting to write a filter/redirector based on file extension
and
the path of the file - some thing like:
http:\\www.wombat.com\filetpye1\file1.abc
gets redirected to server http:\\foo.com\file1.abc
http:\\www.wombat.com\filetpye2\file2.xyz
gets redirected to server http:\\bar.com\file2.xyz
Can some one tell me
a. Is this possible using NSAPI and conf file changes
b. Pointer (and source if available) to implment this
Regards
ImmanuelYou need to use Client tages and redirect and other SAFs. More info in :
http://docs.sun.com/source/817-1834-10/crobjsaf.html#wp18074
http://docs.sun.com/app/docs/doc/820-1643/abvaq?l=en&a=view&q=Client+tags -
Suppressing rows based on a condition
I have report, where I have to remove certain rows out of the report, based on the certain condition.
Note that, there are two characteristics in the rows, and one key figure in the columns. If the first characteristic value equals that of the second characteristic in the rows, I want to remove that row from display.
Row1 R1 R2 K1
Row2 R3 R3 K1
Row3 R2 R3 K1
Row4 R3 R2 K1
In the above example, I need to remove Row2, because both characteristics have same value, which is R3. I want to suppress those records, and just show Row1, Row3 and Row4.
Row1 R1 R2 K1
Row2 R3 R3 K1 -> remove this row
Row3 R2 R3 K1
Row4 R3 R2 K1
My problem is conditions only work on the key figures, not characteristics. I tried the replacement variables, but it is not working.
Any ideas?Hi,
You can achieve the solution if your 2 characteristic's data type is NUMC.
If it is NUMC, then try the below steps:
1. Create a formula in the Key Figures structure.
2. In the formula, create a formula variable, and on the formula variable select the processing type as Replacement Path. After that choose the first characteristic on the Characteristics selection.
3. Repeat step 2 again for second characteristic.
4. Now the two formula variables contains two characteristic. Select both of them and subtract it.
5. You will get the values 0 and not equel to 0.
6. Create a condition and suppress zero values of the formula key figure.
If it is not NUMC, then i guess you have to stage the data to another location. At the time of transformation you have to supress the records.
Vivek -
Trying to alter font on a report row based on data condition
Hello.
I have an Apex application with a "classic" SQL report and a corresponding form.
In the report region I am pulling all items from a table (Select * from TASKS)
The TASKS table contains many columns including DUE_DATE and COMPLETE_DATE field.
I am trying to find a way to format the rows in my report based on the condition of those two fields.
If the record has a complete_date (not null) then I want to change the font for the entire row (each column) to be grey.
If the record does not have a complete_date (null) and due_date is before today, I want the row to be bold and red.
Otherwise, the row would display standard black text.
I can't seem to find a straightforward way to do this in Apex.Hi JodyMorin,
Try looking at this post:
Conditional item formatting (color)
You will need to tweak the code a bit for your needs, but I hope it helps.
-Marc -
Coloring individual table rows based on a condition
Hi Experts,
I have a table bound to a node in the context via datasource property.
I was trying to color an individual row based on a certain value in the context node.
Can anyone help my achieve this please?
For example:
for( int i=0; i<table.size(); i++)
if(wdContext.tableNode().getTableElementAt(i).getFieldA().equals("Y"))
// then color the table row
Any suggestions?
MSolved.
-
hi ,
i need help on the below scenario ,
we have a web dynpro table with different columns, now based on new business requirement one of the column need to
dynamically editable or non editable for different row.
for ex :
Field 1
Field 2 ( Dynamic field )
Field 3
Field 4
Data 11
Data 12 ( Editable with Drop down )
data 13
data 14
Data 21
Data 22 ( Non editable )
Data 23
data 24
Data 31
data 32 ( Editable with drop down )
data 33
data 34
how to achieve this ? please help on this.
Thanks in advance
Thanks
ManishManish,
there is no proper way to insert two Cell Editors in a column(except variants), have a look on below scenario, it may help.
add one more attribute to your table context node for read-only.
create dropDown as celleditor for table and bind with newly created attribute to read-only property of dropdown.
before binding data to table, check the condition then mention readonly value abap_true / false.
@ we can achieve by the use of Variants.
for ex :
Data 11
Data 12 ( Editable with Drop down)
data 13
read-only - abap_false
Data 21
Data 22 ( Non editable, dropdown )
Data 23
read-only - abap_true
Data 31
data 32 ( Editable with drop down )
data 33
read-only - abap_false -
Unique row based on two columns and single column
Dear Members,
I have a table which contains duplicate rows, for which a query should be able to fetch the unique row from the table. Here the unique is not based on one column, but it should be on two columns and also check for uniqueness on one column.
create table addr ( firstname varchar2(10), lastname varchar2(10), area varchar2(3));
insert into addr values('bob', 'james', '1');
insert into addr values('bob', 'james', '1');
insert into addr values('harry', 'bert', '1');
insert into addr values('jimmy', 'bert', '1');
insert into addr values('sam', 'mac', '1');
insert into addr values('sam', 'knight', '1');
insert into addr values('tom', 'sand', '1');
insert into addr values('cat', 'mud', '1');
The output of query should contain 3 rows.
bob - james
harry - bert or jimmy - bert [ either one of them, but not both ]
sam - mac or sam - knight [ either one of them, but not both ]
tom - sand
cat - mud
SELECT firstname, lastname as total from addr WHERE area = '1' GROUP by firstname,lastname; This does not take of single column duplication..
Any suggestions..SQL> with t_data
as
select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
select 'bob', 'james', '1' from dual union all
select 'harry', 'bert', '1' from dual union all
select 'jimmy', 'bert', '1' from dual union all
select 'sam', 'mac', '1' from dual union all
select 'sam', 'knight', '1' from dual union all
select 'tom', 'sand', '1' from dual union all
select 'cat', 'mud', '1' from dual
SELECT
firstname,
lastname,
area
FROM
SELECT
t.*,
row_number() over(partition BY firstname order by 1) rn,
row_number() over(partition BY lastname order by 1) rn1
FROM
t_data t
WHERE
rn = 1
AND rn1 =1 ;
FIRSTNAME LASTNAME AREA
bob james 1
cat mud 1
jimmy bert 1
sam knight 1
tom sand 1
SQL> -
Filter Data based on date Condition
Hi,
Below is the query which is performing cast operation to convert string to date. Now my requirement is to filter all the dates which is from 1/1/2010 or later.
>> SELECT
>> CAST( TICKETID AS VARCHAR2(4000)) TICKETID,
CAST(CUSTOMERID AS VARCHAR2(4000)) CUSTOMERID,
CAST(CUSTOMEREMAIL AS VARCHAR2(4000)) CUSTOMEREMAIL,
CAST(CREATEDBY AS VARCHAR2(4000)) CREATEDBY,
TO_CHAR (TO_DATE ( CAST (DATECREATED AS VARCHAR2 (4000)) , 'Mon DD YYYY HH:MIAM'),'DD-MM-YYYY HH24:MI:SS') DATECREATED
FROM TICKETSI tried with the below format, But it shows as not a valid month to filter please suggest me how to perform the filter on this cast operation of cast conversion.
>> SELECT * FROM
>> ( SELECT
CAST( TICKETID AS VARCHAR2(4000)) TICKETID,
CAST(CUSTOMERID AS VARCHAR2(4000)) CUSTOMERID,
CAST(CUSTOMEREMAIL AS VARCHAR2(4000)) CUSTOMEREMAIL,
CAST(CREATEDBY AS VARCHAR2(4000)) CREATEDBY,
TO_CHAR (TO_DATE ( CAST (DATECREATED AS VARCHAR2 (4000)) , 'Mon DD YYYY HH:MIAM'),'DD-MM-YYYY HH24:MI:SS') DATECREATED
FROM TICKETS )
WHERE
DATECREATED >= TO_DATE('01-01-2010','DD-MM-YYYY HH24:MI:SS') Please suggest me how to put a filter on this date.
Thanks
SudhirSudhir_Meru wrote:
SELECT * FROM
( SELECT
CAST( TICKETID AS VARCHAR2(4000)) TICKETID,
CAST(CUSTOMERID AS VARCHAR2(4000)) CUSTOMERID,
CAST(CUSTOMEREMAIL AS VARCHAR2(4000)) CUSTOMEREMAIL,
CAST(CREATEDBY AS VARCHAR2(4000)) CREATEDBY,
TO_CHAR (TO_DATE ( CAST (DATECREATED AS VARCHAR2 (4000)) , 'Mon DD YYYY HH:MIAM'),'DD-MM-YYYY HH24:MI:SS') DATECREATED
FROM TICKETS )
WHERE
DATECREATED >= TO_DATE('01-01-2010','DD-MM-YYYY HH24:MI:SS')
Plainly un-necessary CHAR-DATE-CHAR conversion and CHAR - Date comparison.
Why do you need it?
Just use
TO_DATE ( CAST (DATECREATED AS VARCHAR2 (4000)) , 'Mon DD YYYY HH:MIAM') DATECREATEDAnd then you can do
datecreated >= to_date('01-01-2010 00:00:00', 'DD-MM-YYYY HH24:MI:SS') -
Split single row in multiple rows based on date range
I need sql script that can split single row in multiple rows based on start date and end date column in table.
Thank youI agree to your suggestion of having a dates table permanently in the database. Thats how we also do for most of our projects as well
But in most projects the ownership of table creation etc lies with the client as they will be the DBAs and will be design approval authorities. What I've seen is the fact that though
many of them are in favour of having calendar table they dont generally prefer having a permanent table for numbers in the db. The best that they would agree is for creating a UDF which will have
tally table functionality built into it based on a number range and can be used in cases where we need to multiply records as above.
Wherever we have the freedom of doing design then I would also prefer creating it as a permanent table with required indexes as you suggested.
>> many of them are in favour of having calendar table they dont generally prefer having a permanent table
Those people do not understand about database and are not DBAs :-)
It is our job to tell them what is right or wrong.
** This is a real story! I had a client several years back, who was the CEO of a software company.
He use the query:
select * from table_name
In order to get the last ID!
The table_name was actually a view that took data from several tables, and the main table that he wanted to get the ID included several string columns, with lot of data!
he actually pulled all this data to the application, just to get the lat ID in a specific table!
It is our job as Consultants or DBAs to fix's his misunderstanding :-)
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
SALV - Hide rows based on certain condtion
All,
I have searched a lot in this forum this answer, but could not find any nearest one.
I am using CL_SALV_TABLE (SALV) for an ALV report. I wanted to hide some rows based on some condition say for example
in the ALV one of the column is MATNR say i wanted to hide rows that having MATNR less than 1000.
How we can do this ?
Thanks
a®Good day, everyone!
Ive faced the same issue - I either have to hide a row or to change subtotal line manually.
Have anyone solved this already?
PPShinde wrote:
HI!
> I think u first calculate total in internal table. save that totals into some veriable and then remove those lines which u dont want to show from internal table and then calculated total append into that internal table .
> I thinks it will work!
> all the best!
I can't find anything that looks like a table for subtotals - they are counting somewhere inside SALV.
Or, maybe, you know something that I dont?
Clemens Li wrote:
If people insist on the requirement, disable SUM and create your own total line.
Add my own total line? How can I do this? -
Single quote in dynamic where condition
BAPI_STUDENT_IDENTIFIC_ADD has a field called IDENTIFICATIONNUMBER. This field is later used in a dynamic where condition and causes a short dump when it contains a single quote. I will change the program that calls the BAPI to check for single quotes, but is there anything else I need to check for to ensure a correct where condition?
Thanks,
DanHi Dan,
The best way to ensure correctness of syntax of a dynamic where condition is:
Run the program in debugging mode, Get the Query that is generated dynamically and write it to some other ABAP program and perform syntax check.
This will help you to remove all the syntax errors.
Regards,
Darshil -
How Can I Change the Where Condition In the First SQL Query?
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT,
TRUNC(MONTHS_BETWEEN((TO_DATE('19'||END_SVC_DT,'YYYYMMDD')),BEG_SVC_DT)/12),
mod(trunc(months_between((to_date('19'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12),
DECODE((SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1),-1,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-2,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-3,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-4,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-5,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-6,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-7,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-8,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-9,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-10,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-11,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-12,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-13,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-14,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-15,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-16,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-17,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-18,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-19,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-20,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-21,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-22,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-23,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-24,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-25,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-26,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-27,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-28,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-29,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-30,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-31,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
30,0,
(SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1))
FROM SVC_OCCURRENCES
WHERE end_svc_dt not in ('PRESENT')
AND SUBSTR(END_SVC_DT,1,1) IN '9'
AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
UNION
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT, NULL, NULL, NULL
FROM SVC_OCCURRENCES
WHERE SUBSTR(END_SVC_DT,1,1) IN 'P'
The above code works fine and I get the correct numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field the SQL query aborts at
the last statement in the WHERE condition. The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
I get the following error message
ERROR ORA-0722 INVALID NUMBER
I encode the word 'PRESENT' in a varchar2 end_svc_dt field on an Oracle form. This is the only word that can be encoded.
Is there some way that I can bypass the last statement in the where condition and
compute the values from the SQL query without having the SQL query abort?
Eventually I want to do this in a report. I know that this sounds strange but can it be done?The above code works fine and I get the correct
numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric
however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field
the SQL query aborts at
the last statement in the WHERE condition.Ouch!
Storting dates in VARCHAR2 columns is bad practice, poor design and makes for horrible code.
The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) -
SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')If it's a date field then why on earth are you trying to SUBSTR it. SUBSTR = sub-string i.e. take a sub section of a string not sub-date.
I get the following error message
ERROR ORA-0722 INVALID NUMBERAnd you're surprised by this?
Is there some way that I can bypass the last
statement in the where condition and
compute the values from the SQL query without having
the SQL query abort?Store your dates properly, use additional flag columns for non-date information and code your SQL properly.
Eventually I want to do this in a report. I know
that this sounds strange but can it be done?Yes, most things are possible. -
Table Control - Input Enabling/Diabling of Rows based on Condition.
Hi,
In the TC, I want to Input Enable/Disable the rows based on Conditions. The First row is input enabled always. But the other rows, (2nd onwards) need to be Input Enabled/Disabled based on some conditions. It is possible to make this working. Can you please provide me a suitable solution for this?
Appreciate Your Help.
Thanks,
KannanHi Kannan...
If we are talking about "Rows"...
then identify based on some conditions the row numbers and in PBO...loop at screen with screen name..set thier input properties and modify screen (make them input only)
If we are taking into consideration "columns"
There is an internal structure COLS where we can identify column number of screen name ...or we can take except for one particular column..
if some condition satisfied....
loop at screen where screen-name <> "Column which is input'.
Loop at screen...and make other columns display only.
modify screen
endif.
Regards
Byju -
Field symbols as Table name and in where condition in a select statement
Hello All,
I have a scenario where I need to get user input on table name and old field value and new field value. Then based on user input, I need to select the record from the database. The column name for all the tables in question is different in the database, however there data type is the same and have same values.
I am not able to use a field symbol for comparing the old field value to fetch the relevant record in my where clause.
I cannnot loop through the entire table as it has 10 millilon records, please advice on how to add the where clause as field symbol as the table name is also dynamically assigned.
Here is my code:
DATA: TAB LIKE SY-TNAME,
TAB_COMP1 LIKE X031L-FIELDNAME,
TAB_COMP2 LIKE X031L-FIELDNAME,
NO_OF_FLD TYPE N.
DATA: BEGIN OF BUFFER,
ALIGNMENT TYPE F,
C(8000) TYPE C,
END OF BUFFER.
FIELD-SYMBOLS: <WA> TYPE ANY,
<COMP1> TYPE ANY,
<COMP2> TYPE ANY.
GET TABLE NAME GIVEN BY USER IN LOCAL VARIABLE
TAB = TAB_NAME.
CREATE FIELD NAME BASED ON THE TABLE NAME ENTERED.
CASE TAB_NAME.
WHEN 'OIUH_RV_GL'.
KEY FIELD
TAB_COMP1 = 'GL_GL_SYS_NO'.
NO_OF_FLD = 1.
WHEN 'OIUH_RV_OPSL'.
KEY FIELD
TAB_COMP1 = 'OPSL_GL_SYS_NO'.
NO_OF_FLD = 1.
WHEN 'OIUH_RV_OTAX'.
NOT THE ONLY KEY FIELD
TAB_COMP1 = 'OTAX_GL_SYS_NO'.
TAB_COMP2 = 'OTAX_TAX_POS_NO'.
NO_OF_FLD = 2.
WHEN 'OIUH_RV_GTAX'.
NOT THE ONLY KEY FIELD
TAB_COMP1 = 'GTAX_GL_SYS_NO'.
TAB_COMP2 = 'GTAX_TAX_POS_NO'.
NO_OF_FLD = 2.
WHEN OTHERS.
EXIT.
ENDCASE.
SET FIELD SYMBOL WITH APPROPRIATE TYPE TO BUFFER AREA.
ASSIGN BUFFER TO <WA> CASTING TYPE (TAB).
How to add where clause and remove the if condition in the select -- endselect
SELECT * FROM (TAB) INTO <WA>.
ASSIGN COMPONENT TAB_COMP1 OF STRUCTURE <WA> TO <COMP1>.
IF NO_OF_FLD = 2.
ASSIGN COMPONENT TAB_COMP2 OF STRUCTURE <WA> TO <COMP2>.
ENDIF.
IF <COMP1> = OLD_SYS_NO.
code for updating table would come here
WRITE: 'MATCH FOUND'.
EXIT.
ENDIF.
ENDSELECT.
Please advice. Thanks much.
Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:33 PM
Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:34 PM
Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:35 PM1. Create single column table for holding field name depending on the table entered.
2. Take input from user: for e.g. table_name
3. Using case load single column table with required fields
for e.g.
CASE TAB_NAME.
WHEN 'OIUH_RV_GL'.
Append 'GL_GL_SYS_NO' to KEY_FIELD --> KEY_FIELD is the single line internal table as mentioned in step 1.
WHEN 'OIUH_RV_OPSL'.
Append 'OPSL_GL_SYS_NO'.
WHEN 'OIUH_RV_OTAX'.
Append 'OTAX_GL_SYS_NO' to KEY_FIELD.
APPEND 'OTAX_TAX_POS_NO' to KEY_FIELD.
WHEN 'OIUH_RV_GTAX'.
Append 'GTAX_GL_SYS_NO' to KEY_FIELD.
APPEND 'OTAX_TAX_POS_NO' to KEY_FIELD.
WHEN OTHERS.
EXIT.
ENDCASE.
Now depending on the table name you have required column ready
4. Create dynamic internal table using following sudo code
Fill the fieldcatlog using the single column field table and DD03L table, See what all columns from DD03L you want to fill in field catlog table
loop at internal table with all the fields.
move it to field catalog.
append field catalog.
endloop.
5. Pass this field catalog table to static method create_dynamic_table method
DATA table TYPE REF TO DATA. --> data object for holding handle to dynamic internal table.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = fieldcatalog_tab
importing
ep_table = table.
6. Now assign table reference to field symbol of type table.
ASSIGN table->* to <field-tab>.
7. Also create work area <field-wa> using refrence of table.
create data object wa LIKE LINE OF <field-tab>.
ASSIGN wa->* to <field-wa>.
8. Also define field symbol for field name.
for e.g. <field_name>
4. Dynamic internal table is ready
5. Now execute the select statement as follows:
SELECT (KEY_FIELD)
INTO <ITAB> --> created dynamically above
FROM (TABLE_NAME)
WHERE (WHERE). --> WHERE is single line internal table having line type of CHAR72. So for every old value there will be one line
Where condition is same as like we give in static way only difference in this case it will stored in internal table line wise.
In this case you need to append all your where condition line by line in to WHERE.
5. To fill this dynamic internal table using ASSIGN COMPONENT <Comp_number> OF STRUCTURE <field-wa> TO <field-name>
So in this case if first field of structure STRUCT1 is user_id then sudo-code will be
loop at internal table containing list of fields into field_wa --> single column field table
ASSIGN COMPONENT field_wa OF STRUCTURE <field-wa> TO <field>. "Here field_wa is wa area for single column internal table holding all the fieldnames.
Now <field-name> points to user_id field. Move some value into it as nornally we do with variables.
Move <your_new_value> to <field-name>. --> Assign new value
or
<field-name> = <your_new_value>.
Endloop.
6. After completing all the fields one row will be ready in <field_wa>.
APPEND <field_wa> to <field_tab>.
Hope this helps you.
Thanks,
Augustin.
Maybe you are looking for
-
3rd Gen 15g isnt recognized by updater, and unknown pic on ipod HELP!
The ipod updater is not recognizing the ipod. Even though it is plugged in and it says do not disconnect. The ipod it self, shows a picture of the end of a pin connector with an arrow on it, and it wont go away. Please help! The ipod was working unti
-
How to get 32bit Windows 7 on new Envy 17
Hi All, This is just a helpfull mail for all those Win7 fans and people with too much 32bit apps. WARNING: Steps below may void your waranty (so get an in store extended waranty lol) Finally managed to get Windows 7 SP1 32bit fully functional .... (C
-
Apple TV 2 stalls over extended Airport network?
Hello. I have an Apple TV 2 in my basement, right next to an Airport Express (802.11n) that extends my Airport Extreme (802.11n) network - which originates upstairs, in my office. ATV2 reports a signal strength of "five bars" in this configuration. H
-
How do I get my apps to send notifications to iCloud
I'm trying to get all of my apps (like twitter) to send me notifications to my iCloud email instead of my actual email. Mainly because the kind of email I use doesn't have an app I can get. Is this possible or am I stuck?
-
Reporting on Previous Month/Current Year - Jan 09 fix
I currently have about 10 reports that are being filtered to only show data on the repository variables for : PreviousMonth and Current Year. When Jan 1, 2009 comes around, these reports will be kicked off to show Decemeber of the Current Year, so De