Sie sind auf Seite 1von 5

Changing source_package

1 of 5

https://archive.sap.com/discussions/thread/3290474

10/31/2016 6:58 PM

Changing source_package

2 of 5

https://archive.sap.com/discussions/thread/3290474

This question is answered

Hi,
I have a DSO with materials and seasons:
0material
0af_sean
material and season are keys but I can have one material with different seasons
Goal: Create a new DSO with a unique material and season where season is selected by the smallest one,
I mean:
Material

| Season

121323

|4

121323

|1

345234

|2

985645

|3

345234

|5

Result will be:


Material

| Season

121323

|1

345234

|2

985645

|3

So, I have created this ABAP in Start routine


*$*$ begin of 2nd part global - insert your code only below this line *
TYPES: Begin of T_temp,
MATNR TYPE C LENGTH 18,
SAISO TYPE C LENGTH 4,

10/31/2016 6:58 PM

Changing source_package

3 of 5

https://archive.sap.com/discussions/thread/3290474

SAISO TYPE C LENGTH 4,


END OF T_temp.

DATA: iT_temp TYPE standard table of T_temp, wa_temp like line of iT_temp.

*$*$ begin of routine - insert your code only below this line

*-*

data: wa_SOURCE_PACKAGE type _ty_s_SC_1.


DATA: ITAB type STANDARD TABLE OF _ty_s_SC_1.
* Delete duplicate data from source package
ITAB = SOURCE_PACKAGE[].
SORT ITAB BY MATERIAL AF_SIZE AF_SEAN DESCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATERIAL AF_SIZE AF_SEAN.

clear SOURCE_PACKAGE.

SOURCE_PACKAGE[] = ITAB[].
LOOP AT SOURCE_PACKAGE into wa_SOURCE_PACKAGE.
if wa_SOURCE_PACKAGE-MATERIAL is not initial.
move wa_SOURCE_PACKAGE-MATERIAL to wa_temp-MATNR.
move wa_SOURCE_PACKAGE-AF_SEAN to wa_temp-SAISO.

append wa_temp TO iT_temp.


endif.
ENDLOOP.
In the Field routine for Season I have:
sort iT_temp by saiso.
read table iT_temp into wa_temp with key matnr = SOURCE_FIELDS-MATERIAL.
if sy-subrc = 0.
RESULT = wa_temp-saiso.
endif.
This results in a really bad performance process, can it be optimized? I am not a guru in ABAP, so I am
asking for help.
I even don't know if it works, 'cause I can have the same material with different seasons in two or more
different packages (source_package), right?

10/31/2016 6:58 PM

Changing source_package

4 of 5

https://archive.sap.com/discussions/thread/3290474

different packages (source_package), right?


Thank you

Paulo Prspero
January 09, 2013 at 17:51 PM
0 Likes

Correct Answer

Paulo Prspero

replied

January 17, 2013 at 12:38 PM

Hi,
I have solved this with this change in code:
SORT ITAB BY MATERIAL ASCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATERIAL AF_SEAN.

clear SOURCE_PACKAGE.

SOURCE_PACKAGE[] = ITAB[].
And by changing the DTP with Semantic Groups by MATERIAL
Thank you to all messages and suggestions
0

View this answer in context

10/31/2016 6:58 PM

Changing source_package

5 of 5

https://archive.sap.com/discussions/thread/3290474

Suyash Pandey

replied
January 10, 2013 at 00:59 AM

Don't write start routine go for field routine.


Like map material key and season from source into
season in target.
Then you can do a look up for each material in the
active table of source DSO by above logic and this way
you will have all your data for comparison.
Hope this is clear.
Cheers!
0

Donghoon Woo

replied January 10, 2013 at 03:28 AM

Hi, Paulo.
If you want a compact source code.
You can use following source code but you need some changes.
-----------------------------------------------*Material

| Season

*121323

|4

*121323

|1

*345234

|2

*985645

|3

*345234

|5

*
*Result will be:
*
*Material

| Season

*121323

|1

10/31/2016 6:58 PM