2007 Jul 12 10:54 AM
iam new to abap.In this report i have to calculate no of days employed for an employee i.e sy-date - joining-date, but its giving wrong o/p.please review my code give the correct solution.
REPORT ypr_mohitsingh_ex02 .
TABLES ytmohit_01.
data:itab type standard table of ytmohit_01.
data:wa type ytmohit_01,days.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_emplid FOR ytmohit_01-emp_id.
SELECTION-SCREEN END OF BLOCK b1.
start-of-selection.
SELECT * FROM ytmohit_01 into wa WHERE emp_id in s_emplid.
append wa to itab.
endselect.
loop at itab into wa.
days = sy-datum - ytmohit_01-joindate.
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
2007 Jul 12 10:57 AM
Hi,
Change the code as follows,
loop at itab into wa.
days = sy-datum - <b>wa</b>-joindate.
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
Reward if helpful.
2007 Jul 12 10:57 AM
Hi,
Change the code as follows,
loop at itab into wa.
days = sy-datum - <b>wa</b>-joindate.
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
Reward if helpful.
2007 Jul 12 10:57 AM
Change as highlighted:
loop at itab into wa.
days = sy-datum - <b>wa</b>-joindate.
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
2007 Jul 12 10:59 AM
hi,
changes as
loop at itab into wa.
days = sy-datum - wa-joindate.
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
2007 Jul 12 10:58 AM
Hello,
Change the code like this.
loop at itab into wa.
days = sy-datum - wa-joindate." Check here
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
Vasanth
2007 Jul 12 10:58 AM
data:itab type standard table of ytmohit_01.
data:wa type ytmohit_01,<b>days type i.</b>
regards
shiba dutta
2007 Jul 12 10:59 AM
Instead of subtracting the joining date fron sy-datum try to use a FM that gives the difference between two given dates. Hope it solves the problem.
Reward if useful.
Cheers
Sharadendu
2007 Jul 12 11:18 AM
Hi,
Try replacing the code.The changes made are,
1. Define a data type for variable 'days'.
2You have to subtract the sy-datum with wa-joindate and not from the table.
REPORT ypr_mohitsingh_ex02 .
TABLES ytmohit_01.
data:itab type standard table of ytmohit_01.
data:wa type ytmohit_01,days type i .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_emplid FOR ytmohit_01-emp_id.
SELECTION-SCREEN END OF BLOCK b1.
start-of-selection.
SELECT * FROM ytmohit_01 into wa WHERE emp_id in s_emplid.
append wa to itab.
endselect.
loop at itab into wa.
days = sy-datum - wa-joindate.
write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.
endloop.
Reward points if it was useful.
Regards,
Hema.