Hello Friends,
I have the following code
Data : Begin of itab occurs 0,
sumso (18),
valut(15),
sumha(18),
end of itab.
DATA :TOTAL.
LOOP AT ITAB INTO WA_ITAB.
AT LAST.
SUM.
TOTAL =
WA_ITAB-SUMSO.
ENDAT.
ENDLOOP.
While executing ,'*****'
is getting in filled in wa_itab-sumso and throwing dump error.
How to resolve this ?
Hari
sample program
see this
Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
DATA: BEGIN OF ITAB OCCURS 0,
F1 TYPE I,
F2(6) TYPE C,
F3(10) TYPE N,
F4(16) TYPE P DECIMALS 2,
END OF ITAB.
DATA: SUB_TOT(10) TYPE P DECIMALS 3.
**--1
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 30.
ITAB-F4 = '3000.00'.
APPEND ITAB.
CLEAR ITAB.
*--2
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
*-- 3
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
SORT ITAB BY F1.
LOOP AT ITAB.
AT FIRST.
WRITE: /35 ' MATERIAL DETAILS:'.
ULINE.
ENDAT.
AT NEW F1.
WRITE: / 'DETAILS OF MATERIAL:' COLOR 7 , ITAB-F1.
ULINE.
ENDAT.
WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
SUB_TOT = SUB_TOT + ITAB-F4.
AT END OF F1.
ULINE.
WRITE: / 'SUB TOTAL :' COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
CLEAR SUB_TOT.
ENDAT.
AT LAST.
SUM.
ULINE.
WRITE: 'SUM:', ITAB-F4.
ULINE.
ENDAT.
ENDLOOP.
Data : Begin of itab occurs 0,
sumso (18),
valut(15),
sumha(18),
end of itab.
DATA :TOTAL.
sort itab by sumso valut sumha. <--- write this statement
LOOP AT ITAB INTO WA_ITAB.
AT LAST.
read table ITAB index sy-tabix. <--- write this statement
SUM.
TOTAL =
WA_ITAB-SUMSO.
ENDAT.
ENDLOOP.
declare variables of type i.
TYPES : BEGIN OF itab,
sumso type i,
valut type i,
sumha type i,
END OF itab.
DATA : t_itab TYPE STANDARD TABLE OF itab,
wa_itab TYPE itab,
total type i.
wa_itab-sumso = 2.
wa_itab-sumha = 3.
append wa_itab to t_itab.
wa_itab-sumso = 2.
wa_itab-sumha = 3.
append wa_itab to t_itab.
LOOP AT t_itab INTO wa_itab.
AT LAST.
SUM.
total = wa_itab-sumso.
ENDAT.
ENDLOOP.
Hi,
Use the foloowing code.
DATA : BEGIN OF ITAB OCCURS 0,
SUMSO(18),
VALUT(15),
SUMHA(18),
END OF ITAB.
DATA :TOTAL LIKE ITAB-SUMSO,
WA_ITAB LIKE ITAB.
ITAB-SUMSO = '247385'.
ITAB-VALUT = '437965'.
ITAB-SUMHA = '365376'.
APPEND ITAB. CLEAR ITAB.
ITAB-SUMSO = '247384'.
ITAB-VALUT = '437966'.
ITAB-SUMHA = '3653767'.
APPEND ITAB. CLEAR ITAB.
LOOP AT ITAB INTO WA_ITAB.
TOTAL = TOTAL + WA_ITAB-SUMSO.
AT LAST.
WRITE :/1 TOTAL.
ENDAT.
ENDLOOP.
Regards,
Sankar.
Add a comment