Application Development 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: 

how to sum up

Former Member
0 Kudos

hi all,

I am making a report using table COSP,if i have a period range suppose 1 to 4 and after that i have to add WTG001 - WTG004 in particular cost centre range.Please tell how to proceed.If any sample report is there plz mail it to me or in reply.

Regards,

Praveen

9 REPLIES 9

Former Member
0 Kudos

Hi Praveen

For such requirements please use

<b>DO VARYING f FROM f1 NEXT f2 </b> statement

Best Regards,

Arun

Message was edited by:

Arun Nair

raymond_giuseppi
Active Contributor
0 Kudos

Use something like

  DATA: w_wkgbtr LIKE coep-wkgbtr,
        w_mbgbtr LIKE coep-mbgbtr,
    DO 16 TIMES
      VARYING w_wkgbtr FROM cossa-wkg001 NEXT cossa-wkg002
      VARYING w_mbgbtr FROM cossa-meg001 NEXT cossa-meg002.
      MOVE sy-index TO coep-perio.
      CHECK coep-perio IN s-perio.
      ADD w_wkgbtr TO outtab-wkgbtr
*     ...
    ENDDO.

Regards

Former Member
0 Kudos

Hi,

check this..



**Let's say the structure/variable WTG001 is having the fields.

FIELD-SYMBOLS: <fs>.

DATA: V_FIELDNAME(30).
DATA: V_CHAR(2).
DATA: V_SUM TYPE NETPR.

DO.

  V_CHAR = SY-INDEX.
  
  CONCATENATE 'WTG001-'  V_CHAR INTO V_FIELDNAME.
   CONDENSE V_FIELDNAME. 

  ASSIGN (V_FIELDNAME) TO <FS>.

  V_SUM = V_SUM + <FS>.

  IF SY-INDEX > 4.   " this can be variable.
     EXIT.
  ENDIF.

ENDDO.

WRITE: / V_SUM.

Thanks

Naren

Former Member
0 Kudos

Hi

You can use the field sysmbols to calculate the amounts based on the period

  • Form Local data

data: l_period(2) type n,

l_name(35) type c,

l_monat type i .

l_monat = p_date+4(2).

  • Field Symbols

field-symbols <fs>.

clear it_bud_tab.

refresh it_bud_tab.

select lednr " Ledger No

objnr " Object No

gjahr " Fiscal Year

wrttp " Actuals

versn " Version

twaer " Currency

perbl " Period Block

kstar " Cost Element/GL A/C No

wog001 " Total Value

wog002 " Total Value

wog003 " Total Value

wog004 " Total Value

wog005 " Total Value

wog006 " Total Value

wog007 " Total Value

wog008 " Total Value

wog009 " Total Value

wog010 " Total Value

wog011 " Total Value

wog012 " Total Value

into table it_bud_tab

from cosp

where lednr = c_lednr and

gjahr = p_gjahr and

wrttp = c_wrttp and

versn = c_versn and

beknz in (c_d,c_s).

  • Get the YTD Budget using Field Symbols

do l_monat times.

l_period = sy-index.

concatenate c_it_bud_tab_wog0 l_period

into l_name.

assign (l_name) to <fs>.

it_ytd_tab-amt_ytd = it_ytd_tab-amt_ytd +

<fs>.

enddo.

collect it_ytd_tab.

clear it_ytd_tab.

endif.

endloop.

sort it_ytd_tab by gjahr kostl kstar.

Regards

Anji

0 Kudos

hi again,

i have to make a report on cost centre expenses with the help table COSP.I have to put cost centre from OBJNR in which last five haraters are cost centre and period like month and year.After that in report display i want KSTAR i.e. in down the line and cost centres of selection in vertical it may increase or decrease depending on selection.After that i have to add all the WTG001-WTG016.if in seletion period is 1 to 2 then i have to add WTG001 and WTG002 in corresponding in KSTAR and so on in desired cost centre column below that facing respective KSTAR.If anyone can send any report relating that i will be thankful.

Former Member
0 Kudos

Hi,

construct a range of specified period (eg: 1 to 4) in a i_period.

go through the below code.

loop at itab.

loop at i_period.

case i_period-val.

when '01'.

sum_wtg = sum_wtg + itab-wtg001.

<repeat for 02 to 16>

endcase.

endloop.

collect itab_final.

endloop.

Thanks!

Brunda

'Reward if useful'.

0 Kudos

how to construct the range of specified period (eg: 1 to 4) in a i_period.?

0 Kudos

hi,

count = so_perio.

CLEAR low.

DO count TIMES.

low = low + 1.

i_per_year-perio = low.

APPEND i_per_year.

CLEAR i_per_year.

ENDDO.

send your code exactly what you want.

Thanks!

Brunda

'Reward if useful'.

0 Kudos

i have to make a report on cost centre expenses with the help table COSP.I have to put cost centre from OBJNR in which last five charaters are cost centre,i have to select last five digits only and period like month and year.After that in report display i want all the values of cost element i.e. KSTAR down the line and cost centres of range selection in vertical.After that i have to add all the WTG001-WTG016.If seletion period is 1 to 2 then i have to add WTG001 and WTG002 in corresponding in KSTAR and below desired cost centre range column below that facing particular KSTAR.If anyone can send any report relating that i will be thankful.