‎2014 Nov 20 10:16 AM
Hi Friends,
Can you please tell,how to compare two rows in a table.
In my table there are more than 10 fields,But i need to compare only PO number and item number.
If both po and item number matches with 2nd row records,then it must perform some validations.
Please tell how to compare these 2 rows.
my logic will be,if po number and item number are same with below records,then in description field it will check for occurence of space.
‎2014 Nov 20 10:30 AM
Hi Varun,
You can read your internal table using Index and check the ponumber and item number with IF statements.If it satisfies then you can perform necessary validations.
Read Table <IT> into <WA> index sy_index
if sy_subrc = 0.
Read table <it> into <WA1> index 2.
if sy-subrc = 0.
do PO and item checks here.If satisfies then,
do validations.
endif.
endif.
‎2014 Nov 20 10:37 AM
Yeah, agree with this. Need 'SORT' itab first, i think.
And, each row need do this validation?
regards,
Archer
‎2014 Nov 20 10:39 AM
Hi Varun,
SORT itab BY ebeln ebelp.
READ itab INTO wa INDEX 1.
lv_ebeln = wa-ebeln.
lv_ebelp = wa-ebelp.
LOOP AT itab INTO wa FROM 2.
IF lv_ebeln = wa-ebeln AND lv_ebelp = wa-ebelp.
**Do validation
ELSE.
lv_ebeln = wa-ebeln.
lv_ebelp = wa-ebelp.
ENDIF.
ENDLOOP.
Regards
Sreekanth
‎2014 Nov 20 10:49 AM
Hi Varun,
Sort the internal table on PO and ITEm number and then loop through it .
loop at itab1 into ls_itab1.
loop at itab1 into ls_itabb2 where po = ls_itab1-po and item = ls_itab1-item.
do validations.
endloop.
endloop.
Please check if this helps,
Thanks
Sri
‎2014 Nov 21 7:36 AM
Hi Varun,
Suppose your internal table is IT_EKPO.
1. Sort IT_EKPO by EBELN EBELP.
2. Loop at IT_EKPO into WA_EKPO.
LV_INDEX = SY-TABIX + 1.
Clear WA_EKPO1.
Read table IT_EKPO into WA_EKPO1 index lv_index.
If SY_SUBRC is initial and
( WA_EKPO-EBELN = WA_EKPO1-EBELN ) and
( WA_EKPO-EBELP = WA_EKPO1-EBELP).
** do your validations here
Endif.
Clear LV_INDEX.
Endloop.
Hope it helps!