如何定义 2 列数组 A = 1, B = 2...ZZZ =?
我需要在 ABAP 中创建一个 2 列数组,以便程序可以查找记录项(由字母 A - ZZZ 定义),然后返回与其关联的数字。
例如:
A = 1
B = 2
C = 3
...
Z = 26
AA = 27
AB = 28
...
AZ =
文学士 =
...
BZ =
CA =
...
...
ZZZ =
请您建议我如何编码。
有比编写数组更好的选择吗?
谢谢。
I need to create a 2 column array in ABAP so that a program can look up a record item (defined by the letters A - ZZZ) and then return the number associated with it.
For example:
A = 1
B = 2
C = 3
...
Z = 26
AA = 27
AB = 28
...
AZ =
BA =
...
BZ =
CA =
...
...
ZZZ =
Please can you suggest how I can code this.
Is there a better option than writing an array?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您不需要查找表中的值。这是可以计算的:
我没有测试该程序,并且它非常肯定有一些语法错误。但其背后的算法应该有效。
you don't need to lookup the value in a table. this can be calculated:
i didn't test the program and it has pretty sure some syntax errors. but the algorithm behind it should work.
也许我误会了,但你不想要这样的东西吗?
然后一旦填充完毕,请读回它
,不幸的是,ABAP 中不存在数组,但哈希表是为这种查找(快速访问、唯一键)而设计的。
perhaps I'm misunderstanding, but don't you want something like this?
then once it's populated, read it back
unfortunately, arrays don't exist in ABAP, but a hashed table is designed for this kind of lookup (fast access, unique keys).
执行后使用此代码。
Use this code after executing.
我不久前也做过类似的实现。
检查一下它是否适合您。
这里的算法使用递归逻辑来确定数字中的列索引。
这不是我的算法,但已适应在 ABAP 中使用。
原来的算法是在Open Excel中使用的,现在找不到任何链接。
I did a similar implementation some time back.
Check this it it works for you.
Here The algorithm uses a recursive logic to determine the column index in numbers.
This is not my algorithm but have adapted to be used in ABAP.
The original algorithm is used in Open Excel, cant find any links right now.