cancel
Showing results for 
Search instead for 
Did you mean: 

Start and End Routines Query

Former Member
0 Kudos

Hello, I have built an internal table in my start routine and now i want to use it in my end routine so i can pick up the values and assign them to my fields in transformation. can someone tell me if this is possible?

thanks.

Accepted Solutions (1)

Accepted Solutions (1)

anshu_lilhori
Active Contributor
0 Kudos

You can declare the Internal table globally in start routine as stated by vinod and then you can read the same table in end routine.

Suppose the internal table declared is ITAB.

In end routine the syntax would be:


loop at RESULT_PACKAGE assigning <result_fields>.

Read table itab into wa with key

Hope this gives an idea.

Regards,

AL

Former Member
0 Kudos

AL, thanks, but i don't think reading with in a loop would help the performance. what do you think?

former_member976
Active Contributor
0 Kudos

Hi,

if you use the one LOOP it will improve the performance if you write the end routine.

loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS> .
     READ TABLE IT_XXXX into LS_XXXX WITH KEY XXXXX =
     <RESULT_FIELDS>-XXXXX. and DATE TO = 31.12.9999.


if you write the start routine it will read the record by record and end routine read packet by packet.


Thanks,

Phani.

anshu_lilhori
Active Contributor
0 Kudos

Please share the code so that we can give some inputs on the same.

It all depends on the requirement.Normally Select statement inside the loop degrade performance.

Make sure to use internal table type hashed if not then sorted instead of standard table.

Regards,

AL

anshu_lilhori
Active Contributor
0 Kudos
if you write the start routine it will read the record by record and end routine read packet by packet.

In Start routine also it reads package by package only.In case of field level routine data will be read record by record.

Regards,

AL

former_member976
Active Contributor
0 Kudos

HI Anshu,

i agree with you.

i miss used.

field level routine- record by record.

start and end routine - package by package.

former_member182346
Active Contributor
0 Kudos

Reading inside loop is the best option as far as performance is concern.

Add : once internal table filled with data, sort it with the key which you are going to use in read and then use binary search.

This will further improve the performance.

So if your read statement is

Read table ITAB with Key Field1 = 'xyz'.

Sort the ITAB after select statement in global declaration as

Sort table ITAB ascending field1.

and replace the read statement as :

Read table ITAB with Key Field1 = 'xyz' BINARY SEARCH.

Thank-You.

Regards,

VB

Former Member
0 Kudos

Hello, I decided to go for start routine, i want to use hash tables as they are good with performance. but i dont know how to do the loop on hash tables. i want to have 2 internal tables ok so the first one will have the source package data then i want to use my logic and send it to second internal table, once i get the data in second internal table then i want to read from it at the field level but my question is how to do the loop from one internal table to another. can you help me with that?

This is what I have written so far in my start routine:

    SELECT
CUSTOMER
/BIC/ZADDR1
/BIC/ZADDR2
/BIC/ZADDR3

        INTO TABLE ITAB1 FROM
        /BIC/AZMAN_CUS

      FOR ALL ENTRIES IN SOURCE_PACKAGE

      WHERE MATERIAL = SOURCE_PACKAGE-CUSTOMER.

    SORT ITAB1 BY MATERIAL /BIC/ZCLSCHAR.

now i want to do a loop and put this data in to itab2 which has a different structure, so how do i do that?

thanks.

former_member182346
Active Contributor
0 Kudos

Loop at ITAB1.

Itab2-filed1 = itab1-field1

Append itab2.

End Loop.

Answers (2)

Answers (2)

Former Member
0 Kudos

Agreed with Vinod.

When you will go to start routine -> scroll up and you will find the global data declaration. This is common for all the routines (start, field, end). So ideally you will have to declare your table in this section and it will be accessible in all the routines.

Thanks

Amit

former_member182346
Active Contributor
0 Kudos

Hi,

Go on the top section of start routine, you will find the global decleration part.

like :

*$*$ begin of global - insert your declaration only below this line  *-*
    ... "insert your code here

< Inser your table declaration and even select statement.

Same will be avaialble in end routine.

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

Thank-You.

Regards,

VB