cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding Start routine and field routine

Former Member
0 Kudos

Hi ,

Please correct me if I am wrong .

1 below code will check the material details from it_material with the source mat_plant ,if it is not euqal then it will delete the all data in the source_package .

2 if we are doing declaration in the global part of the start routine then will it available across endroutine and field level routine .

READ TABLE it_material  INTO wa_material

         WITH KEY material = <source_fields>-mat_plant

         BINARY SEARCH.

       IF sy-subrc <> 0.

         DELETE SOURCE_PACKAGE.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ram,

As per your requirement, you want to delete the mat_plant which are not available into the it_material internal table.

Yes, if you will declare into the global area, it will available into the start/end/ and filed level routine.

But in the global area we are usually do declaration on variables, constants, and internal tables. And we select the data and insert into internal table in global part ,it will be available for read purpose in the start/end and fields level routine.

Based on your require please use below code,

Global part declaration,

DATA: it_source1 TYPE tyt_SC_1,

            wa_source1 type  tyt_SC_1,

              v_tabix type sy-tabix.

Hope you have filled the internal table it_material in global part.

in start routine area,

it_source1[] = SOURCE_PACKAGE[].

Loap it_source1 into wa_source1.

   

clear wa_material.

v_tabix - sy-tabix.

READ TABLE it_material  INTO wa_material

         WITH KEY material = wa_source1-mat_plant

         BINARY SEARCH.

       IF sy-subrc <> 0.

         DELETE it_source1 to wa_material index v_tabix.

         modify it_source1.

endloop.

SOURCE_PACKAGE[] = IT_SOURCE1.

Hope this will help.

Thanks,

Chandresh

Former Member
0 Kudos

Thanks chandresh I got a lot of information from your input .Could you please let me know what is the exact work of the below .

Will it delete whole source package if the if condition is satisfy .

READ TABLE it_material  INTO wa_material

         WITH KEY material = <source_fields>-mat_plant

         BINARY SEARCH.

       IF sy-subrc <> 0.

         DELETE SOURCE_PACKAGE

Thanks& regards

,

Former Member
0 Kudos

Hi ram,

yes, it will delete whole source_package... as you haven't apply any condition when you have written delete source_package.

If you check the code with i have posted, it will delete the row when material and mat_plant are not equal.

If you want any further info please let me know.

Thanks,

Chandresh

Former Member
0 Kudos

Hi,

For your Ref, hope you will get answers from this code by modification w.r.t your requirement.

DATA: IT_SOURCE1 LIKE SOURCE_PACKAGE.

FIELD-SYMBOLS: <FS_SOURCE> LIKE LINE OF SOURCE_PACKAGE.


IT_SOURCE1 = SOURCE_PACKAGE[].
     sort IT_SOURCE1 descending by PLANT MATERIAL PSTNG_DATE MOVETYPE.
     delete adjacent duplicates from IT_SOURCE1 comparing PLANT MATERIAL
     PSTNG_DATE MOVETYPE.


SOURCE_PACKAGE[] = IT_SOURCE1
    


Thanks & Regards,

Srinu.Rapolu

Former Member
0 Kudos

Thanks for the update srinu .

I want to know what is that code doing exactly ..

my assumption is correct or not .

Former Member
0 Kudos

Hi Ram,

Your assumption is correct. However just to add a few points here:

1. You will not have source_package in field or end routine as its declaration is autogenerated.

2. For it_material, wa_material if you have declared them in global declaration parts then it will be available in field and end routine.

Ideally we declare almost all data objects in global parts unless it is specifically used only in a particular routine. Then we populate data from start routine (in many cases) say we populate it_material with a look up on a table in relation to source package and this populated data of it_material is available in field and end routine both.

Let us know if there are any doubts.

Thanks

Amit

Former Member
0 Kudos

Thanks Amit . I got it .

delete sourse_package .means it will delete all the data in the source pakage .can you give some information for source package .It would be help full for me .

Regards,

surya

Former Member
0 Kudos

That is correct, if you write DELETE source_package it will delete all data from source_package. However this is usually done using another internal table.

Ideally source package have all the data from source of your transformation. For example, if you have a transformation from DSO1 to DSO2 then source pacakge will have all data of DSO1 and it is used in start routine in any cases where you want to manipluate the source data or select any look up data based on source data. Then in end routine you have result package data which is finally applied to your target i.e. DSO2. In endroutine the result pacakge can be already modified by field routine etc. so it is not truly a source data.

Conclusion is that you have source package in start routine and result package in end routine and global declared data in start,end and field routines.

Thanks

Amit