Skip to Content
author's profile photo Former Member
Former Member

loop error

hii,

the output of my report showing correct data for one employee.

but, on selecting 2 or more employees it is showing data corresponding to last employee for all of them.

where m i getting wrong.

thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

12 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:00 AM

    hELLO ,

    Better paste u r code.

    regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:09 AM

    Hi,

    Check your code wheather it is overwriting the previous data.

    Its better if you give the code.

    Regards,

    Anirban

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:11 AM

    check where you have written the append statement in the loop. if u are using a loop within a loop, the append should be in the 2nd loop and not in the first. but posting ur code here would be of much help.

    Regards,

    SG

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:14 AM

    The possible error may be you would not have cleared the structure and so the last value in the structure will be taken into consideration.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:18 AM

    Used function modules for payroll result

    LOOP AT i_pa0001 INTO fs_pa0001.

    *& Reading of the Payresult for all the Periods

    REFRESH:

    it_rgdir,

    i_rgdir.

    CLEAR:fs_rgdir.

    CALL FUNCTION 'CU_READ_RGDIR'

    EXPORTING

    persnr = fs_pa0001-pernr

    TABLES

    in_rgdir = it_rgdir

    EXCEPTIONS

    no_record_found = 1

    OTHERS = 2.

    IF sy-subrc = 0.

    CALL FUNCTION 'PYXX_GET_RELID_FROM_PERNR'

    EXPORTING

    employee = fs_pa0001-pernr

    IMPORTING

    relid = lv_relid

    molga = lv_molga

    EXCEPTIONS

    error_reading_infotype_0001 = 1

    error_reading_molga = 2

    error_reading_relid = 3

    OTHERS = 4.

    IF sy-subrc NE 0.

    ENDIF.

    SELECT SINGLE typename

    FROM t52relid

    INTO lv_type

    WHERE relid EQ lv_relid

    AND tabname = 'PCL2'.

    IF sy-subrc NE 0.

    lv_relid = 'IN'.

    lv_type = 'PAYIN_RESULT'.

    ENDIF.

    lv_typename = lv_type.

    CREATE DATA ref_payresult TYPE (lv_typename).

    ASSIGN ref_payresult->* TO <payresult>.

    • SRTZA--Status Of records.

    • SRTZA = 'A' --Current Result.

    DELETE it_rgdir WHERE srtza NE 'A'.

    • PAYTY --> Payment Type ( Regular or Bonus)

    • PAYTY = SPACE --'Regular Payroll'.

    • PAYTY = 'B' --> 'Bonus'.

    LOOP AT it_rgdir INTO fs_rgdir WHERE payty = ''

    AND fpbeg GE v_begda

    AND fpend LE v_endda.

    APPEND fs_rgdir TO i_rgdir.

    ENDLOOP. " LOOP AT it_rgdir

    SORT i_rgdir BY seqnr DESCENDING.

    CLEAR: lv_unpaid,lv_paid.

    LOOP AT i_rgdir INTO fs_rgdir.

    CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'

    EXPORTING

    clusterid = lv_relid

    employeenumber = fs_pa0001-pernr

    sequencenumber = fs_rgdir-seqnr

    CHANGING

    payroll_result = <payresult>

    EXCEPTIONS

    illegal_isocode_or_clusterid = 1

    error_generating_import = 2

    import_mismatch_error = 3

    subpool_dir_full = 4

    no_read_authority = 5

    no_record_found = 6

    versions_do_not_match = 7

    error_reading_archive = 8

    error_reading_relid = 9

    OTHERS = 10.

    IF sy-subrc EQ 0.

    ASSIGN COMPONENT 'INTER-RT' OF STRUCTURE <payresult> TO <li_rt>.

    LOOP AT <li_rt> INTO lfs_rt .

    if lfs_rt-lgart = '/460'.

    fs_pa0001-betrg = lfs_rt-betrg.

    endif.

    if lfs_rt-lgart = '4101'.

    fs_pa0001-betrg1 = lfs_rt-betrg.

    endif.

    ENDLOOP.

    ENDIF.

    ENDLOOP.

    ENDIF.

    ENDLOOP.

    LOOP AT TABFINAL INTO W_FINAL.

    WRITE:/6(8) W_FINAL-PERNR .

    WRITE:/100(10) fs_pa0001-betrg .

    ENDLOOP.

    ENDFORM.

    Edited by: AKSHAYA A on May 20, 2009 12:18 PM

    Edited by: AKSHAYA A on May 20, 2009 12:20 PM

    Edited by: AKSHAYA A on May 20, 2009 12:20 PM

    Edited by: AKSHAYA A on May 20, 2009 12:21 PM

    Edited by: AKSHAYA A on May 20, 2009 12:25 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:23 AM

    hi ,

    i suggest .

    first check your internal table contain all the data,in debugg mode....

    enter the multiple values and check whether your internal table is filtering the required values.

    Clear all the workarea you are using inside the loop after appending or displaying.

    clear the internal table before fetching datas.

    regards,

    Safel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:30 AM

    thanks

    Edited by: AKSHAYA A on May 20, 2009 12:30 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:36 AM

    you are not appending the records in to internal table that's why you are getting last record in the out put.

    chek the inter nal table or select statement. it will work .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 10:37 AM

    Hi,

    Close the thread if solved.

    Regards,

    Nikhil.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 11:09 AM

    LOOP AT TABFINAL INTO W_FINAL.

    WRITE:/6(8) W_FINAL-PERNR .

    WRITE:/100(10) fs_pa0001-betrg .

    ENDLOOP.

    instead of this

    write

    LOOP AT TABFINAL INTO W_FINAL.

    append W_FINAL TO IT_FINAL.

    ENDLOOP.

    AND THEN

    WRITE IT_FINAL-PERNR .

    WRITE IT_FINAL-BETRG.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.