2012 Aug 02 2:37 AM
Hi All,
I have a requirement in BW to transform HR related data for internal use. For this purpose i have created an APD (Analysis Process Designer) which reads data from a database table and writes it into a CSV file by trasnforming only some records using an ABAP routine.
Exmaple. I have ORGUNIT and DATETO as 2 fields in the source table.
ORGUNIT | DATETO |
12345678 | 31.12.2011
12345678 | 31.11.2010
12345678 | 31.10.2009
12345678 | 31.08.2008
87654321 | 31.12.9999
87654321 | 31.12.2012
87654321 | 31.10.2011
Target CSV file should have output like below
12345678 | 31.12.9999
12345678 | 31.11.2010
12345678 | 31.10.2009
12345678 | 31.08.2008
87654321 | 31.12.9999
87654321 | 31.12.2012
87654321 | 31.10.2011
in the above example ORGUIT 87654321 has no change, where as in 12345678 we need to sort the ORGUNIT by DATETO field in DESCENDING ORDER and check the first record's DATETO value. IF first record's DATETO value is not equal to 31.12.9999, we only need to modify the first record with value as 31.12.9999. rest of the records will remain same.
For this requirement i used the below code in my routine and struggling to get the logic working.
DATA: ls_ source type y_source_fields,
ls_target type y_target_feilds.
SORT itab by ORGUNIT ASCENDING DATETO DESCENDING.
loop at itab into ls_source.
move-corresponsing ls_source to ls_target.
if ls_source-DATETO ne '99991231'
ls_target-DATETO = '99991231'
Append ls_target to et_target.
Endloop.
I am not an ABAPer .but trying to do this by myself. The above code gives me DATETO fields for each record as 31.12.9999.
Can any one help me here please.
Thanks in advance.
2012 Aug 02 5:57 AM
Dear Former Member,
Go like this.
DATA: ls_ source type y_source_fields,
ls_target type y_target_feilds.
SORT itab by ORGUNIT ASCENDING DATETO DESCENDING.
loop at itab into ls_source.
At New ORGUNIT.
if ls_source-DATETO ne '99991231'
ls_target-DATETO = '99991231'
end at.
Append ls_target to et_target.
Endloop.
With Regards,
Akshay
Hi All,
I have a requirement in BW to transform HR related data for internal use. For this purpose i have created an APD (Analysis Process Designer) which reads data from a database table and writes it into a CSV file by trasnforming only some records using an ABAP routine.
Exmaple. I have ORGUNIT and DATETO as 2 fields in the source table.
ORGUNIT | DATETO |
12345678 | 31.12.2011
12345678 | 31.11.2010
12345678 | 31.10.2009
12345678 | 31.08.2008
87654321 | 31.12.9999
87654321 | 31.12.2012
87654321 | 31.10.2011
Target CSV file should have output like below
12345678 | 31.12.9999
12345678 | 31.11.2010
12345678 | 31.10.2009
12345678 | 31.08.2008
87654321 | 31.12.9999
87654321 | 31.12.2012
87654321 | 31.10.2011
in the above example ORGUIT 87654321 has no change, where as in 12345678 we need to sort the ORGUNIT by DATETO field in DESCENDING ORDER and check the first record's DATETO value. IF first record's DATETO value is not equal to 31.12.9999, we only need to modify the first record with value as 31.12.9999. rest of the records will remain same.
For this requirement i used the below code in my routine and struggling to get the logic working.
DATA: ls_ source type y_source_fields,
ls_target type y_target_feilds.
SORT itab by ORGUNIT ASCENDING DATETO DESCENDING.
loop at itab into ls_source.
move-corresponsing ls_source to ls_target.
if ls_source-DATETO ne '99991231'
ls_target-DATETO = '99991231'
Append ls_target to et_target.
Endloop.
I am not an ABAPer .but trying to do this by myself. The above code gives me DATETO fields for each record as 31.12.9999.
Can any one help me here please.
Thanks in advance.
2012 Aug 02 5:57 AM
Dear Former Member,
Go like this.
DATA: ls_ source type y_source_fields,
ls_target type y_target_feilds.
SORT itab by ORGUNIT ASCENDING DATETO DESCENDING.
loop at itab into ls_source.
At New ORGUNIT.
if ls_source-DATETO ne '99991231'
ls_target-DATETO = '99991231'
end at.
Append ls_target to et_target.
Endloop.
With Regards,
Akshay
2012 Aug 02 7:25 AM
Hi thanks for your help.
But that doesn't solve my problem. The result is not what i wanted. if i don't use move corresponding statement at the start of the loop, that will write all other field values to zero except DATETO.
any other thougths please ??
2012 Aug 09 2:03 AM
Hi All,
Can any one please help me with the code here please.
I am using the code as below, but it is not working as i wanted.
DATA: LS_SOURCE TYPE y_source_fields,
LS_TARGET TYPE y_target_fields.
SORT it_SOURCE BY ORGUNIT ASCENDING DATETO DESCENDING.
LOOP AT IT_SOURCE into ls_source. ..
MOVE-CORRESPONDING
ls_source to ls_target.at new ORGUNIT.
if ls_source-dateto ne '99991231'.
ls_target-dateto = '99991231'.
endif.
endat.
append ls_target to et_target.
SORT ET_TARGET BY NODEID ASCENDING.
ENDLOOP.
2012 Aug 09 6:16 AM
Hi,
Could you please show how have you defined the types y_source_fields and y_target_fields?
Regards,
Kumud
2012 Aug 09 6:37 AM
Hi POPS,
What output you are getting..?
Are you getting " ****** " in date field....???
if you are getting " ****** " in date filed than go for the following modified code.
DATA: LS_SOURCE TYPE y_source_fields,
LS_TARGET TYPE y_target_fields.
DATA: Old_date type ls_target-dateto,
New_date type ls_target-dateto.
SORT it_SOURCE BY ORGUNIT ASCENDING DATETO DESCENDING.
LOOP AT IT_SOURCE into ls_source. ..
MOVE-CORRESPONDING
ls_source to ls_target.
old_date = ls_target-dateto.
at new ORGUNIT.
if old_date ne '99991231'.
new_date = '99991231'.
else
new_date = old_date.
endif.
endat.
ls_target-dateto = new_date.
clear new_date.
clear old_date.
append ls_target to et_target.
SORT ET_TARGET BY NODEID ASCENDING.
ENDLOOP.
With Regards,
Akshay
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |