2009 Apr 17 2:52 AM
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
2009 Apr 17 4:12 AM
Try this way
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.
DATA: wa_it_vbeln_temp 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.
read table it_vbeln into wa_it_vbeln_temp with key "<<<<<<<<<
wa_it_vbeln_temp-plant = <RESULT_FIELDS>-PLANT
wa_it_vbeln_temp-subgrp = <RESULT_FIELDS>-/BIC/ZSUBGROUP
wa_it_vbeln_temp-lprio = <RESULT_FIELDS>-WM_PRIO
wa_it_vbeln_temp-vbeln = <RESULT_FIELDS>-DELIV_NUMB..
if sy-subrc > 0.
append wa_it_vbeln TO it_vbeln..
clear wa_it_vbeln.
endif.
ENDLOOP.
a®
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
2009 Apr 17 4:12 AM
Try this way
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.
DATA: wa_it_vbeln_temp 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.
read table it_vbeln into wa_it_vbeln_temp with key "<<<<<<<<<
wa_it_vbeln_temp-plant = <RESULT_FIELDS>-PLANT
wa_it_vbeln_temp-subgrp = <RESULT_FIELDS>-/BIC/ZSUBGROUP
wa_it_vbeln_temp-lprio = <RESULT_FIELDS>-WM_PRIO
wa_it_vbeln_temp-vbeln = <RESULT_FIELDS>-DELIV_NUMB..
if sy-subrc > 0.
append wa_it_vbeln TO it_vbeln..
clear wa_it_vbeln.
endif.
ENDLOOP.
a®
2009 Apr 17 4:17 AM
I tried that and I still got short dump.
My code was that I commented out.:
DATA: st_it_vbeln LIKE LINE OF it_vbeln.
read table it_vbeln into st_it_vbeln
with table key
plant = <RESULT_FIELDS>-PLANT
subgrp = <RESULT_FIELDS>-/BIC/ZSUBGROUP
lprio = <RESULT_FIELDS>-WM_PRIO
vbeln = <RESULT_FIELDS>-DELIV_NUMB.
Arggg.
Mike
Edited by: Michael Hill on Apr 17, 2009 5:18 AM
2009 Apr 17 4:30 AM
Something with UNIQUE KEY , remove it and use SORT
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 ty_vbeln
sort it_vbeln by plant subgrp lprio vbeln.
DATA: wa_it_vbeln LIKE LINE OF it_vbeln.
DATA: wa_it_vbeln_temp 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.
read table it_vbeln into wa_it_vbeln_temp with key "<<<<<<<<<
wa_it_vbeln_temp-plant = <RESULT_FIELDS>-PLANT
wa_it_vbeln_temp-subgrp = <RESULT_FIELDS>-/BIC/ZSUBGROUP
wa_it_vbeln_temp-lprio = <RESULT_FIELDS>-WM_PRIO
wa_it_vbeln_temp-vbeln = <RESULT_FIELDS>-DELIV_NUMB..
if sy-subrc > 0.
append wa_it_vbeln TO it_vbeln..
clear wa_it_vbeln.
endif.
ENDLOOP.
a®
2009 Apr 17 4:33 AM
you have specified unique keys plant, subgrp, lprio, vblen
DATA: it_vbeln TYPE SORTED TABLE OF ty_vbeln WITH UNIQUE KEY plant
subgrp lprio vbeln.
if you try to append data with these keys and a record exists with similar keys to the table you will get this error.
My Suggestion Increase number of keys in the it_vbeln table.
2009 Apr 17 4:37 AM
I don't need any other fields there, just those and I want unique records.
I was hoping to be able to trap that error that the key already exists and simply skip it.
Not possible?
Mike
2009 Apr 17 4:19 AM
Hi,
Your code:
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.Over here yo want to check for equality right? So, change it to:
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
READ TABLE it_vbeln WITH TABLE KEY
plant = <RESULT_FIELDS>-PLANT
subgrp = <RESULT_FIELDS>-/BIC/ZSUBGROUP
lprio = <RESULT_FIELDS>-WM_PRIO
vbeln = <RESULT_FIELDS>-DELIV_NUMB TRANSPORTING NO FIELDS.
IF SY-SUBRC NE 0.
append wa_it_vbeln TO it_vbeln..
clear wa_it_vbeln.
endif.
ENDLOOP.Regards,
Lim...
Edited by: Ruslim Chang on Apr 17, 2009 5:32 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |