cancel
Showing results for 
Search instead for 
Did you mean: 

data package error

Former Member
0 Kudos

Dear Guru,

I am trying to derive 2 more records out of 1 record in start routine.

I am using this code as reference:

DATA: wa_temp TYPE DATA_PACKAGE_STRUCTURE OCCURS 0 WITH HEADER LINE.

*Here we populate additional internal tables with values for February – December.

  • Original Data_Package will hold data for January

LOOP AT DATA_PACKAGE INTO wa_temp.

wa_temp-/BIC/New1Key3 = 'ABC'.

wa_temp-/BIC/BIC/KeyFigure01 = data_package-/BIC/KeyFigure01.

wa_temp-/BIC/BIC/KeyFigure02 = data_package-/BIC/KeyFigure02.

APPEND wa_temp.

wa_temp-/BIC/New2Key3 = 'DEF'.

wa_temp-/BIC/BIC/KeyFigure03 = data_package-/BIC/KeyFigure03.

wa_temp-/BIC/BIC/KeyFigure04 = data_package-/BIC/KeyFigure04.

APPEND wa_temp.

ENDLOOP.

  • Append data for February-December to January data

LOOP AT wa_temp.

APPEND wa_temp TO DATA_PACKAGE.

ENDLOOP.

ABORT = 0.

-


However, the Keyfigures are not populated with values as the source record.

Source record:

Key1 Key2 <blank key column> 100 200 300 400

Derived records (but not what is expected!):

Key1 Key2 New1Key3 100 200 0 0

Key1 Key2 New2Key3 100 200 0 0

  • 2nd derived record is assigned same value as 1st derived record. This is puzzling! The code specifically assigned to different KF columns, yet the result is perplexing.

I expected it to be :

Key1 Key2 New1Key3 100 200 <blank> <blank>

Key1 Key2 New2Key3 <blank> <blank> 300 400

I also tried hardcoding the assignment of KF values by actual values. That worked. Somehow, the key field is assigned properly but not the KF (data field) values.

Any idea?

Best Regards,

Suzie

Accepted Solutions (1)

Accepted Solutions (1)

former_member671571
Participant
0 Kudos

Hi,

Check the Code:

wa_temp-/BIC/New1Key3 = 'ABC'.

wa_temp-/BIC/BIC/KeyFigure01 = data_package-/BIC/KeyFigure01.

wa_temp-/BIC/BIC/KeyFigure02 = data_package-/BIC/KeyFigure02.

*Here you need to make KeyFigure03 and KeyFigure04 values blank before appending to wa_temp.

APPEND wa_temp.

wa_temp-/BIC/New2Key3 = 'DEF'.

wa_temp-/BIC/BIC/KeyFigure03 = data_package-/BIC/KeyFigure03.

wa_temp-/BIC/BIC/KeyFigure04 = data_package-/BIC/KeyFigure04.

*Also same make KeyFigure01 and KeyFigure02 values blanck

APPEND wa_temp.

**Refresh the data package..

REFRESH DATA_PACKAGE.

  • Append data for February-December to January data

LOOP AT wa_temp.

APPEND wa_temp TO DATA_PACKAGE.

ENDLOOP.

I hope this should work..

Answers (2)

Answers (2)

Former Member
0 Kudos

Sorry, wrong topic.

Message was edited by: Karsten Larsen

Former Member
0 Kudos

Hi Suzie,

If I undestood correctly,you can write code....

DATA: wa_temp type DATA_PACKAGE_STRUCTURE OCCURS 0

WITH HEADER LINE.

-> Create a structure like data_package

Data : WS_str type data_package.

*Here we populate additional internal tables with values for February – December.

  • Original Data_Package will hold data for January

LOOP AT DATA_PACKAGE .

If ws_str-/BIC/New1Key3 = 'ABC'.

ws_str-/BIC/BIC/KeyFigure01 = data_package-/BIC/KeyFigure01.

ws_str-/BIC/BIC/KeyFigure02 = data_package-/BIC/KeyFigure02.

ws_str-/BIC/BIC/KeyFigure03 = 0.

ws_str-/BIC/BIC/KeyFigure04 = 0.

APPEND ws_str to wa_temp.

endif.

clear ws_str.

if ws_str-/BIC/New2Key3 = 'DEF'.

ws_str-/BIC/BIC/KeyFigure01 = 0.

ws_str-/BIC/BIC/KeyFigure02 = 0

ws_str-/BIC/BIC/KeyFigure03 = data_package-/BIC/KeyFigure03.

ws_str-/BIC/BIC/KeyFigure04 = data_package-/BIC/KeyFigure04.

APPEND ws_str to wa_temp.

endif.

clear ws_str.

ENDLOOP.

-> Clear data_pacage

refresh data_package.

-> insert lines of new internal table to data_package.

insert lines of wa_temp from index 1 into data_package.

Hope it helps

Srini