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

Problem with output

Hi to all,

i am trying to collect the data form different internal table and print then in one final table.

but am unale to achieve it,

i am getting the below output.

"""
                    0.00           0.00 64,402.00      64,402.00   "this line is complete unwanted line
 6609001
               10,000.00                     0.00             
 A5400         57,495.36                     0.00   "64,402.00 must be printed here
 28                           67,495.36                0.00   "64,402.00 must be printed here
""""

expected output

"""
 6609001
               10,000.00                     0.00             
 A5400         57,495.36                    64,402.00   
 28                           67,495.36               64,402.00  
""""

this is my code


types:  begin of ty_coll,
        hkont type bseg-hkont,
        aufnr type bseg-aufnr,
        kostl type bseg-kostl,
        pswbt type bseg-pswbt,
        hkont1 type bseg-hkont,
        aufnr1 type bseg-aufnr,
        kostl1 type bseg-kostl,
        pswbt1 type bseg-pswbt,
        hkont2 type bseg-hkont,
end of ty_coll.
  data : sy_tabix type sy-tabix.
  data: lv_index type sy-tabix.
"data: declaration


PARAMETERS: S_GJAHR TYPE ty_bseg-gjahr memory id mdk."default sy-datum+0(4).
PARAMETERS: S_MONAT type ty_BKPF-MONAT memory id mde."default sy-datum+4(2).
SELECT-OPTIONS: S_HKONT FOR WA_BSEG-HKONT obligatory memory id mdf .
SELECT-OPTIONS: s_kostl for wa_bseg-kostl memory id mds.

START-OF-SELECTION.
  perform actual.
  perform pri_actual.
  CLEAR WA_BSEG.
  REFRESH IT_BSEG.
  skip 3.
  perform sply.
  perform pri_sply.
  CLEAR WA_BSEG1.
  REFRESH IT_BSEG1.
  skip 3.
  perform final.
FORM ACTUAL .

  SELECT hkont
  belnr
  gjahr
  KOSTL
  AUFNR
  BUKRS
  PSWBT
  WRBTR FROM BSEG
  INTO TABLE IT_BSEG
  WHERE GJAHR EQ S_GJAHR
  AND HKONT IN S_HKONT
  and kostl in s_kostl.
  IF not it_bseg[] IS INITIAL.
    SELECT belnr
    GJAHR
    MONAT
    BUKRS
    BUDAT FROM BKPF
    INTO TABLE IT_BKPF
    FOR ALL ENTRIES IN IT_BSEG
    WHERE MONAT eq s_monat
          AND belnr = it_BSEG-belnr
          AND GJAHR = it_BSEG-GJAHR
          AND BUKRS = it_BSEG-BUKRS.
  ENDIF.
ENDFORM.                    " ACTUAL
FORM PRI_ACTUAL .
  sort it_bseg by hkont kostl aufnr.
  sort it_bkpf by BUKRS BELNR GJAHR.
  LOOP AT IT_BSEG INTO WA_BSEG.
    sy_tabix = sy-tabix.
    Read table it_bkpf into wa_bkpf with key BUKRS = wa_bseg-bukrs
                                             BELNR = wa_bseg-belnr
                                             GJAHR = wa_bseg-gjahr Binary search.
    sort it_bkpf by BUKRS BELNR GJAHR.
    If sy-subrc EQ 0.
    else.
      delete it_bseg index sy_tabix.
    endif.
  endloop.
  clear wa_bseg.
  sort it_bseg by hkont aufnr kostl pswbt.
  LOOP AT IT_BSEG INTO WA_BSEG.
    wa_coll-hkont = wa_bseg-hkont.
    wa_coll-aufnr = wa_bseg-aufnr.
    wa_coll-kostl = wa_bseg-kostl.
    wa_coll-pswbt = wa_bseg-pswbt.
    collect wa_coll into it_coll.
    clear : wa_coll,wa_bseg.
  endloop.
ENDFORM. 
FORM SPLY .
  S_GJAHR1 = S_GJAHR - 1.
  SELECT hkont
  belnr
  gjahr
  KOSTL
  AUFNR
  BUKRS
  PSWBT
  WRBTR FROM BSEG
  INTO TABLE IT_BSEG1
  WHERE GJAHR EQ S_GJAHR1
  AND HKONT IN S_HKONT
  and kostl in s_kostl.
  IF not it_bseg1[] IS INITIAL.
    SELECT belnr
    GJAHR
    MONAT
    BUKRS
    BUDAT FROM BKPF
    INTO TABLE IT_BKPF1
    FOR ALL ENTRIES IN IT_BSEG1
    WHERE MONAT eq s_monat
          AND belnr = it_BSEG1-belnr
          AND GJAHR = it_BSEG1-GJAHR
          AND BUKRS = it_BSEG1-BUKRS.
  endif.
  clear s_gjahr1.
ENDFORM.      
FORM PRI_SPLY .
  sort it_bseg1 by hkont kostl aufnr.
  sort it_bkpf1 by BUKRS BELNR GJAHR.

  LOOP AT IT_BSEG1 INTO WA_BSEG1.
    sy_tabix = sy-tabix.
    Read table it_bkpf1 into wa_bkpf1 with key BUKRS = wa_bseg1-bukrs
                                               BELNR = wa_bseg1-belnr
                                               GJAHR = wa_bseg1-gjahr Binary search.
    sort it_bkpf1 by BUKRS BELNR GJAHR.
    If sy-subrc EQ 0.
    else.
      delete it_bseg1 index sy_tabix.
    endif.
  endloop.

  clear wa_bseg1.

  sort it_bseg1 by hkont aufnr kostl pswbt.

  LOOP AT IT_BSEG1 INTO WA_BSEG1.
    wa_coll-hkont1 = wa_bseg1-hkont.
    wa_coll-aufnr1 = wa_bseg1-aufnr.
    wa_coll-kostl1 = wa_bseg1-kostl.
    wa_coll-pswbt1 = wa_bseg1-pswbt.
    collect wa_coll into it_coll.
    clear : wa_coll,wa_bseg1.
  endloop.

ENDFORM.  
  

Moderator message: duplicate issue, vague title.

Edited by: Thomas Zloch on Sep 13, 2011 2:50 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 13, 2011 at 11:16 AM

    this is the final print code

    FORM FINAL .
      data: lv_index type sy-tabix.
      sort it_coll by hkont kostl aufnr.
      loop at it_coll into wa_coll.
        lv_index = sy-tabix.
        at new hkont.
          write:1 sy-uline(98).
          write:/1 sy-vline(1),
                 2 wa_coll-HKONT COLOR 3.
        endat.
        at new aufnr.
          sum.
          write:78 sy-vline(1).
          write:/1 sy-uline(98),
                /1 sy-vline(1),
                 2 wa_coll-aufnr color 1,
                10 wa_coll-pswbt,
                98 sy-vline(1).
        endat.
        at last.
          read table it_coll into wa_coll index lv_index.
          write:/1 sy-uline(78),
                /1 sy-vline(1),
                 2 wa_coll-kostl,
                98 sy-vline(1).
        endat.
        at end of hkont.
          sum.
          write:25 wa_coll-pswbt.
          write:65 wa_coll-pswbt1.
          write:/1 sy-uline(98).
        endat.
      endloop.
    ENDFORM. 
    

    so kindly please share your suggestions.

    thanks in advance,

    ben.

    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.