Data not lining up

5 pts.
Tags:
SAP ABAP
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

First of all separate the heading from the rest of the program by creating an event called TOP-OF-PAGE. Put this at the bottom of the program under the
ENDFORM. ” WRITE_LINE.
Example:
.
.
.
ENDFORM. ” WRITE_LINE.
*&———————————————————————*
TOP-OF-PAGE.
FORMAT COLOR 1 INTENSIFIED ON.
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 ‘.
ULINE AT /(128). ” make sure there is no space between the / and (.
FORMAT RESET.
END-OF-PAGE.
*&———————————————————————*
TOP-OF-PAGE is automatically called at the first write statement. You don’t have to do anything. This way the heading will always stay at the top of the screen even if the
written data scrolls below the bottom of the page.

To avoid confusion put START-OF-SELECTION at the beginning of your processing after the SELECTION-SCREEN.

Get rid of the spaces [‘ ‘] between your write fields. ABAP automatically puts a space
between the variables. To line everything up use position numbers in the variables
like you did in the heading. Use the same positions you used in the header and they will
line up with the header. The color makes it look better.

Hope this helps.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following