Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

append error where entry already exists

I am adding line to this table and and getting an short dump about the items already existing.

TYPES: BEGIN OF ty_vbeln,

plant TYPE /BI0/OIPLANT,

subgrp TYPE /BIC/OIZSUBGROUP,

lprio TYPE /BI0/OIWM_PRIO,

vbeln TYPE /BI0/OIDELIV_NUMB,

END OF ty_vbeln.

DATA: it_vbeln TYPE SORTED TABLE OF ty_vbeln WITH UNIQUE KEY plant

subgrp lprio vbeln.

DATA: wa_it_vbeln LIKE LINE OF it_vbeln.

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

wa_it_vbeln-plant = <RESULT_FIELDS>-PLANT.

wa_it_vbeln-subgrp = <RESULT_FIELDS>-/BIC/ZSUBGROUP.

wa_it_vbeln-lprio = <RESULT_FIELDS>-WM_PRIO.

wa_it_vbeln-vbeln = <RESULT_FIELDS>-DELIV_NUMB.

if sy-subrc > 0. " the fields are not in the table so add them

append wa_it_vbeln TO it_vbeln..

clear wa_it_vbeln.

endif.

ENDLOOP.

So I somehow need to capture the error so my pgm doesnt short dump.

What I ultimatly want is a table that I can find the unique number of vbelns.

So if my table looks like:

aaa 8 003 80008361

aaa 8 003 80008362

bbb 8 003 80009361

if I look up 80008361 I will 2.

if I look up 80008362 I will 2.

if I look up 80009361 I will 1.

Any help is appreciated.

Mike

Former Member
Not what you were looking for? View more on this topic or Ask a question