cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate same records based on From Date and To Date

Former Member
0 Kudos

Hi All,

I want to generate number of records based on my begin date and end date.I am loading data from data source to DSO. My DSO contains Begin Date and End Date. I want to create Date field in the DSO as key field which will generate number of records. For example if I have date range as 02/04/2011 --  02/14/2012. So in my DSO I want to see 10 records from 02/04,02/05,02/06 to 02/14 etc. Please suggest me the solution to implement in the routine.

Thanks

Ganesh Reddy.

Accepted Solutions (1)

Accepted Solutions (1)

Anand71
Active Contributor
0 Kudos

Hello,

Please try this:

Create a info object in DSO for number of records. Using routine in transformation, Pass the Begin Date and End Date in source field and using off set, get the value of days( Like 04 and 14)  in a predefine variable. Pass the difference of the predefine variable( Variable1 for 04 day and variable for 14 day) into the target field.

How to generate same records based on From Date and To Date'

Please change your description, it is confusing.

Thanks.

With regards,

Anand Kumar

Former Member
0 Kudos

Thanks Anand,

You are correct I have to create a date field in my DSO to get all generated dates between Beginning date and Return Date. But if you store days ( beginning & Return date ) into a variable I am not sure we get correct values or not.... In my example I suppose to get (02/04/2011 --  02/14/2012 ) 369 records and not sure if I use offset will work or not....

Please let me know if I am wrong with your logic.

Thanks

Ganesh Reddy.

Anand71
Active Contributor
0 Kudos

Hello,

Use standard  function module, just pass the date range( 02/04/2011 --  02/14/2012 ) to get number of days(369). If you have probelm take the help of ABAP developer.

Thanks.

WIth regards,

Anand Kumar

Former Member
0 Kudos

Thanks Anand,

Yes I am using the standard function module ( SCOV_TIME_DIFF_46B ). Which gives the difference of the days.

Please if you explore little bit more about your below statement will help full to finish my self.

"Pass the difference of the predefine variable( Variable1 for 04 day and variable for 14 day) into the target field."

Thanks again Anand

Ganesh Reddy.

Former Member
0 Kudos

Hi All,

Please some one correct my below End Routine Programme.

DATA: NO_DAYS TYPE I.

    LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

* Find the number of days between Begin Date and Return Date

      NO_DAYS = 0.

      CALL FUNCTION 'SCOV_TIME_DIFF_46B'

      EXPORTING

        IM_DATE1 = <RESULT_FIELDS>-/BIC/ODATE_FRM

        IM_DATE2 = <RESULT_FIELDS>-/BIC/ODATE_TO

*        IM_TIME1 =

*        IM_TIME2 =

      IMPORTING

        EX_DAYS  = NO_DAYS.

*        EX_TIME  = .

      DO NO_DAYS TIMES.

      <RESULT_FIELDS>-/BIC/PEMPL_RCD = /BIC/PEMPL_RCD.

      <RESULT_FIELDS>-/BIC/ODATE     = /BIC/ODATE_FRM.

      <RESULT_FIELDS>-/BIC/ODATE_FRM = /BIC/ODATE_FRM.

      <RESULT_FIELDS>-/BIC/ODATE_TO  = /BIC/ODATE_TO.

      <RESULT_FIELDS>-/BIC/ODATE_COM = /BIC/ODATE_COM.

      <RESULT_FIELDS>-/BIC/OABS_TYPE = /BIC/OABS_TYPE.

      <RESULT_FIELDS>-/BIC/COMMENTS  = /BIC/COMMENTS.

      <RESULT_FIELDS>-/BIC/ODESC     = /BIC/ODESC.

      <RESULT_FIELDS>-/BIC/ZDATEINDI = /BIC/ZDATEINDI.

      /BIC/ODATE_FRM + NO_DAYS.   " Incremental

     

      NO_DAYS = NO_DAYS - 1.

     

      ENDDO.

Appreciated your help.

Thanks

Ganesh Reddy.

Former Member
0 Kudos

Hi,

Small error in the below code

    LOOP AT SOURCE_PACKAGE ASSIGNING <SOURCE_FIELDS>.

    NO_DAYS = 0.

  BEG_DATE = <SOURCE_FIELDS>-/BIC/ODATE_FRM.

  CALL FUNCTION 'SCOV_TIME_DIFF_46B'

      EXPORTING

        IM_DATE1 = <SOURCE_FIELDS>-/BIC/ODATE_FRM

        IM_DATE2 = <SOURCE_FIELDS>-/BIC/ODATE_TO

*        IM_TIME1 =

*        IM_TIME2 =

      IMPORTING

        EX_DAYS  = NO_DAYS.

*        EX_TIME  = .

DO NO_DAYS TIMES.

  <SOURCE_FIELDS>-/BIC/ODATE = BEG_DATE.

  BEG_DATE = BEG_DATE + 1.

APPEND SOURCE_FIELDS TO SOURCE_PACKAGE.

  ENDDO.

ENDLOOP.

/BIC/ODATE doesn't contain in the my source but it exists in the target table. I have to assign generated  values to new field ( /BIC/ODATE ) in the target table.

Thanks

Ganesh Reddy.

Former Member
0 Kudos

   DATA: lv_date TYPE sy-datum,
      lt_resultpackage TYPE STANDARD TABLE OF _ty_s_tg_1.

LOOP AT result_package ASSIGNING <result_fields>.

  lv_date = <result_fields>-/bic/odate_frm.

  WHILE lv_date <= <result_fields>-/bic/odate_to.
    <result_fields>-/bic/odate     = lv_date.
    lv_date = lv_date + 1.
    APPEND <result_fields> TO lt_resultpackage.
  ENDWHILE.
ENDLOOP.

"Delete the curretn result_package completely
"and refresh it with the temporary resultpackage table
REFRESH result_package.
result_package[] = lt_resultpackage[].

Former Member
0 Kudos

Uday, You made it simple with easy logic. I was thinking with Function module.

Appreciate your help.

Thanks again

Ganesh Reddy.

Answers (0)