‎2007 Sep 18 7:09 AM
my requirement:
I want to divide the DMBTR field (currency) by MENGE field (quantity).I gave the perform endperform in script. Now i am coding the subroutine . this is what i've coded.
form f_division
TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY .
DATA : V1 TYPE BSEG-DMBTR,
V2 TYPE BSEG-MENGE,
V3(13) TYPE C,
RESULT TYPE P DECIMALS 2.
Read Table INTAB INDEX 1.
V1 = INTAB-VALUE.
Replace "," with "." into v3.
v1 = v3.
Read Table INTAB INDEX 2.
V2 = INTAB-VALUE.
Replace "," with "." into v3.
v2 = v3.
IF V2 NE 0 OR NOT V2 IS INITIAL. "for Division by 0
RESULT = V1 / V2.
ENDIF.
WRITE RESULT TO OUTTAB-VALUE LEFT-JUSTIFIED.
MODIFY OUTTAB TRANSPORTING VALUE WHERE NAME = 'TMP'.
endform.
Here i've assigned V1 to dmbtr and V2 to menge. The v3(13) is a temporary variable i introduced so that the format of dmtbr is <b>12,98</b> is changed to <u><b><u>12.98</u></b></u> .ie. the comma is changed to a point(fullstop). Now that i coded this i get an error stating "IN EXPECTED AFTER V1". plz temme how do i go abt this.
‎2007 Sep 18 9:31 AM
hI ALL,
IF USE THE FOLLWING CODE IT WORKS.
TABLES intab STRUCTURE itcsy
outtab STRUCTURE itcsy .
DATA : v1 LIKE bseg-dmbtr,
v2 LIKE bseg-menge,
TEMP1(255) TYPE C,
TEMP2(255) TYPE C,
result TYPE p DECIMALS 2.
READ TABLE intab INDEX 1.
TEMP1 = intab-value+242(13).
v1 = TEMP1.
READ TABLE intab INDEX 2.
TEMP2 = intab-value+242(13).
v2 = temp2.
IF v2 NE 0 OR NOT v2 IS INITIAL. "for Division by 0
result = v1 / v2.
ENDIF.
WRITE result TO outtab-value LEFT-JUSTIFIED.
MODIFY outtab TRANSPORTING value WHERE name = 'TMP'.
ENDFORM. " f_division