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

Sequence

Former Member
0 Likes
762

Hi,

May I know how can I do this in more efficient way?

let say i have :

sales order pos seq

00010 10 1

00010 10 2

00010 10 3

00020 10 1 -> this line to be removed because seq = 1, and there is no following seq for this sales order+pos.

00040 10 1

Will reward points if the answer helps. Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
739

Try this..

DATA: v_int TYPE i.

DATA: v_tabix TYPE SYTABIX.

SORT ITAB BY vbeln pos seq.

LOOP AT ITAB INTO WA.

V_TABIX = SY-TABIX.

CLEAR: v_int, wa_tmp. [WA_TMP IS WORKAREA FOE INTERNAL TABLE ]

LOOP AT ITAB INTO wa_tmp WHERE vbeln = wa-vbeln AND pos = wa-pos.

V_INT = V_INT + 1.

ENDLOOP.

IF V_INT = 1 AND WA_TMP-SEQ = 1.

DELETE ITAB INDEX V_INDEX.

ENDIF.

ENDLOOP.

If helpful reward some points.

with regards,

suresh

5 REPLIES 5
Read only

Former Member
0 Likes
739

Hi,

Try this..



DATA: v_int TYPE i.
DATA: v_tabix TYPE SYTABIX.

SORT ITAB BY vbeln pos seq.

* process the internal table.
LOOP AT ITAB IN WA.

* row number
  V_TABIX = SY-TABIX.

* Clear
  CLEAR: v_int, wa_tmp.

* Get the count.
  LOOP AT ITAB INTO wa_tmp WHERE vbeln = wa-vbeln AND pos = wa-pos.
     V_INT = V_INT + 1.
  ENDLOOP.

* Check the count and WA_TMP = 1.
  IF V_INT = 1 AND WA_TMP-SEQ = 1.

* Delete that record.
    DELETE ITAB INDEX V_INDEX.
  ENDIF.

ENDLOOP.

Thanks,

Naren

Read only

Former Member
0 Likes
739

Hi,

loop at itab.

l_tabix = sy-tabix.

if itab-seq = 1.

read itab with key sales order, pos seq =2

if sy-subrc NE 0.

delete itab index l_tabix

endif.

endif.

endloop.

Reward points if useful.

Regards,

Atish

Read only

Former Member
0 Likes
739

Hi

You can try this way.

Loop at itab.

at new sorder.

read itab index sy-tabix.

lf_sorder = itab-sorder.

lf_seq_flg = 'X'.

endat.

if lf_sorder NE itab-sorder.

clear lf_seq_flg.

lf_del_index = sy-tabix - 1.

delete itab index lf_del_index.

endif.

endloop.

Regards

Raj

Read only

Former Member
0 Likes
739

Hi

Do Like This............

it2[] = it1[].

loop at it2.

n = it2-seq.

read table it1 with key sales_order = it2-sales_order

pos = it2-pos

seq = it2-seq.

if sy-subrc = 0.

n = n + 1.

read table it2 with key sales_order = it2-sales_order

pos = it2-pos

seq = n.

if sy-subrc = 0.

move this to your final table.(entry existing)

move-corresponding it1 to it_final.

else.

endif

endif.

clear n.

endloop.

Reward All Helpfull answers........

Read only

Former Member
0 Likes
740

Try this..

DATA: v_int TYPE i.

DATA: v_tabix TYPE SYTABIX.

SORT ITAB BY vbeln pos seq.

LOOP AT ITAB INTO WA.

V_TABIX = SY-TABIX.

CLEAR: v_int, wa_tmp. [WA_TMP IS WORKAREA FOE INTERNAL TABLE ]

LOOP AT ITAB INTO wa_tmp WHERE vbeln = wa-vbeln AND pos = wa-pos.

V_INT = V_INT + 1.

ENDLOOP.

IF V_INT = 1 AND WA_TMP-SEQ = 1.

DELETE ITAB INDEX V_INDEX.

ENDIF.

ENDLOOP.

If helpful reward some points.

with regards,

suresh