cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP code for not overwriting existing value while loading to cube.

former_member194898
Active Contributor
0 Kudos
836

Hi,

How to prevent transformation from overwriting existing value in the given field when there's nothing to load ie loaded value is initial or "" WHILE LOADING transactional data from 0figl_O14 to data cube.

I tried to use code like this

but RAISE EXCEPTION TYPE CX_RSOUT_SKIP_RECORD instruction can't be used as it causes not loading entire record.

What can be use instead of that RAISE... instruction ???

Regards, Leszek

Accepted Solutions (0)

Answers (2)

Answers (2)

anish_samuel
Explorer
0 Kudos

Leslaw,

Could you please mention the logic in word, so i can write abap code for the logic.

Thanks,

Anish Samuel

former_member194898
Active Contributor
0 Kudos

Hi, some more explanation:

Data should be loaded from DSO to data cube.

There is a source field in dso and destination field in cube.

The loads works on document number l(doc no) evel as many times as document positions (doc pos) exists.

The problem is that sometimes loading from first position of the document fetches proper value and then in the second position of the same dokument there's unwanted value ie "" or initial and that overwrites what has been written to that field before.

The proper value should not be overwritten by that "" or initial like in the picture below.

Regards, Leszek  

Former Member
0 Kudos

Do you have document position in Target. As shown in your scren above doesnt have Doc Pos in Target.

Madhu.

anindya_bose
Active Contributor
0 Kudos

Hi Leslaw

I assume your Data Flow is like  DataSource---->DSO----->Cube

It seems you want REF_DOC_NUM to be populated for a doc , if for a particular position REF_DOC is blank but is has the value for some other position .

In  transformation DSO --->Cube , create a start routine which would read like this...

Select Doc Num  ref_doc_num from DSO into table it_doc where ref_doc_num != ' '

for all entries in SOURCE_PACKAGE where DOC_NUM = SOURCE_PACKAGE-DOC_NUM.

In the field routine read this internal table if your SOURCE_FIELD is blank .

Instead of field routine, complete logic can be implemented in start or end routine for better performance. Here we are reading the same source DSO and see if the value is populated .

Note: Cube does not overwrite record , for every load it would create a separate record.

Regards

Anindya

Former Member
0 Kudos

Hi Leszek,

This can be achieved with few lines of code, however I believe your requirement is little ambiguous.

Because when you have just 2 records with source field one populated and other blank then we can assign the filled value to blank value however if you have more than 1 filled values similar like below then how you expect it to work?

When you clarify this doubt then its easy to handle actually .

Thanks

Amit

Former Member
0 Kudos

Hi Leslaw,

Use a continue statment in the else part this helps to skip the loop iteration.

See example below for make it clear how this works.

CONTINUE statement in ABAP is used for terminating the current loop iteration and start the next iteration. This statement can only used with the loops like

  • DO … ENDDO Loops
  • WHILE … ENDWHILE loops
  • LOOP … ENDLOOP loops
  • SELECT … ENDSELECT loops

See the following sample code and its result for better understand.

DO 10 TIMES.

IF SY-INDEX >= 0 AND SY-INDEX <= 6.    CONTINUE.

WRITE: SY-INDEX, ‘ ‘.

ENDIF.

ENDDO.

Its output will be:

7 8 9 10.

Thanks,

Madhu.

former_member194898
Active Contributor
0 Kudos

Thank you for quick response but as far as I understood your answer  it's not that case. Could you please look into my explanation that I wrote to Mr Anish Samuel.