on 05-16-2007 12:20 PM
hi ABAP gurus
a using the code below to sumup the field BSEG_WRBTR but am getting the values as 0 in the output and i also debugged the code in SE38.The value under GLOBAL is coming as zero.I also used other data type like integer and float but i was geting runtime errors..please help...u wiill appreciated & rewarded..
<b>Code in Scripts</b>
/: DEFINE &SUM&
/: PERFORM GETTOTAL IN PROGRAM ZINNERDOCTEST3
/: USING &BSEG-WRBTR&
/: CHANGING &SUM&
/: ENDPERFORM
<b>Code in SAP scripts</b>
DATA:GLOBAL TYPE n .
FORM GETTOTAL TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
READ TABLE IN_TAB INDEX 1.
DATA:SUM1 TYPE n .
SUM1 = IN_TAB-VALUE.
GLOBAL = GLOBAL + SUM1.
READ TABLE OUT_TAB INDEX 2.
LOOP AT OUT_TAB.
OUT_TAB-VALUE = GLOBAL.
MODIFY OUT_TAB INDEX sy-tabix.
ENDLOOP.
ENDFORM.
with regards
vijay
HI..
Try this code
DATA:GLOBAL(10) TYPE N value '100'.
FORM GETTOTAL TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
READ TABLE IN_tab WITH KEY 'BSEG-WRBTR'.
global = global + in_tab-value.
READ TABLE out_tab WITH KEY 'SUM'.
move global to out_tab-value.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDFORM.
<b>ITCSY IS A STRUCTURE WHICH CONTAINS ONLY FIELD AND FIELDVALUE SO IT IS ALWAYS BETTER TO READ TABLES WITH KEY VARIABLE NAME.</b>
reagards,
veeresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Here is your error (in bold)
Code in Scripts
/: DEFINE &SUM&
/: PERFORM GETTOTAL IN PROGRAM ZINNERDOCTEST3
/: USING &BSEG-WRBTR&
/: CHANGING &SUM&
/: ENDPERFORM
Code in SAP scripts
DATA:GLOBAL TYPE n .
FORM GETTOTAL TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
READ TABLE IN_TAB INDEX 1.
DATA:SUM1 TYPE n .
SUM1 = IN_TAB-VALUE.
GLOBAL = GLOBAL + SUM1.
<b>BTW i think that there should have been another read like this
READ TABLE IN_TAB INDEX 1.
GLOBAL IN_TAB-VALUE.
then GLOBAL = GLOBAL + SUM1.</b>
READ TABLE OUT_TAB <b>INDEX 2</b>.
<b>SHOULD BE : READ TABLE OUT_TAB INDEX1.</b>
LOOP AT OUT_TAB.
OUT_TAB-VALUE = GLOBAL.
MODIFY OUT_TAB INDEX sy-tabix.
ENDLOOP.
ENDFORM.
Regards,
Sooness
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Change these codes:
DATA:GLOBAL TYPE n .
FORM GETTOTAL TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
READ TABLE IN_TAB INDEX 1.
DATA:SUM1 TYPE n .
SUM1 = IN_TAB-VALUE.
GLOBAL = GLOBAL + SUM1.
READ TABLE OUT_TAB INDEX 2.
LOOP AT OUT_TAB.
OUT_TAB-VALUE = GLOBAL.
MODIFY OUT_TAB INDEX sy-tabix.
ENDLOOP.
ENDFORM.
line this:
DATA:GLOBAL TYPE n .
FORM GETTOTAL TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
READ TABLE IN_TAB INDEX 1.
DATA:SUM1 TYPE n .
READ TABLE OUT_TAB INDEX 2.
LOOP AT OUT_TAB.
SUM1 = IN_TAB-VALUE.
GLOBAL = GLOBAL + SUM1.
OUT_TAB-VALUE = GLOBAL.
MODIFY OUT_TAB INDEX sy-tabix.
ENDLOOP.
ENDFORM.
It will work.
Jogdand M B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use Code like :
/: DEFINE &SUM&
/: PERFORM GETTOTAL IN PROGRAM ZINNERDOCTEST3
/: USING &BSEG-WRBTR&
/: CHANGING &SUM&
/: ENDPERFORM
Code in SAP scripts
DATA:GLOBAL TYPE n .
FORM GETTOTAL TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
READ TABLE IN_TAB with key name 'BSEG-WRBTR'.
DATA:SUM1 TYPE n .
SUM1 = IN_TAB-VALUE.
GLOBAL = GLOBAL + SUM1.
READ TABLE OUT_TAB Iwith key name '= 'SUM'.
OUT_TAB-VALUE = GLOBAL.
MODIFY OUT_TAB INDEX sy-tabix.
ENDFORM.
Reward Points if it is useful
Thanks
Seshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.