Application Development 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: 

report

MohitSingh
Product and Topic Expert
Product and Topic Expert
0 Kudos
219

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
198

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.

7 REPLIES 7

Former Member
0 Kudos
199

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.

former_member181962
Active Contributor
0 Kudos
198

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.

0 Kudos
198

hi,

changes as

loop at itab into wa.

days = sy-datum - wa-joindate.

write:/ wa-fname ,wa-lname ,wa-occu ,wa-joindate ,days.

endloop.

Former Member
0 Kudos
198

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

Former Member
0 Kudos
198

data:itab type standard table of ytmohit_01.

data:wa type ytmohit_01,<b>days type i.</b>

regards

shiba dutta

sharadendu_agrawal
Active Participant
0 Kudos
198

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

Former Member
0 Kudos
198

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.