Skip to Content
Author's profile photo HITESH GAVANDE

Addition of new records to START or END routine

Dear All,

Many times there are sdn threads on issues while adding records to SOURCE_PACKAGE or ERSULT_PACKAGE.

This issue causes because while adding new records to SOURCE or RESULT Package, we need to add “Record Number” field in addition to other fields which we want  to add to result package.

There are two ways to resolve this issue:

Way-1) add record number manually to SOURCE or RESULT package.

Way-2) Call standard method provided by SAP .

Way-1) Update record number manually which inserting new records:

            In this way, we need to manually populate record number & then increment it manually while adding records to source/result package.

             Example: Suppose based on some condition in internal table IT_TAB1, we need to add records to result package.

            Step-1) First declare integer type of variable.

                         ex. DATA: lv_record_count TYPE I.

            Step-2) Populate records of result_package, this is start counter for our declared variable.

                         DESCRIBE TABLE RESULT_PACKAGE LINES lv_record_count.

                        This line will populate total number of records in RESULT_PACKAGE, for ex. in result_package we have 100 records then after                                               executing above ABAP statement , we will have 100 integer value inside variable lv_record_count.


             Step-3) Just increment this counter for each record while inserting new record in SOURCE/RESULT package.


                        LOOP AT IT_TAB1 ASSIGNING <FS_1>  WHERE <condition>.

                           <———- ABAP Syntax ———————>

                         lv_record_count = lv_record_count + 1.

                         <FS_1>-record = lv_recod_count.

                         APPEND <FS_1> TO RESULT_PACKAGE.


Way-2) Update record number using SAP method while inserting new records.

             <considering same scenario as of above>

            This way is more feasible and preferable, as provided by SAP.

               SAP provided method which populates record number automatically.



                        LOOP AT IT_TAB1 ASSIGNING <FS_1>  WHERE <condition>.


                           <———- ABAP Syntax ———————>

                         CALL METHOD me->new_record__end_routine. 


                                      source_segid = 1

                                      source_record = 0


                                       record_new = <result_fields>-record.

                                 “”  This method automatically populates record number, we just need to import new record number populated by this method. 



SNOTE: 1223532 DEsign Rule: Addition of records to end routine

**************************** Thanks for your Time 🙂   ************************************** 

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sudnya Shah
      Sudnya Shah

      Thanks for Sharing! Really Helpful 🙂