首页 \ 问答 \ 在类定义中ABAP“SET EXTENDED CHECK”语句(ABAP “SET EXTENDED CHECK” statement inside class definition)

在类定义中ABAP“SET EXTENDED CHECK”语句(ABAP “SET EXTENDED CHECK” statement inside class definition)

在客户对象中,我看到以下ABAP代码:

CLASS lcl_detail DEFINITION FINAL.
  SET EXTENDED CHECK OFF.      
  PUBLIC SECTION.
  [...]
ENDCLASS.

我已经在SAP 7.40系统上执行了语法检查,这很好。 但是,如果我检查CLASS DEFINITION的7.40 ABAP关键字文档,它并没有说在这个地方允许SET EXTENDED CHECK。 另外,我认为CLASS DEFINITION部分和第一部分之间不应该有任何关系。


In a customer object, I see the following ABAP code:

CLASS lcl_detail DEFINITION FINAL.
  SET EXTENDED CHECK OFF.      
  PUBLIC SECTION.
  [...]
ENDCLASS.

I've performed a syntax check on an SAP 7.40 system and it is fine. But if I check the 7.40 ABAP Keyword documentation of CLASS DEFINITION, it does not say that SET EXTENDED CHECK is allowed in this place. Also, I though there shouldn't be anything between the CLASS DEFINITION part and the first SECTION part.


原文:https://stackoverflow.com/questions/32352410
更新时间:2022-07-10 20:07

最满意答案

首先,我强烈建议不要过滤这样的警告:这个错误是由MySQL生成的,它绝对意味着你正在丢失数据。

首先要做的就是使用MySQL describe命令来确保数据库列的实际定义与您期望的大小相同:如果您更改列的长度,那么Django不支持数据库迁移,因此如果您的slug字段比现在更短,您需要手动更改表以设置新长度:

mysql> DESCRIBE my_table slug;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| slug  | varchar(255) | NO   | UNI | NULL    |       |
+-------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)

如果该字段不是您所期望的,则可以通过更新列长来简单地解决问题:

mysql> ALTER TABLE my_table MODIFY slug VARCHAR(255) NOT NULL;

如果允许在你的slu Unicode中使用Unicode字符,那么也可以解释它,因为上面的转储似乎使用latin1字符集而不是UTF-8 - 单个UTF-8字符最多可以有4个字节的数据,这意味着只要17个字节的值就可以溢出一个VARCHAR(64)

下一个调试步骤是对您正在进行的调用进行简单的变化,以过滤警告以准确找出错误发生的位置:

warnings.simplefilter("error",  category=MySQLdb.Warning)

这会使警告致命,这将会停止你的程序,但更重要的是也会产生堆栈跟踪。 用这样的东西,你会看到下面的输出:

#!/usr/bin/env python
import warnings

def foo():
    warnings.warn("uhoh")

def bar():
    foo()

def main():
    warnings.simplefilter("error", UserWarning)
    bar()

if __name__ == "__main__":
    main()

没有simplefilter调用:

cadams@Io:~ $ python test_warnings.py 
test_warnings.py:5: UserWarning: uhoh
  warnings.warn("uhoh")

通过simplefilter调用:

cadams@Io:~ $ python test_warnings.py 
Traceback (most recent call last):
  File "test_warnings.py", line 15, in <module>
    main()
  File "test_warnings.py", line 12, in main
    bar()
  File "test_warnings.py", line 8, in bar
    foo()
  File "test_warnings.py", line 5, in foo
    warnings.warn("uhoh")
UserWarning: uhoh

First, I'd strongly recommend against filtering warnings like this: this error is generated by MySQL and it absolutely means you are losing data.

The first thing to do would be using the MySQL describe command to make sure that your database column is actually defined to the same size you're expecting: Django has no support for database migrations if you change the length of a column so if your slug field was ever shorter than it is now you'd need to manually alter the table to set the new length:

mysql> DESCRIBE my_table slug;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| slug  | varchar(255) | NO   | UNI | NULL    |       |
+-------+--------------+------+-----+---------+-------+
1 row in set (0.00 sec)

If that field wasn't what you expected you could simply solve the problem by updating the column length:

mysql> ALTER TABLE my_table MODIFY slug VARCHAR(255) NOT NULL;

If you allow Unicode characters in your slugs, that could also explain it as your dump above appears to be using the latin1 character set rather than UTF-8 – a single UTF-8 character can be up to 4 bytes of data, meaning that a value as short as 17 bytes could overflow a VARCHAR(64).

One next debugging step is a simple variation on the call you're making to filter warnings to figure out exactly where your errors are happening:

warnings.simplefilter("error",  category=MySQLdb.Warning)

This will make the warning fatal, which will halt your program, but more importantly will also produce a stacktrace. With something like this, you'll see the output below:

#!/usr/bin/env python
import warnings

def foo():
    warnings.warn("uhoh")

def bar():
    foo()

def main():
    warnings.simplefilter("error", UserWarning)
    bar()

if __name__ == "__main__":
    main()

Without the simplefilter call:

cadams@Io:~ $ python test_warnings.py 
test_warnings.py:5: UserWarning: uhoh
  warnings.warn("uhoh")

With the simplefilter call:

cadams@Io:~ $ python test_warnings.py 
Traceback (most recent call last):
  File "test_warnings.py", line 15, in <module>
    main()
  File "test_warnings.py", line 12, in main
    bar()
  File "test_warnings.py", line 8, in bar
    foo()
  File "test_warnings.py", line 5, in foo
    warnings.warn("uhoh")
UserWarning: uhoh

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)