2009 Jul 13 8:35 AM
Hi all,
DATA: BEGIN OF i_mgmt OCCURS 0,
btrtl TYPE pa0001-btrtl,
btext TYPE t001p-btext,
perm TYPE pad_amt7s ,
con TYPE pad_amt7s ,
perm2 TYPE pad_amt7s ,
con2 TYPE pad_amt7s ,
perm3 TYPE pad_amt7s ,
con3 TYPE pad_amt7s ,
tot TYPE pad_amt7s ,
avg TYPE pad_amt7s ,
END OF i_mgmt.
This my int. table and i need to calculate tot. row wise How can i use do varying command in this condition. Or any other way to calculate tot. row wise...Plesae help me
Thanks.
2009 Jul 13 10:14 AM
Hi Ramya,
After selecting the required data into itab i_mgmt with work area (say wa), do the following.
loop at i_mgmt into wa.
wa-tot = wa-perm + wa-con + wa-perm2 + wa-con2 + wa-perm3 + wa-con3.
wa-avg = wa-tot / 3.
modify i_mgmt index sy-tabix from wa .
endloop.
Hope it helps...
Regards,
Mdi.Deeba
Hi Ramya,
After selecting the required data into itab i_mgmt with work area (say wa), do the following.
loop at i_mgmt into wa.
wa-tot = wa-perm + wa-con + wa-perm2 + wa-con2 + wa-perm3 + wa-con3.
wa-avg = wa-tot / 3.
modify i_mgmt index sy-tabix from wa .
endloop.
Hope it helps...
Regards,
Mdi.Deeba
2009 Jul 13 8:40 AM
Hi,
Do you mean that tot will be the sum of perm con, perm2, con2, perm3 and con3 for each btrtl then you can use COLLECT statement and collect the data in a new internal table.
regards,
Ankur Parab
2009 Jul 13 9:50 AM
Hi,
Ya tot = perm + con + perm2 + con2 + perm3 + con3 for eac btrtl. will collect gives the total row-wise?
2009 Jul 13 11:22 AM
>
> Hi,
>
> Ya tot = perm + con + perm2 + con2 + perm3 + con3 for eac btrtl. will collect gives the total row-wise?
COLLECT statment should not be used for standard tables (obsolete for standard tables). As suggested by Thomas please use the ASSIGN statement with the INCREMENT addition
Please check the below article(page 6)
[State of the art ABAP programs - part 2|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/4fbafc9e-0e01-0010-dea9-9d23d1b269fb?overridelayout=true]
Regards
Rajesh
2009 Jul 13 8:44 AM
Hi,
You can use simple loop - endloop to calculate any thing row wise.
Declare some field outside the loop for calculation and initilize it.
then use.
m_tot type p decimals 2 value 0.
loop at i_mgmt.
m_tot = m_tot + tot.
endloop.
m_tot will give you the final total row wise. You can use any number of variable as per calculating different fields total.
If this was your requirement, i think this is more than sufficient.
Regds,
Anil
2009 Jul 13 9:59 AM
Hi anil,
Here tot = perm + con + perm2 + con2 + perm3 + con3.
How to calculate??
2009 Jul 13 8:49 AM
Depending on your SAP release, DO ... VARYING might be obsolete, use ASSIGN ... INCREMENT instead inside the loop.
See ABAP Online help for more information, as always.
Thomas
2009 Jul 13 8:54 AM
Hi,
Check this example program how to use DO VARYING ..
REPORT ZTEST_NOTEPAD.
DATA: BEGIN OF text,
word1 TYPE c LENGTH 4 VALUE 'AAAA',
word2 TYPE c LENGTH 4 VALUE 'BBBB',
word3 TYPE c LENGTH 4 VALUE 'CCCC',
word4 TYPE c LENGTH 4 VALUE 'DDDD',
END OF text.
DATA: word TYPE c LENGTH 4,
char1 TYPE c LENGTH 1,
char2 TYPE c LENGTH 1,
leng TYPE i.
FIELD-SYMBOLS <word> LIKE text-word1.
DATA inc TYPE i.
DESCRIBE FIELD text LENGTH leng IN CHARACTER MODE.
leng = leng / 2.
DO leng TIMES VARYING char1 FROM text(1)
NEXT text+2(1) RANGE text
VARYING char2 FROM text+1(1)
NEXT text+3(1) RANGE text.
WRITE: char1, char2.
char1 = 'x'.
char2 = 'y'.
ENDDO.
DO 4 TIMES VARYING word FROM text-word1 NEXT text-word2.
WRITE / word.
ENDDO.
DO.
inc = sy-index - 1.
ASSIGN text-word1 INCREMENT inc TO <word> RANGE text.
IF sy-subrc = 0.
WRITE / <word>.
ELSE.
EXIT.
ENDIF.
ENDDO.
.Thanks
Venkat.O
2009 Jul 13 10:14 AM
Hi Ramya,
After selecting the required data into itab i_mgmt with work area (say wa), do the following.
loop at i_mgmt into wa.
wa-tot = wa-perm + wa-con + wa-perm2 + wa-con2 + wa-perm3 + wa-con3.
wa-avg = wa-tot / 3.
modify i_mgmt index sy-tabix from wa .
endloop.
Hope it helps...
Regards,
Mdi.Deeba
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |