Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Logic Error in BW Transformations...

Former Member
0 Likes
361

I am getting a strange issue when used the below code

Target : Charasteristic,Data Type CHAR 5

Code:

DATA: years TYPE tfmatage,

months TYPE tfmatage.

*DATA: result TYPE c LENGTH 5.(Showing error if included:Result is already declared)

DATA: l_res TYPE p DECIMALS 2.

IF source-field-/bic/zdob IS INITIAL.

result = ''.

ELSE.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

EXPORTING

i_date_from = source-field-/bic/zdob

i_date_to = sy-datum

i_flg_separate = 'X'

IMPORTING

e_months = months

e_years = years.

if months 0.

l_res = years + months / 100.

WRITE l_res TO RESULT.

else.

write years to RESULT.

ENDIF.

ENDIF.

WRITE / RESULT.

I am using the above code (given by Mat in SDN) as a field routine in Transformations...can any one please explain me in detail(step by step) whats it doing.

My requirment is to cal age of the employee in YY:MM format based on his DOB & SY datum.

FIMA_DAYS_AND_MONTHS_AND_YEARS give Years & Months between 2 dates

Please update me where i was doing wrong

If months = 0 the the result should be only years

Ex: if Months & Years of FM Output is 40Y,0M the i want only 40 to be updated insted of 40.00 so that the reason why i enhanced your code

But it is giving me strange output

For Output which got months it is being update correctly but

for output for which months are 0 it is being update as

If FM output is 40Y,0M

then the output being updated is ' 40' (2 spaces before 40)

In report i need to enter 2 spaces before 40 to retrive values of 40

Please correct error

Please ask if you need any info

Thanks

2 REPLIES 2
Read only

Former Member
0 Likes
327

After writing to 'RESULT'.

Add this code.

SHIFT RESULT LEFT DELETING LEADING SPACE.

" I think this will solve your leading space issue".

I have added in the code.

*DATA: result TYPE c LENGTH 5.(Showing error if included:Result is already declared)

DATA: l_res TYPE p DECIMALS 2.

IF source-field-/bic/zdob IS INITIAL.

result = ''.

ELSE.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

EXPORTING

i_date_from = source-field-/bic/zdob

i_date_to = sy-datum

i_flg_separate = 'X'

IMPORTING

e_months = months

e_years = years.

if months 0.

l_res = years + months / 100.

WRITE l_res TO RESULT.

else.

write years to RESULT.

ENDIF.

after writing to 'RESULT'.

Add this code.

SHIFT RESULT LEFT DELETING LEADING SPACE.

" I think this will solve your leading space issue".

ENDIF.

WRITE / RESULT.

Thanks

Marudha

Read only

0 Likes
327

Hi Experts,

"SHIFT RESULT LEFT DELETING LEADING SPACE."

This is not working

Please update.

Thanks