cancel
Showing results for 
Search instead for 
Did you mean: 

Start Routine code issues (How to copy and fill SOURCE_PACKAGE)

Former Member
0 Kudos

Hi,gurus here

I want to copy SOURCE_PACKAGE in start routine to another inner table and increase the inner table's fields.

But when I write the code like this "DATA ITAB4 TYPE tyt_SC_1." (Also Source_package is TYPE tyt_SC_1.)

The system reports an error as: E:Type "_TY_T_SC_1" is unknown

Another thing is how to fill Source_package via an inner table?

So how to make it up?

Or anybody can provide some sample codes like to copy Source_package to an inner table,increase some customized-fields in this inner table and then copy the inner table back to Source_package?

Thanks,for a lot.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Kindly define the DATA ITAB4 TYPE tyt_SC_1 after below statement.

DATA:

MONITOR_REC TYPE rstmonitor.

OR

TYPE tyt_SC_1 in the global section of the routine.

Former Member
0 Kudos

Hi, thanks.

If the structure of SOURCE_PACKAGE is different from inner table such as ITAB4.

How to fill SOURCE_PACKAGE via ITAB4?

Former Member
0 Kudos

Hi,

You are right. Structure of both Source Package and ITAB4 should be same. You need to define the

DATA ITAB4 TYPE tyt_SC_1. with in the class....endclass statement.

CLASS lcl_transform DEFINITION.

ENDCLASS.

or

CLASS lcl_transform IMPLEMENTATION.

ENDCLASS.

Former Member
0 Kudos

After defining the DATA ITAB4 type tyt_SC_1.

Please write the below statement

ITAB4 [ ] = SOURCE_PACKAGE [ ].

Which will copy all the data to ITAB4.

Edited by: Pradeepkdas on Oct 17, 2011 11:31 AM

Former Member
0 Kudos

Hi,

If you have all the data available in internal table itab and you want to change some values of source package which has got different structure than itab then you can simply manually loop on the source package and inside loop read the value of itab and then do the manual assignment of fields.

loop at source_package assigning <wa_package>.

read table itab into wa_itab with key key1= <wa_package>-key1.........

<wa_package>-field1 = wa_itab-field1 and so on.....

endloop.

you can do the manual assignment of fields inside the loop.

Regards,

Durgesh.

Former Member
0 Kudos

Hi,thanks.

Actually I want to enlarge the SOURCE_PACKAGE which means I want to append some additional records into SOURCE_PACKAGE.

eg:

SOURCE_PACKGE content

Material Sold_to quantity type Sales order ReceiptNO

mm01 100016 5 Market 100103 9004313

mm02 100017 6 Market 100103 9004314

mm03 100018 7 Market 100104 9004315

Now I have an inner table which content is

Material Sold_to quantity type

mm04 100016 4 Supply

mm05 100019 3 Supply

I want to insert the content of inner table to SOURCE_PACKAGE in spite of Sales order and ReceiptNO.

That means I want to realize the following content:

SOURCE_PACKAGE content

Material Sold_to quantity type Sales order ReceiptNo

mm01 100016 5 Market 100103 9004313

mm02 100017 6 Market 100103 9004314

mm03 100018 7 Market 100104 9004315

mm04 100016 4

mm05 100019 3

How to realize the intention in START ROUTINE by codes? Is that possible to "APPEND WA_ITAB TO SOURCE_PACKAGE" directly?

Former Member
0 Kudos

Hi,

This can be done through END ROUTINE. Try implementiong the logic in end routine.

Thanks,

Nagarjuna.

Former Member
0 Kudos

Yes it would work.

APPEND WA_ITAB TO SOURCE_PACKAGE

or

APPEND <Field_Symbol> TO SOURCE_PACKAGE

regards

Amandeep

0 Kudos

Hi Pradeep,

I tried implementing the code that you suggested to pull data from source package to an internal table.

However, although I have defined the Itab with the same structure as source package, still while checking, it says that the internal table has not been defined.

Could you help on this.

Regards,

Uday

Answers (1)

Answers (1)

Former Member
0 Kudos

HIi,

In the start routine, therer will be space immediately after the declaration tyt_SC_1 .

eg:

$*$ begin of global - insert your declaration only below this line -

... "insert your code here

*Declare Your internal table here like below***

DATA: it_data type STANDARD TABLE OF tys_SC_1,

wa_data type tys_SC_1,

wa_source_package type tys_SC_1.

*end OfDeclare Your internal table here like below***

$$ end of global - insert your declaration only before this line -

Later in the space whichs is listed below.

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

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

****Write your logic here like**

it_data[ ] = source_package[ ].

      • End OF logic***

If your internal tbale it_tab is different from Source package.

then you have loop at Source_package and populate your internal table...

Eg:

Loop at source_package into wa_source_package.

wa_data-field1 = wa_source_package-field1.

wa_data-field2 = wa_source_package-field2.

.....

......

wa_data-fieldn = wa_source_package-fieldn.

append wa_data to it_data.

clear: wa_data, wa-source_package.

endloop.

$$ end of routine - insert your code only before this line -

Regards,

Nanda.S

Former Member
0 Kudos

My one comment to Nanda's post is that I would put the table declaration in the "normal" section.

DATA: it_data type STANDARD TABLE OF tys_SC_1,

wa_data type tys_SC_1,

wa_source_package type tys_SC_1.

Because if you were to write a Transformation Rule or End Routine, you may get a warning that type_ty_s_SC_1 doesn't exist. Because it technically only exists in the start routine. It'll probably work but every time you'd modify the rule, it would tell you that that type doesn't exist.

-


And yes you can append lines to your internal table and then at the end I usually just say

SOURCE_PACKAGE = internal_table.

Which overwrites the original source package with the one I was play around with.