Skip to Content

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.

                        ENDLOOP.

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. 

                               EXPORTING

                                      source_segid = 1

                                      source_record = 0

                               IMPORTING

                                       record_new = <result_fields>-record.

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

                        ENDLOOP.

References:

http://scn.sap.com

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

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

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply