Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Comparing 2 rows

Former Member
0 Likes
2,321

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.

5 REPLIES 5
Read only

Former Member
0 Likes
1,141


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.

Read only

0 Likes
1,141

Yeah, agree with this. Need 'SORT' itab first, i think.

And, each row need do this validation?

regards,

Archer

Read only

former_member202818
Active Contributor
0 Likes
1,141

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

Read only

former_member191761
Active Participant
0 Likes
1,141

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

Read only

Former Member
0 Likes
1,141

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!