首页 > Linux操作系统 > Linux操作系统 > ABAP数值消零、负号提前
sap本身在显示金额的时候负号在后面,而我们的习惯是把它放在前面。还有些客户提出如果数据为零就让他不让他显示:
*&--------------------------------------------------------------------*
*& FORM. p_conver *
*&--------------------------------------------------------------------*
* 名称:p_conver *
* 功能描述:负号提前,消0 *
*---------------------------------------------------------------------*
form. p_conver changing blstring .
types: begin of xx,
x0(2) type c,
x1(3) type c,
x2(3) type c,
x3(3) type c,
x4(3) type c,
x5(7) type c,
end of xx.
types: begin of yy,
y1(2) type c,
y2(4) type c,
y3(4) type c,
y4(4) type c,
y5(7) type c,
end of yy.
data: string1 type xx,
string2 type yy,
f type c,
dh(1) type c value ',',
qq like glt0-hslvt.
qq = blstring.
if qq < 0.
qq = ( -1 ) * qq.
f = 1.
endif.
if qq = 0.
blstring = ''.
exit.
endif.
string1 = qq.
string2-y5 = string1-x5.
if string1-x4 <> 0 or string1 > 1000.
concatenate string1-x4 dh into string2-y4.
endif.
if string1-x3 <> 0 or string1 > 1000000.
concatenate string1-x3 dh into string2-y3.
endif.
if string1-x2 <> 0 or string1 > 1000000000.
concatenate string1-x2 dh into string2-y2.
endif.
if string1-x1 <> 0 or string1 > 1000000000000.
concatenate string1-x1+2(1) dh into string2-y1.
endif.
concatenate string2-y1 string2-y2 string2-y3 string2-y4 string2-y5
into blstring.
if f = 1.
shift blstring left deleting leading space.
concatenate '-' blstring into blstring.
endif.
endform. " p_conver
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16565567/viewspace-612288/ ,如需转载,请注明出处,否则将追究法律责任。