Data not lining up
5 pts.
0
Q:
Data not lining up
I am very very new to ABAP programming.
I am accumulating hours by employee and department for selected work weeks.
When it outputs to the screen the hours are one line below the employee and dept.
So the hours are on the wrong employee. How do I get these to line up?

*&---------------------------------------------------------------------*
*& Report ZTIMEDEPTEMPSUM Creation Date: 07/15/2008
*&
*&---------------------------------------------------------------------*
*& Hours by Dept and Employee Summary Report
*&
*&---------------------------------------------------------------------*

REPORT ZTIMEDEPTEMPSUM LINE-SIZE 132
* LINE-COUNT 63
NO STANDARD PAGE HEADING.

*========================================================================
* TABLES
*========================================================================

TABLES: catsdb, "Database Table for Time Sheet
cskt, "Cost Center text table
pa0001, "Employee name table
T513S. "Job description table

*=========================================================================
* DATA
*=========================================================================

DATA:
Direct(9) type P decimals 2, "Direct hours
Indirect(9) type P decimals 2, "Indirect hours
save_kostl LIKE pa0001-kostl, "Employee cost center
save_sy_tabix LIKE sy-tabix, "Save the tab index
save_pernr LIKE catsdb-pernr. "Employee number

DATA:
BEGIN OF i_cats OCCURS 0, "Internal table i_cats

pernr LIKE catsdb-pernr, "Employee number
workdate LIKE catsdb-workdate, "Work date
lstar LIKE catsdb-lstar, "Activity type
rproj LIKE catsdb-rproj, "WBS Element
raufnr LIKE catsdb-raufnr, "Work order number
awart LIKE catsdb-awart, "Attendance type
status LIKE catsdb-status, "Status 30 = approved
catshours LIKE catsdb-catshours, "Hours
kostl LIKE pa0001-kostl, "Cost center

END OF i_cats.

DATA:
BEGIN of i_cskt OCCURS 0, "Internal table i_cskt

kostl LIKE cskt-kostl, "Cost center
datbi LIKE cskt-datbi, "End date 12/31/9999
ktext LIKE cskt-ktext, "Cost center description

END OF i_cskt.

DATA:

BEGIN of i_pa0001 OCCURS 0, "Internale table i_pa0001

pernr LIKE pa0001-pernr, "Employee number
kostl LIKE pa0001-kostl, "Cost center
sname LIKE pa0001-sname, "Employee last name first name
stell LIKE pa0001-stell, "Job code
endda LIKE pa0001-endda, "End date 12/31/9999

End OF i_pa0001.

DATA:

BEGIN OF i_t513s OCCURS 0, "Internal table i_t513s

stell LIKE t513s-stell, "Job code
stltx LIKE t513s-stltx, "Job description
endda LIKE t513s-endda, "End date 12/31/9999

END of i_t513s.


*============================================================================
* SELECTION
*============================================================================

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-a01.

SELECT-OPTIONS:

s_workdt FOR catsdb-workdate. "Work Date

SELECTION-SCREEN END OF BLOCK a1.

SELECT

pernr
workdate
lstar
rproj
raufnr
awart
status
catshours

from catsdb INTO CORRESPONDING FIELDS OF TABLE i_cats

where workdate in s_workdt
and status = '30'
and ( awart = '1EXC' OR
awart = '1HLW' OR
awart = '1MKT' OR
awart = '1MTG' OR
awart = '1REG' OR
awart = '1SUT' OR
awart = '1TRG' ).

SELECT

pernr
kostl
sname
stell
endda

from pa0001 INTO CORRESPONDING FIELDS OF TABLE i_pa0001

FOR ALL ENTRIES IN i_cats

where pernr eq i_cats-pernr and endda eq '99991231'.

SELECT

kostl
datbi
ktext

from cskt INTO CORRESPONDING FIELDS OF TABLE i_cskt

FOR ALL ENTRIES IN i_pa0001

where datbi eq '99991231' and kostl eq i_pa0001-kostl.


SELECT

stell
stltx
endda

from t513s INTO CORRESPONDING FIELDS OF TABLE i_t513s

FOR ALL ENTRIES IN i_pa0001

where stell eq i_pa0001-stell and endda eq '99991231'.

*=====================================================================

SORT i_pa0001 by pernr.

LOOP AT i_cats.

save_sy_tabix = sy-tabix.

READ table i_pa0001 with key pernr = i_cats-pernr binary search.

MOVE i_pa0001-kostl to i_cats-kostl.

MODIFY i_cats index save_sy_tabix.

ENDLOOP.

*=====================================================================
* WRITE
*=====================================================================

WRITE: / 'Workdate From ', s_workdt-low, ' To ', s_workdt-high,
50 'DATE: ', sy-datum mm/dd/yy, 67 'TIME: ', sy-uzeit.

SKIP.

WRITE: / 'Dept', 10 'Emp No', 22 'Employee Name', 56 'Job Description', 93 'Direct Hrs', 114 'Indirect Hrs'.

SKIP.

*======================================================================
* SORT
*======================================================================

SORT i_cskt by kostl.

SORT i_cats by kostl pernr.

SORT i_t513s by stell.

*=======================================================================
* LOOP
*=======================================================================

LOOP AT i_cats.

ON CHANGE of i_cats-pernr.

READ table i_pa0001 with key pernr = i_cats-pernr binary search.

MOVE:
i_cats-pernr to save_pernr,
i_cats-kostl to save_kostl.

PERFORM write_line.

ENDON.

*==========================================================================
* ACCUMULATE HOURS
*==========================================================================


IF i_cats-raufnr is initial and i_cats-rproj = '00000000'.
indirect = indirect + i_cats-catshours.

ELSE.

direct = direct + i_cats-catshours.

ENDIF.

ENDLOOP.


PERFORM WRITE_LINE.

*&---------------------------------------------------------------------*
*& Form WRITE_LINE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_LINE .

CLEAR: i_pa0001-SNAME, i_t513s-stltx.

READ table i_pa0001 with key pernr = i_cats-pernr binary search.

READ table i_cskt with key kostl = i_pa0001-kostl binary search.

READ table i_t513s with key stell = i_pa0001-stell binary search.

WRITE: /
save_kostl, ' ', 10 save_pernr, ' ', i_pa0001-sname, ' ', i_t513s-stltx, ' ', direct, ' ', indirect.

CLEAR: direct, indirect.

ENDFORM. " WRITE_LINE
ASKED: Aug 15 2008  11:39 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
5 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Last Answered: Aug 15 2008  11:39 PM GMT by Kp9404   5 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0