Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8800

ABAP code in a BW Transformation

$
0
0

Hello,

I am having some problems for solving this:

 

When loading data to a DSO, I am using a transformation for loading data from source (datasource) to target (DSO). In this transformation I have created ABAP programs in the START Routine, FIELD Routines and END Routine.

 

In the source I have:

Material (0material)

Season (0AF_SEAN)

 

In The DSO I have:

Material (Key)

DateFrom (Key)

Season

DateTo

 

The ideia is:

For every entry, check data in DSO,

* if material doesn't exist in DSO

add a new record with material, dateFrom = sy-datum, season, DateTo = '99991231'

* if material and season is the same don't do anything

* if material is the same but season is different:

add:

--> data to DSO but with DateFrom = sy-datum and DateTo = '99991231'

--> Modify existing entry in DSO with DateTo = sy-datum - 1

Here you have the code:

 

Start Routine:

 

On the global part:

TYPES: Begin of T_temp,

MATNR TYPE C LENGTH 18,

SAISO TYPE C LENGTH 4,

END OF T_temp.

 

*-- internal table declaration

DATA: iT_temp TYPE standard table of T_temp with key MATNR SAISO,

wa_temp like line of iT_temp.

 

On the local part:

data: wa_SOURCE_PACKAGE type _ty_s_SC_1.

 

loop at SOURCE_PACKAGE into wa_SOURCE_PACKAGE.

if wa_SOURCE_PACKAGE-MATERIAL is not initial and

wa_SOURCE_PACKAGE-AF_SEAN is not initial.

move wa_SOURCE_PACKAGE-MATERIAL to wa_temp-MATNR.

move wa_SOURCE_PACKAGE-AF_SEAN to wa_temp-SAISO.

append wa_temp TO iT_temp.

endif.

endloop.

 

FIELD Routine DATEFROM

 

data: d type /BI0/OIDATETO.

data: season type /BIC/OIZC_ZSEASO.

d = '99991231'.

 

select single /BIC/ZC_ZSEASO from /BIC/AZBI_STM00 into season

where material = SOURCE_FIELDS-MATERIAL and DATETO = d.

 

if sy-subrc = 0.

if season NE SOURCE_FIELDS-AF_SEAN.

RESULT = SY-DATUM.

endif.

else.

RESULT = SY-DATUM - 1.

endif.

 

FIELD Routine for DATETO

 

DATA: DATA_ACTUAL TYPE D,

D type /BI0/OIDATETO,

season type /BIC/OIZC_ZSEASO.

DATA_ACTUAL = SY-DATUM - 1.

D = '99991231'.

 

select single /BIC/ZC_ZSEASO from /BIC/AZBI_STM00 into season

where material = SOURCE_FIELDS-MATERIAL and DATETO = D.

 

if sy-subrc = 0.

if season NE SOURCE_FIELDS-AF_SEAN.

UPDATE /BIC/AZBI_STM00 SET DATETO = DATA_ACTUAL

WHERE material = SOURCE_FIELDS-MATERIAL AND DATETO = D AND

/BIC/ZC_ZSEASO NE SOURCE_FIELDS-AF_SEAN.

commit work.

RESULT = D.

endif.

else.

RESULT = D.

endif.

 

I am reading and searching 'net' to see if I can do a upload in a DSO table directally.

Anyway all this code is not working properly.

 

Any idea?

 

Thank you


Viewing all articles
Browse latest Browse all 8800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>