cancel
Showing results for 
Search instead for 
Did you mean: 

Multiply records in the transformation

Former Member
0 Kudos

Hi,

I have DS sending records in following structure:

ItemCategoryGroup1Group2

itm1

cat1xx
itm2cat2x

I need to load data in the InfoObject with following structure:

Item          String

Category  String

Group       Int

And use following algorithm:

1) If Group1 is checked, make 1 record with Group = 1

2) If Group2 is checked, make 3 record with Groups in (2,3,4)

So from the input on top I would get following output:

ItemCategGroup
itm1cat11
itm1cat12
itm1cat13
itm1cat14
itm2cat11

I was about to load data to DSO first where I can have the Group<Int> field. Then use start routine to multiply records. Im just very new to ABAP and not sure if this could be the right way.

Thank you for advice.

Pavel

Accepted Solutions (0)

Answers (1)

Answers (1)

sander_vanwilligen
Active Contributor
0 Kudos

Hi Pavel,

I suggest to use the End Routine. Here you have the Characteristic Group available as part of the RESULT_PACKAGE. This is missing in the Start Routine.

Please review SAP Note 1223532 - Design rule: Addition of records to end routine.

Best regards,

Sander

Former Member
0 Kudos

Hi Sander,

Can I lookup Group checklist from the source in the End Routine?

Regarding they are not in the result (output DSO) structure.

Cheers,

Pavel

sander_vanwilligen
Active Contributor
0 Kudos

Hi Pavel,

My assumption was that the source Characteristics would also be available in the target structure. There are a few options how to proceed:

  1. Extend the target structure with Group1 and Group2 and use an End Routine;
  2. Use an Expert Routine where you have both source and target structure available *);
  3. Introduce an intermediate InfoSource with all source fields plus the new Group, use an End Routine in the first Transformation.

*) Please refer to SAP Note 1227667 - Guidelines for expert routine: Design rules for design rules.

A Start Routine will not work since it does not have the new Group.

Best regards,
Sander

Former Member
0 Kudos

Hi Sander,

I used DSO as middle structure and then used easy loop to load it there:

    data: new_record type _ty_s_TG_1,

          new_records_t type table of _ty_s_TG_1.

    loop at RESULT_PACKAGE assigning <RESULT_FIELDS>.

      if <RESULT_FIELDS>-Group1 eq 'X'.

        new_record-Itm = <RESULT_FIELDS>-Itm.

        new_record-Cat = <RESULT_FIELDS>-Cat.

        new_record-Group = 1.

        append new_record to new_records_t.

      endif.

      if <RESULT_FIELDS>-Group2 eq 'X'..

        new_record-Group = 2.

        append new_record to new_records_t.

        new_record-Group = 3.

        append new_record to new_records_t.

        new_record-Group = 4.

        append new_record to new_records_t.

      endif.

    endloop.

    refresh RESULT_PACKAGE.

    RESULT_PACKAGE[] = new_records_t[].

    data: i type i.

    i = 0.

    loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

      i = i + 1.

      <RESULT_FIELDS>-record = i.

    endloop.

Thanks for help,

Pavel

sander_vanwilligen
Active Contributor
0 Kudos

Hi Pavel,

According to SAP Note 1223532 - Design rule: Addition of records to end routine you should use a different way to determine the record no. for a new record. Also the reference to the source record is recommended if the new record can be uniquely linked to one source record.

Best regards,

Sander