Compare two fields
Hi
I have a table with 2 fields
ROW....FIELD1.......FIELD2
001.......XX_0020......XX_20
002.......XX_0002......XX_2
003.......XX_0200......XX_200
004.......XX_0201......XX_200
005.......XX_0037......XX_39
In select statement I would like to get only rows: 001, 002 and 003
because in these rows FIELD1 = FIELD2 if all zeros between "XX_" and first sign not equal "0" in FIELD1 are not taken into consideration.
Regards
PWnuk
for simple demo check this...
data: begin of itab occurs 0,
field1 type i,
field2 type i,
end of itab .
itab-field1 = '10'.
itab-field2 = '0010'.
append itab .
itab-field1 = '20'.
itab-field2 = '0020'.
append itab .
itab-field1 = '30'.
itab-field2 = '0030'.
append itab .
loop at itab .
if itab-field1 = itab-field2 .
write:/ itab-field1 , itab-field2 .
endif.
endloop.
Similar Messages
-
I would like to compare two field and then is it's true then the output will be the 2nd one
Hello All,
I am doing a mappong where i need to compare two field and then if there are equal the 2nd one should be the output and 2nd value will be using multiple segment.
It's for shipment.
Regards
RituparnaNot sure if i understand correctly. But you are trying to compare one field with multiple occurrences of another field.
You can make use of the node function "Use One as Many" and repeat the first value as many times as the second value.
Please refer to below wiki.
Explain node functions - Process Integration - SCN Wiki -
Compare two fields of one table in selection.
Dear Experts,
I want to compare two fields of a table and make selection according to this.
Ex: simply i want to select the rows from table mard where mard-labst>mard-insme. Could you write me the code to make this selection.Yes, Thomas,
Its working:
Sample code:
data: begin of itab occurs 0,
matnr type matnr,
ernam type ernam,
end of itab.
select matnr ernam
into table itab
from mara where brgew > mara~ntgew.
loop at itab.
write: itab-matnr.
endloop.
Or,
Try with inner join once.
Its working: Sample code.
data: begin of itab occurs 0,
matnr type matnr,
ernam type ernam,
end of itab.
select p~matnr q~ernam
into table itab
from mara as p
inner join mara as q
on p~brgew > q~ntgew.
loop at itab.
write: itab-matnr.
endloop.
Thanks,
Naveen.I -
Is there is any way to create a validator to compare two fields (like a pa
Hi,
Is there is any way to create a validator to compare two fields (like a password and a retype password ) ?
please give me any suggestion or any example related this problem!!
thanks,
Praveen SoniUgh, do you have taken over the LimitValidator and the JSF example (including the f:validateDoubleRange which is unnecessary in this case) literally without actually reading/interpreting/understanding it? No, then it is indeed not going to work. Basically you just need to define a validator in the one password field and pass the client ID of the another field as attribute along the one password field. In the validator you can retrieve the value of the another field by its client ID and finally just invoke String#equals() on the values of the both fields.
-
How to compare two fields from the same table in the select statement
Hi, friends
I try to compare tow fields from the same table, but no result,
For example, this
data: cptotchek tyep i.
select count(*) into cptotchek
from aufk where erdat = aufk-idat2 .
The result is cptotchek = 0, but there are the records in aufk , where, aufk-erdat = aufk-idat2.
Please, help me, i don't use the loop statement for optimize my program.
RegardsHi ,
it will not return any value when you are using column of same table
such as Date Field , Because while Using Aggregate Function it will not check with self column
. For that you have to take data in one internal table and then you can work on it .
And if you are worried about Performance it will not affect , untill you are selecting only required data .
you can try this way .
data: cptotchek type i.
types : begin of w_aufk.
include structure aufk .
types : end of w_aufk .
data : it_aufk type standard table of w_aufk with header line .
select * into corresponding fields of table it_aufk
from aufk .
loop at it_aufk .
if it_aufk-erdat = it_aufk-idat2 .
write : / it_aufk-erdat , it_aufk-idat2 .
else .
delete it_aufk .
endif .
endloop.
Regards
Deepak. -
How to compare two fields in two seperate databases
Hi
Can we compare two columns in two separate databases with a one script.
Cheers
ShabarHi,
if you mean Oracle to sqlserver then you would have to put hand in pocket and buy ODBC connectivity for this...
If it is just a one off maybe export your data and import into Oracle table and do your one off comparision.
regards,
Robert. -
Hi Experts,
I want to compare two characteristics in bex. Is it possible to do in BEx ? If yes, how can i do it.
If char A is equal to char B, display value of this key figure other wise display value of this key figure.Hi
try this out:
1) create 2 variables with Processing Type : Replacement Path and select the charc required.
2) create 2 formula key figs. taking values from 2 diff. variables.
3) include the variables into the formula key figs. created above respct. and the compare them.
Hope it will resolve ur issue.
Thanks,
Jitender
Edited by: Jitenderkumar Danduvia on Mar 13, 2010 7:49 AM -
How to compare two fields in condition editor in receiver determination
Hello,
Is it possible to compare to fields frrom the source in the condition editor of Receiver Determination?
Because on the right hand operand we can specify only constants right and not the source field.
For eg: If field1 != field2 then Reciever = Receiver1
Thanks,
LoveenaIn standard receiver determination while defining the condition, you can only specify an element from the message payload using expression editor to create an expression for the left operand and you must specify a fixed value in the right operand, against which the value of the element will be compared at runtime. You can use only these (=,, ,EX) operators. So the functionalities are limited.
so you have to use Enhanced Receiver Determination, In this Instead of creating the receivers in the receiver determination manually, you assign an Interface mapping to the receiver determination and this returns a list of receivers at runtime.
refer this wiki for more details
http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=133562771 -
Form to compare two fields ... cast needed?
Hi all gurus,
I'm rebuilding a report that performs a lot of checks by comparing fields of two different structures.
Basically, the check has a structure that is repeated over and over in many check: it looks like this:
IF srm_items-{field1} NE r3_services-{field2}.
t_temp-prezzi_errati = icon_red_light.
t_temp-error_code = '{errorcode}'.
IF counter_s = 0.
PERFORM add_son_in_t_temp USING srm_items e_backend w_obj-posting_date w_obj-changed_at.
ELSE.
PERFORM add_additional_error_temp USING srm_items 0.
ENDIF.
counter_s = counter_s + 1.
fl_errore_s = 'X'.
I was thinking to create a form, say 'check_son', that takes as USING parameter , and . My doubt is about types ad casts; in a check, could be a text string, in another a number, in another again a guid, and so on. Always simple field (no structures or complex field by now), but for what that concerns my FORM:
FORM check_son USING compare1
compare2
errorcode.
how should I declare the form in order to have the check working? I mean, I'd like that compare1 and compare2 get the same TYPE of the parameter I pass.. Is there a way? Or implicitly the params are converted into text (this should not work for me)?
Thanks in advance>
Matteo Montalto wrote:
> I don't know macros
Hi, Matteo
Test the following Sample Code it will help you to understand the working of Macros.
DEFINE check_son.
if &1 NE &2. " If Field1 Not Equal Field2
&3 = 'NE'. " In This Variable it will Return Error Code NE for Not Equal and EQ for Equal
else.
&3 = 'EQ'.
endif.
END-OF-DEFINITION.
DEFINE write_message.
if &1 = 'EQ'.
write: 'Two Numbers are Equal', /.
else.
write: 'Two Numbers are Not Equal', /.
endif.
END-OF-DEFINITION.
DATA: f1 TYPE i,
f2 TYPE i,
error_code(2).
f1 = 10. f2 = 15.
check_son f1 f2 error_code.
write_message error_code.
f1 = 10. f2 = 10.
check_son f1 f2 error_code.
write_message error_code.
Please Reply if any Confusion,
Best Regards,
Faisal -
How to compare two fields from different list sharepoint designer?
hi All,
I need to add a value to a field using SharePoint designer workflow. The value is from another column.
for example list A has the field has loginID, and another list B has loginID amd another column called Desig.
i need to compare both and get the Desig field and store it to a column. how do i do that in sharePoint Designer workflow.Hi,
you can create a workflow variable ex.Test. and add an action set Workflow variable. Then you have to set this variable value using lookUps. something like(in look up window)
Data source: Choose List B
Field from source: Choose Desig
Then under find the list item
Field: Choose login Id
Value :(Again open lookup window by clicking "fx") and in this window choose
data Source: List A
field from source :LoginId
and click ok.
attached is the image for your reference. (I am using other lists,you can change appropriately ) -
How to compare two fields from two different groups
My RTF template is like this.
GROUP A
Field 1 Field 2 Field 3 (Display in table)
GROUP B
**Condition
Display Fields from B
end GROUP B
end GROUP A
But I need the following condition to be added at the place (** Condition)
IF A.Field1 = B.Field1
Display fields from B
END IF
end Group B
end Group A
Please help, if anyone has come across such a situation.
Thanks,
AnandYou can use variables to store the A.field1 value and then compare it against B.Field1.
Take a look at this post for an example: https://blogs.oracle.com/xmlpublisher/entry/formatting_concatenated_dataso
Thanks,
Bipuser -
Need to compare two fields and populate the other fields.
Hi All,
I have scenario like this.
DATA: text1(150) type C
VALUE 'Step: SHORT DUMP; Scenario: PRE; Date :09.07.2007. Time :13:08:33.'.
DATA: text2(150) TYPE C
VALUE 'Step: &; Scenario: &; &',
DATA: text_A(150) TYPE C,
text_B(150) TYPE C,
text_C(150) TYPE C.
Now I need to compare text1 and text2 and populate text_A, text_B and text_C as follows.
text_A = SHORT DUMP
text_B = PRE
text_C = Date :09.07.2007. Time :13:08:33.
Basically I need to fill text_A, text_A and text_A with the values in text1 which are replaced by '&'.
Can anyone suggest me a code snippet to do it?
Thanks in advance.
Regards
AnkitSorry for slow response - I'm in a different timezone I think... Well it's not a short algorithm, but you could try something like the following (there's probably a sweeter algorithm, but this is what occured to me overnight)... I realise that it's not foolproof as you could have words substituted in for the "&" that also appear in the original message text and that would skew the results...
Jonathan
report zlocal_jc_get_msgvars.
types:
gty_char150(150) type c.
parameters:
p_text_1 type gty_char150 lower case,
p_text_2 type gty_char150 lower case.
initialization.
perform initialization.
start-of-selection.
perform extract_msgv.
*& Form initialization
form initialization.
*" Default screen variables
concatenate
'Step: SHORT DUMP; Scenario: PRE;'
'Date :09.07.2007. Time :13:08:33.'
into p_text_1 separated by space.
p_text_2 = 'Step: &; Scenario: &; &'.
endform. "initialization
*& Form extract_msgv
form extract_msgv.
*" Work out the values that have been substituted
*" into p_text2 to make p_text1
data:
l_text_a type gty_char150,
l_text_b type gty_char150,
l_text_c type gty_char150,
l_text_d type gty_char150,
l_tabix_1 type i,
l_tabix_2 type i,
l_word_1 type gty_char150,
lt_word_1 type gty_char150 occurs 10,
l_word_2 type gty_char150,
lt_word_2 type gty_char150 occurs 10,
l_result type gty_char150,
l_tabix type sy-tabix,
l_tabix_next type sy-tabix,
l_tabix_from type sy-tabix,
l_tabix_to type sy-tabix,
lt_tabix type sy-tabix occurs 4,
lt_result type gty_char150 occurs 10.
*" Break the strings into words
split p_text_1 at space into table lt_word_1.
split p_text_2 at space into table lt_word_2.
format reset.
format color col_total.
write: / p_text_1(80).
write: / p_text_2(80).
format reset.
*" Look at where the words in the shorter string appear in the longer
loop at lt_word_2 into l_word_2.
add 1 to l_tabix_2.
write: / 'P_TEXT_2, Word', l_tabix_2, l_word_2.
if l_word_2+0(1) = '&'. "placemarker
continue.
endif.
*" examine the expanded version
read table lt_word_1 into l_word_1
with key = l_word_2.
if not sy-subrc is initial.
write: /
'ERROR: Word not found in expanded version' color col_negative.
continue.
endif.
l_tabix_1 = sy-tabix. "Where we found word from short msg
append l_tabix_1 to lt_tabix.
endloop.
*" add pointer to end of list of words too
describe table lt_word_1 lines l_tabix_1.
add 1 to l_tabix_1. "because we subtract 1 below...
append l_tabix_1 to lt_tabix.
loop at lt_tabix into l_tabix_from.
l_tabix = sy-tabix.
write: / l_tabix_from.
*" get the range of words we want by getting next tabix row
*" and subtracting 1
l_tabix_next = l_tabix.
add 1 to l_tabix_next.
read table lt_tabix into l_tabix_to index l_tabix_next.
if not sy-subrc is initial. "no more words...
exit.
endif.
add 1 to l_tabix_from.
subtract 1 from l_tabix_to.
loop at lt_word_1 into l_word_1
from l_tabix_from to l_tabix_to.
write: / l_word_1 color col_positive.
* Push into text_A, text_B, text_C, text_D
case l_tabix.
when 1.
concatenate l_text_A l_word_1 into l_text_a
separated by space.
when 2.
concatenate l_text_b l_word_1 into l_text_b
separated by space.
when 3.
concatenate l_text_c l_word_1 into l_text_c
separated by space.
when 4.
concatenate l_text_d l_word_1 into l_text_d
separated by space.
endcase.
endloop.
endloop.
uline.
format reset.
format color col_group.
write: / 'TEXT_A', l_text_a(80).
write: / 'TEXT_B', l_text_b(80).
write: / 'TEXT_C', l_text_c(80).
write: / 'TEXT_D', l_text_d(80).
format reset.
endform. "extract_msgv -
Compare two fields and populate a third
I am trying to do the following:
Filed A number of days leave left
Field B Total number of days requested (some of other Fields)
Field C = A - B
Field D = Listed number of days unpaid to be taken
If C < 0 then D = C
I am using the following code
// Get the field values, as numbers
var v1 = this.getField("leaveleft").value;
var v2 = this.getField("totaldaysrequested").value;
var v3 = this.getField("daysleft").value;
var v4 = this.getField("unpaiddays").value;
if (v2 < "0") v4 = v3;
unpaiddays.value = v4.value;
This is not populating the field, what am i doing wrong?Assuming this is the calculation script for "unpaiddays", use this code instead of what you have now:
var v1 = +this.getField("daysleft").value;
event.value = (v1<0) ? v1 : ""; -
How to compare the two field in jasper report design
hi to all,
I am new to jasper report design
I want to compare two fields (or) variable using if..else condition.
pls help me outCheck out these postings:
http://forum.java.sun.com/thread.jspa?threadID=5286462
http://forum.java.sun.com/thread.jspa?threadID=5286468 -
REGEXP_ compare two tokenized strings
Hi,
I need to compare two fields (from two tables), to see if any of the tokenized contents match.
I have two tables with a "name" field, but the names might be incomplete or in random order. To get a match, I just need 1 part of both to really match, for example "John Doe" should match to "Doe J.".
Something like:
SELECT names1.name, names2.name
FROM names1, names2
WHERE INSTR(names1.name, REGEXP_SUBSTR(names2.name, '[[:alpha:]]+')) > 0
But the statement should consider all tokens, not just the first one as in the example.
Any suggestion on how to achieve this?
Thanks,
K.The performance of the regexp_instr in the where clause is terrible ... I stopped working out other scenarios, because the conclusion will be the same:
SQL> create table names1
2 as
3 select 1 id, 'John Doe' name from dual union all
4 select 2, 'Larry Ellison' from dual union all
5 select 3, 'Catharina-Amalia Beatrix Carmen Victoria van Oranje' from dual union all
6 select object_id, o
7 from ( select object_id
8 , owner || object_name o
9 , ntile(200) over (order by object_id) nt
10 from all_objects
11 )
12 where nt = 11
13 /
Tabel is aangemaakt.
SQL> create table names2
2 as
3 select 1001 id, 'Doe J.' name from dual union all
4 select 1002, 'Gates Bill' from dual union all
5 select 1003, 'Beatrix Wilhelmina Armgard van Oranje' from dual union all
6 select object_id, o
7 from ( select object_id
8 , owner || object_name o
9 , ntile(200) over (order by object_id) nt
10 from all_objects
11 )
12 where nt = 22
13 /
Tabel is aangemaakt.
SQL> select count(*) from names1
2 /
COUNT(*)
241
1 rij is geselecteerd.
SQL> select count(*) from names2
2 /
COUNT(*)
241
1 rij is geselecteerd.
SQL> exec dbms_stats.gather_table_stats(user,'names1')
PL/SQL-procedure is geslaagd.
SQL> exec dbms_stats.gather_table_stats(user,'names2')
PL/SQL-procedure is geslaagd.
SQL> set timing on
SQL> set autotrace on
SQL> select distinct n1.original_name name1
2 , n2.original_name name2
3 from ( select id
4 , name
5 , original_name
6 from names1
7 model
8 return updated rows
9 partition by (id)
10 dimension by (0 i)
11 measures (' ' || name || ' ' name, cast(null as varchar2(100)) original_name)
12 rules iterate (100) until (iteration_number = length(regexp_replace(name[0],'[^ ]')) - 2)
13 ( name[iteration_number+1] = regexp_substr(name[0],'[^ ]+',1,iteration_number+1)
14 , original_name[iteration_number+1] = trim(name[0])
15 )
16 ) n1
17 , ( select id
18 , name
19 , original_name
20 from names2
21 model
22 return updated rows
23 partition by (id)
24 dimension by (0 i)
25 measures (' ' || name || ' ' name, cast(null as varchar2(100)) original_name)
26 rules iterate (100) until (iteration_number = length(regexp_replace(name[0],'[^ ]')) - 2)
27 ( name[iteration_number+1] = regexp_substr(name[0],'[^ ]+',1,iteration_number+1)
28 , original_name[iteration_number+1] = trim(name[0])
29 )
30 ) n2
31 where n1.name = n2.name
32 /
NAME1
NAME2
Catharina-Amalia Beatrix Carmen Victoria van Oranje
Beatrix Wilhelmina Armgard van Oranje
John Doe
Doe J.
2 rijen zijn geselecteerd.
Verstreken: 00:00:00.07
Uitvoeringspan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=8 Card=581 Bytes=987
70)
1 0 SORT (UNIQUE) (Cost=8 Card=581 Bytes=98770)
2 1 HASH JOIN (Cost=7 Card=581 Bytes=98770)
3 2 VIEW (Cost=3 Card=241 Bytes=20485)
4 3 BUFFER (SORT)
5 4 SQL MODEL (ORDERED FAST)
6 5 TABLE ACCESS (FULL) OF 'NAMES1' (TABLE) (Cost=3
Card=241 Bytes=5784)
7 2 VIEW (Cost=3 Card=241 Bytes=20485)
8 7 BUFFER (SORT)
9 8 SQL MODEL (ORDERED FAST)
10 9 TABLE ACCESS (FULL) OF 'NAMES2' (TABLE) (Cost=3
Card=241 Bytes=5784)
Statistics
387 recursive calls
0 db block gets
52 consistent gets
0 physical reads
0 redo size
590 bytes sent via SQL*Net to client
508 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
11 sorts (memory)
0 sorts (disk)
2 rows processed
SQL> select n1.name name1
2 , n2.name name2
3 from names1 n1
4 , names2 n2
5 where regexp_instr ( ' ' || n1.name || ' ', ' ' || replace( n2.name, ' ', ' | ' ) || ' ' ) > 0
6 /
NAME1 NAME2
John Doe Doe J.
Catharina-Amalia Beatrix Carmen Victoria van Oranje Beatrix Wilhelmina Armgard van Oranje
2 rijen zijn geselecteerd.
Verstreken: 00:00:46.54
Uitvoeringspan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=218 Card=2904 Bytes=
121968)
1 0 NESTED LOOPS (Cost=218 Card=2904 Bytes=121968)
2 1 TABLE ACCESS (FULL) OF 'NAMES1' (TABLE) (Cost=3 Card=241
Bytes=5061)
3 1 TABLE ACCESS (FULL) OF 'NAMES2' (TABLE) (Cost=1 Card=12
Bytes=252)
Statistics
1 recursive calls
0 db block gets
728 consistent gets
0 physical reads
0 redo size
590 bytes sent via SQL*Net to client
508 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processedRegards,
Rob.
Maybe you are looking for
-
Convert color PDF to Black in Acrobat 9
I have need that I have not been able to find an answer to. I have a fairly large color pdf (over 400 pages of drawings in color) and I would like to turn all the colors to black. Everything I have been able find in my research to do this has to do w
-
Firefox Crashes when opening PDF file with Acrobat 9.4 installed.
Everytime I attempt to open a PDF file, Firefox will crash. I have Adobe Reader 9.4 installled. This has been happening since 7/9/2010
-
Thread: Out of memory error
I'm running a program that reads a file of more than 20k lines. Each line of this file is being processed by a thread. Sometimes the program is being halted with the out of memory error. What can I do to solve this problem ? Is it better to change th
-
How to find out what are in my startup?
My macbook has only 2 GB but since it's already 4 years old, I don't want to spend any more money to increase its memory, I'm just going to use it until it dies and goes to Mac Heaven. This morning I checked the system memory and noticed that even wh
-
Preselect an option in html:select
Hey, I am implementing struts in my application. How do i preselect an option in <html:select> tag here is what i am doing but the option does not get preselected.. the collection below returns A, B , C etc.. <html:select property="accountClass" name