cancel
Showing results for 
Search instead for 
Did you mean: 

Routine in DTP

Former Member
0 Kudos

Hello Experts,

I need your help in programming a routine in a dtp.

I have a DSO and want to load this data into a Cube. But I just want to load data if month of the first date (0bill_date) is not equal with the month of the second date (0serv_date).

Can anybody help me to create the coding?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

thanks, but this does not work. now no data gets into the cube. before, just by comparing the two dates, everything worked fine. What can be the problem?

here you can see current coding:

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

DATA: v_rec LIKE sy-tabix.

LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

v_rec = sy-tabix.

IF <source_fields>-bill_date+4(2) EQ

<source_fields>-serv_date+4(2).

DELETE SOURCE_PACKAGE INDEX v_rec.

ENDIF.

ENDLOOP.

$$ end of routine - insert your code only before this line -

Former Member
0 Kudos

you have to check the records coming from the source. the code is fine.

As per the logic used the records with same month in Bill date and serv date will be deleted.

Just make sure you have data at the source where month in Bill date and serv date is different.

If all the records in the source have same month for BIll date and Serv date then you would get zero records only.

--- Thanks...

former_member186445
Active Contributor
0 Kudos

if the month AND the year are to be the same for deleting the record...

if <source_fields>-bill_date(6) EQ <source_fields>-serv_date(6).

Former Member
0 Kudos

Hey,

coding looks fine. Use DTP to debug your start routine. Than you can see what happen and learn best.

Kind regards,

Peter

Former Member
0 Kudos

i have stopped trying to delete lines from a package using an index.

for some reason removing lines reshuffles the package i guess.

what i usually do is creating an extra table l_t_result

whicj i populate with the lines i want to pass

at the end of the start routine (or end routine) i replace the source_package with the table l_t_result

Marco

Answers (5)

Answers (5)

Former Member
0 Kudos

Perfect, it works!

Just one more thing: routine currently compares the two dates. But I have to compare the monhs of the two dates (MM.YYYY).

How can I solve this problem?

regards

Jesper

former_member186445
Active Contributor
0 Kudos

if <source_fields>-bill_date4(2) EQ <source_fields>-serv_date4(2).

Former Member
0 Kudos

some further questions :

- Do I need coding in global part?

- how to define "V_REC" ?

Actual Coding in start routine is as follows:

$$ begin of global - insert your declaration only below this line -

... "insert your code here

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

METHODS

start_routine

IMPORTING

request type rsrequest

datapackid type rsdatapid

EXPORTING

monitor type rstr_ty_t_monitors

CHANGING

SOURCE_PACKAGE type tyt_SC_1

RAISING

cx_rsrout_abort.

METHODS

inverse_start_routine

IMPORTING

i_th_fields_outbound TYPE rstran_t_field_inv

i_r_selset_outbound TYPE REF TO cl_rsmds_set

i_is_main_selection TYPE rs_bool

i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set

i_r_universe_inbound TYPE REF TO cl_rsmds_universe

CHANGING

c_th_fields_inbound TYPE rstran_t_field_inv

c_r_selset_inbound TYPE REF TO cl_rsmds_set

c_exact TYPE rs_bool.

ENDCLASS. "routine DEFINITION

$$ begin of 2nd part global - insert your code only below this line *

... "insert your code here

$$ end of 2nd part global - insert your code only before this line *

----


  • CLASS routine IMPLEMENTATION

----


*

----


CLASS lcl_transform IMPLEMENTATION.

----


  • Method start_routine

----


  • Calculation of source package via start routine

----


  • <-> source package

----


METHOD start_routine.

*=== Segments ===

FIELD-SYMBOLS:

<SOURCE_FIELDS> TYPE tys_SC_1.

DATA:

MONITOR_REC TYPE rstmonitor.

$$ begin of routine - insert your code only below this line -

... "insert your code here

*-- fill table "MONITOR" with values of structure "MONITOR_REC"

*- to make monitor entries

... "to cancel the update process

  • raise exception type CX_RSROUT_ABORT.

loop at source_package assigning <source_fields>.

v_rec = sy-tabix.

if <source_fields>-bill_date EQ <source_fields>-serv_date.

delete source_package index v_rec.

endloop.

$$ end of routine - insert your code only before this line -

ENDMETHOD. "start_routine

I am really an abap noob. Sorry for those questions....

Former Member
0 Kudos

No need to do any coding in Global Part.

Define V_REC as DATA: V_REC like SY-TABIX.

--- Thanks...

former_member186445
Active Contributor
0 Kudos

more or less....

start routine:

loop at source_package assignig <source_fields>

v_rec = sy-tabix.

if <source_fields>-bill_date EQ <source_fields>-serv_date.

delete source_package index v_rec.

endloop.

Former Member
0 Kudos

Hello Arminder,

thank you for this hint.

Can you give me a quick impression of the abap code in start routine?

Regards

Jesper

former_member360228
Contributor
0 Kudos

Instead of doing this in a DTP you can achieve the same in the start routine as well, just loop on the source package and convert the two dates into months and check them, if they are same then delete source_package for that record.

Regards,

Arminder