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

Problem with output

Former Member
0 Likes
520

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

3 REPLIES 3
Read only

Former Member
0 Likes
477

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.

Read only

0 Likes
477

try using the addition under of command write :

The output takes place in the current line at the position where, in a previous WRITE statement, the data object other_dobj was output. The data object other_dobj must be written in the same way as in the respective WRITE statement - that is, including possible offset/length specifications, and so on. if the data object other_dobj was not specified beforehand, the addition is ignored.

The addition UNDER cannot be used together with a position specification pos after AT.

Vertical positioning must be taken care of. If the list cursor is at the same position as the output of other_dobj, this will be overwritten.

The data object other_dobj should be defined globally in the current program. The use of local data objects in procedures can lead to undesirable results, for example, if components with the same structure are used in different procedures.

Example

Table-type output of flight connections.

DATA: carrid TYPE spfli-carrid,

connid TYPE spfli-connid.

WRITE: 10 'Carrier', 40 'Connection'.

ULINE.

SELECT carrid connid

FROM spfli

INTO (carrid,connid).

WRITE: / carrid UNDER 'Carrier',

connid UNDER 'Connection'.

ENDSELECT.

Read only

0 Likes
477

HI Ziv Katz ,

thanks for your reply,

can you please be more specific,

can you explain it with my code,

thanks in advance,

ben.