使用SMARTFORM字段参数设置解决SMARTFORM中数量、金额字段显示问题
2016-09-07 09:36 51人阅读 评论(0) 收藏 举报
本文章已收录于:
分类:
程序人生 ABAPer(840)
作者同类文章X
在SMARTFORM中,数量和金额类型的字段在显示的时候会和其他字段不在同一个水平面上,解决的方法:&ITAB-MENGE(C)& ,下面是SMARTFORM字段参数设置的几个注意事项:
1、使用SFSY-FORMPAGES显示总页数的时候,如果页数大于9,,将会在前10页显示成星号。解决办法:可以添加3ZC,&SFSY-PAGE(3ZC)&/&SFSY-FORMPAGES(3ZC)&,不过可能会出现字体颠倒或者重叠的现象,用一个单独的窗口来存放显示页码的文本,并且把窗口的类型设置为L(最终窗口)就OK了。
2、如果金额或者数量字段显示不出来的话,可以在“货币/数量字段”标签中指定相应的数据类型。
3、Field not outputting more than 255 characters in a loop. This is happening because when you send a string to smartform with length >255 characters then it takes only first 255 characters. I overcomed this problem by splitting the string which was of around 500 char into two and then sending it to smartform as individual vairables and displaying the two variables one after the other in the smartform.
将文本字段拆分成几个字符变量再连接在一起显示。
Syntax 说明
& field+& 对于字符变量设置从何位置显示数据,如果offset大于字符变量长度时,系统就不会显示任何数据
& field()& 设置输出长度.
& field(*)& 如果该字段类型是abap数据字典里定义的类型,系统将按照字典定义的长度设置输出长度
& field(S)& 禁止输出符号位
& field(<)& 符号位显示在数据的左边
& field(.)& 设置显示小数的位数
& field(E)& 设置为科学标示法
& field(T)& 禁止千分位的显示(适用于: DEC, CURR, INT和QUAN几种数据类型).
& field(Z)& 禁止数字前导0的显示
& field(I)& 禁止显示空值
& field(K)& 禁止类型系统按数据字典定义的转换函数进行输出转换
& field(R)& 右对齐(只有在定义了输出长度时才有效)
& field(F)& 用指定的字符替换左边的空格.
& field(L)& 将日期转换为本地显示格式,使用JDAT指定的格式
& field(C)& 该设置效果和ABAP的CONDENSE语句相同.
先在SE73里定义一个新的BARCODE,注意一定要用新的才可以,旧的是打印不出来的。然后定义一个SMARTFORM的样式,把你定义的BARCODE放到字符样式里面去。再做SMARTFORM就可以了,将需要作为条码的变量的格式选为该BARCODE格式,输出时会根据变量不同的数据(如物料,批次)得到相应的条码。
(1).In the transaction se73 , choose a barcode font that suits your
requirements (do this by checking the system barcodes radio button)
(2).Click on the Printer barcodes radiobutton and make sure that the
barcode you chose in step 1 exists for the device type of your
printer.
If you need to create a new barcode font , create it in step1 , and
enterthe hex barcode prefix and suffix ( can be obtained from your
printer manual) , then in step 2 , define a new z_ device type as a
copy of the device type of your printer and assign the system barcode
to the printer.
(3). in your layout set , define a character string with the barcode
font chosen above in the Bar code field .
Format the string that you want to print as a barcode using this
character string.
如果在SMARTFORM中添加了代码,编辑器是不允许设置断点的。
一种方法就是,在代码中加入断点语句break-point,缺点是,每想设一个断点,就需要写一条断点语句。
另一种方法是,自己加的代码都会自带出一个名字的比如‘%CO1’。
Environment -> Function Module Name,
he function that generated for this smartforms is ‘/1BCDWB/SF00000227’(自动生成的SMARTFORM程序名)
T-code se37 -> /1BCDWB/SF00000227 -> Goto -> Main Program
最后一个INCLUDE是对DEBUG最有用的,双击进入,找到 FORM %GLOBAL_INIT。
ABAP之程序相互调用--SUBMIT
2015-01-21 15:41 274人阅读 评论(0) 收藏 举报
本文章已收录于:
分类:
SAP ABAP(187)
作者同类文章X
程序人生 ABAPer(840)
作者同类文章X
功能代码的重用是个老生常谈的话题,ABAP代码中实现程序的调用以及调用时数据参数的传递又是怎样的呢
(1) 调用其他程序:
(2) 调用其他程序参数传递参数:
(3) 更复杂一点的可以用文件临时存储数据:
Idoc学习笔记----获取查询Idoc信息
2014-06-10 13:52 1617人阅读 评论(1) 收藏 举报
本文章已收录于:
分类:
程序人生 ABAPer(840)
作者同类文章X
SAP ABAP(187)
作者同类文章X
过年前写了一篇如何查询idoc信息,在后面的学习实践中了解了下面一些知识点,记录如下:
一,通过IDOC_READ_COMPLETELY这个Function module可以获取idoc的数据信息。该function module以iodc number为参数返回一个 int_edidd的table。在该table中,每一个segment最为一行信息输出,segment下所有field的值都存储在sdata这一字段中,前面学习中提到可以根据每个segement下field的长度以及起始位置到sdata中获取相应的数据信息。其实还有一种更简单的方法:每一个segment对应了SE11中的一个Structure,而每个segment下的field同样也对应到了该Structure中;因此可以定义一个类型为segment的对象,然后将sdate直接赋值给该对象,最后通过该对象来获取field的数据。示例代码如下:
DATA: ZE1EDK01 LIKE E1EDK01.if int_edidd-segnam = 'E1EDK01'.
ZE1EDK01 = int_edidd-sdata.
IT_output-BELNR = ZE1EDK01-BELNR. //fill the internal table with field data.
ENDIF.二,如何获取Idoc的status信息。Idoc的Status信息存储在EDIDS这个Table中,可以根据idoc number获取所有该idoc下的status信息。在EDIDS这个表中存储了STAMID以及STAMNO这两列信息。其中STAMID表示Status message ID,STAMNO表示Status message number,因此可以根据这两个条件到T100中获取相应的status message信息。值得注意的是,在根据STAMID以及STAMNO到T100中获取message信息时要先进行一下转换,代码如下(具体为什么还没有想清楚):
loop at int_edids. "根据idoc number到edids表中获取的所有记录
if int_edids-stacod ne space and int_edids-stamqu eq space.
int_edids-stamqu = int_edids-stacod(3).
int_edids-stamid = int_edids-stacod+3(2).
int_edids-stamno = int_edids-stacod+5(3).
modify int_edids.
endif.
endloop.
此外,在Message中可能存在&以及$这样的符号,这表示需要用其他值来替换。具体用什么值呢?在edids中有STAPA1、STAPA2、STAPA3、STAPA4这样4个filed,分别代表了Parameter 1、Parameter 2、Parameter 3、Parameter 4.可以将这些Parameter代替Message中的特殊符号。如下代码:
LOOP AT int_edids WHERE DOCNUM = int_edidc-DOCNUM AND STATUS = int_edidc-STATUS.select single * from t100
where sprsl = sy-langu
and arbgb = int_edids-stamid
and msgnr = int_edids-stamno.
if sy-subrc ne 0.
clear buffer.
exit.
endif.
buffer = t100-text.
if t100-text ca '$1'.
replace '$1' with int_edids-stapa1 into buffer.
endif.
if t100-text ca '$2'.
replace '$2' with int_edids-stapa2 into buffer.
endif.
if t100-text ca '$3'.
replace '$3' with int_edids-stapa3 into buffer.
endif.
if t100-text ca '$4'.
replace '$4' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '&1'.
replace '&1' with int_edids-stapa1 into buffer.
endif.
if t100-text ca '&2'.
replace '&2' with int_edids-stapa2 into buffer.
endif.
if t100-text ca '&3'.
replace '&3' with int_edids-stapa3 into buffer.
endif.
if t100-text ca '&4'.
replace '&4' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '$'.
replace '$' with int_edids-stapa1 into buffer.
replace '$' with int_edids-stapa2 into buffer.
replace '$' with int_edids-stapa3 into buffer.
replace '$' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '&'.
replace '&' with int_edids-stapa1 into buffer.
replace '&' with int_edids-stapa2 into buffer.
replace '&' with int_edids-stapa3 into buffer.
replace '&' with int_edids-stapa4 into buffer.
endif.
condense buffer.
IF int_edids-STATXT CA '&'.
REPLACE '&' WITH int_edids-stapa1 INTO buffer.
REPLACE '&' WITH int_edids-stapa2 INTO buffer.
REPLACE '&' WITH int_edids-stapa3 INTO buffer.
REPLACE '&' WITH int_edids-stapa4 INTO buffer.
CONDENSE buffer. "Condense 用于删除字符字段中多余的空格
ENDIF.CONCATENATE IT_output-Message buffer INTO IT_output-Message.
ENDLOOP.OK.先补充如上。
SAP中负数的表示增强 负号从数字后更改到数字前面
2015-05-22 10:36 334人阅读 评论(0) 收藏 举报
本文章已收录于:
分类:
程序人生 ABAPer(840)
作者同类文章X
SAP ABAP(187)
作者同类文章X
SAP中的负号是放后面的,其实也无所谓,谁看不出来啊,关键人家要你改也没有办法。有个函数CLOI_PUT_SIGN_IN_FRONT是把负号提前的,但是它是把字符转化为字符型输出的。就是把负号split下然后放前面,这样的问题就是在显示的时候字符型数字没有3位一分的千位分隔符。再把字符型赋予数字型输出,但是输出的时候负号还是会自动加后面滴~
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'CHANGING
VALUE = gt_table-column5.
问同事了下,告诉我用write to语句把负数取绝对值,然后把数字型写入字符型可以保留千位符,再判断正负数,在输出的时候添上负号。在FORM里我就是这样改的了,很方便。
Form asset_front_minus changing value1.
value2 = abs( value1 ).
write value2 to string1.
condense string1.
if value1 < 0.
write: '-', string1 LEFT-JUSTIFIED NO-GAP NO-ZERO.
else.
write: string1 LEFT-JUSTIFIED NO-GAP NO-ZERO.
endif.
endform.
他告诉我手动把字符型加千位符的,取整,判断长度,除3以后循环mask"___,"格式,分割,再处理头3位,觉得有点头晕,麻烦啊。不过真有强人这么做,下面就是了,手动把字符型加千位符号。
FORM NUMTOSTR USING VALUE(ZNUM) CHANGING VALUE(ZSTR).DATA : ZCLEN TYPE I,
N TYPE I,
ZCSTR(20) TYPE C,
ZCSTR2(20) TYPE C,
ZCTEMP(3) TYPE C,
ZFLAG(1) TYPE C VALUE '.',
ZFLAG2 TYPE I VALUE 0,
ZCDEC(20) TYPE C. "记录小数部分.
ZSTR = ''.
CHECK ZNUM <> 0.
IF ZNUM <= -1000.ZFLAG2 = 1.
ZNUM = ABS( ZNUM ).
ENDIF.IF ZNUM >= 1000.ZCSTR = ZNUM.
• 压缩字符串,去除前面的空格。
CONDENSE ZCSTR NO-GAPS.
• 分离整数与小数,好单独处理整数。
SPLIT ZCSTR AT ZFLAG INTO ZCSTR ZCDEC.
ZCLEN = STRLEN( ZCSTR ).
• 在循环中从右面在每三位的前面加上一个逗号。
WHILE ZCLEN > 3.
N = ZCLEN - 3.
ZCTEMP = ZCSTR+N(3).
IF NOT ZCSTR2 IS INITIAL.CONCATENATE ZCTEMP ZCSTR2 INTO ZCSTR2 SEPARATED BY ','.
ELSE.
ZCSTR2 = ZCTEMP.
ENDIF.ZCLEN = ZCLEN - 3.
ENDWHILE.• 将不剩下的不足三位数加到前面
CONCATENATE ZCSTR+0(ZCLEN) ZCSTR2 INTO ZCSTR2 SEPARATED BY ','.
IF ZFLAG2 = 1.CONCATENATE '-' ZCSTR2 INTO ZCSTR2.
ENDIF.CLEAR ZCSTR.
• 将处理过的整数与小数连接起来。
CONCATENATE ZCSTR2 ZCDEC INTO ZCSTR SEPARATED BY ZFLAG.
• 将值返回
ZSTR = ZCSTR.
ELSE.
ZSTR = ZNUM.
ENDIF.ENDFORM.SAP字段与表的对应关系
2015-04-27 10:47 3452人阅读 评论(0) 收藏 举报
本文章已收录于:
分类:
SAP ABAP(187)
作者同类文章X
程序人生 ABAPer(840)
作者同类文章X
MASTER DATA-主数据
Customer Master
KNA1 Customer Basic Data
KNB1 Customer Company Level Data客户的公司数据
KNVV Customer Sales Level Data 客户的销售数据
KNVP Customer Partnering Data客户合作伙伴
KNKA Customer Credit Data - Centralized
KNKK Customer Credit Data - Control Area Level
KNBK Customer Bank Details
KNVH Customer Hierarchies
KNVL Customer Licenses
KNMT Customer - Material Info Record,客户-物料信息记录数据表
...