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: 

Sapscript Totals by Subroutine Error

Former Member
0 Kudos

Hi Everybody,

PROGRAM Z_GET_PRICE.

FORM F_GET_PRICE TABLES INTAB STRUCTURE ITCSY OUTTAB STRUCTURE ITCSY.

DATA FIELD1 TYPE CHAR25.

STATICS TOT_PRICE TYPE CHAR25.

READ TABLE INTAB WITH KEY 'RF140-WRSHB'.

IF SY-SUBRC = 0 .

FIELD1 = INTAB-VALUE.

ENDIF.

TOT_PRICE = TOT_PRICE + FIELD1.

READ TABLE OUTTAB WITH KEY 'TOT_PRICE' .

IF SY-SUBRC = 0 .

OUTTAB-VALUE = TOT_PRICE.

MODIFY OUTTAB INDEX 1 .

ENDIF.

ENDFORM.

I am getting error while using this code . I debugged this code, for first record its passing out from routine, but at second record at TOT_PRICE = TOT_PRICE + FIELD1 this place throwing to dump. Can you please suggest me on this issue?

at first record field1 = 45.00 ,TOT_PRICE = 0 + 45.00 = 45.00

second record 1631.28 ,TOT_PRICE = 45.00 + 1631.28 --> error

In sapscript at main window i diclare perform, is fine. if i dont use TOT_PRICE = FIELD1 only Its printing data, but a wrong data.

Thanks in Advance.

1 REPLY 1

Former Member
0 Kudos

Got solved by myself. In the above code if there is the item value is more than 1000 its giving cama for thousand. as it is the WRSHB field property it's giving cama. thats violating the adition rule. So I played arround with data types like below code.

DATA FIELD1(13) TYPE N.

STATICS FIELD2(13) TYPE N.

STATICS FIELD3(13) TYPE P DECIMALS 2.

STATICS TOT_PRICE TYPE CHAR25 .

READ TABLE INTAB WITH KEY 'RF140-WRSHB'.

IF SY-SUBRC = 0 .

FIELD1 = INTAB-VALUE.

ENDIF.

FIELD2 = FIELD2 + FIELD1.

FIELD3 = FIELD2 / 100 .

TOT_PRICE = FIELD3.

READ TABLE OUTTAB INDEX 1 .

IF SY-SUBRC = 0 .

OUTTAB-VALUE = TOT_PRICE.

MODIFY OUTTAB INDEX 1 .

ENDIF.

ENDFORM.