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

report

MohitSingh
Product and Topic Expert
Product and Topic Expert
0 Likes
1,088

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
Read only

Former Member
0 Likes
1,067

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
Read only

Former Member
0 Likes
1,068

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.

Read only

Former Member
0 Likes
1,067

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.

Read only

0 Likes
1,067

hi,

changes as

loop at itab into wa.

days = sy-datum - wa-joindate.

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

endloop.

Read only

Former Member
0 Likes
1,067

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

Read only

Former Member
0 Likes
1,067

data:itab type standard table of ytmohit_01.

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

regards

shiba dutta

Read only

sharadendu_agrawal
Active Participant
0 Likes
1,067

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

Read only

Former Member
0 Likes
1,067

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.