将字段符号传递给FORM [英] Passing field-symbols into FORM

查看:87
本文介绍了将字段符号传递给FORM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在几处代码中将数据字段(另一个字段符号的组成部分)分配给字段符号。为了可重用性,我决定将此代码封装在过程中,但是我不明白如何将字段符号传递到该过程中。

I need to assign data field (component of another field symbol) to field-symbol in a several places of code. For the sake of reusability I decided to encapsulate this code in procedure, but I cannot understand how to pass field-symbols into this procedure.

LOOP bseg ASSIGNING <bseg>
...
PERFORM assigning USING <bseg>
                  CHANGING <wrbtr>.
...
ENDLOOP.

FORM assigning USING <bseg> TYPE bseg
               CHANGING <wrbtr> TYPE bseg-wrbtr
IF ...
  some logic here
  ASSIGN <bseg>-wrbtr TO <wrbtr>.
ELSE
  ASSIGN <bseg>-skfbt TO <wrbtr>.
ENDIF.

ENDFORM.

此代码无效。

This code does not work.

我也应该怎么更改字段符号引用?

What should I do to change the field symbol reference too?

推荐答案

这是不可能的,至少不是您尝试这样做的方式。字段符号不能作为其真正的指针传递。如果您需要类似的内容,则必须使用真实的引用。

This is not possible, at least not the way you try to do it. Field symbols cannot be passed as the pointers they really are. If you need something like that, you'll have to use real references.

对代码的其余部分一无所知-看起来有点奇怪。您为什么要直接更改BSEG字段中的数据?我只能假设您在整个代码中滥用字段来传递一些自定义值,这通常是个坏主意。而且,如果您需要这样做,我宁愿这样:

Not knowing anything about the rest of your code - it looks a bit weird. Why would you want to change data in BSEG fields directly? I can only assume that you're "abusing" fields to transport some custom value throughout the code, and that's usually a bad idea. And if you need to do this, I'd rather do it this way:

LOOP bseg ASSIGNING <bseg>.
   IF foo.
    l_my_wrbtr = <bseg>-wrbtr.
  ELSE.
    l_my_wrbtr = <bseg>-skfbt.
  ENDIF.

  " ... pro'lly thousands of lines I don't even want to see...

  IF foo.
    <bseg>-wrbtr = l_my_wrbtr.
  ELSE.
    <bseg>-skfbt = l_my_wrbtr.
  ENDIF.
ENDLOOP.    

这篇关于将字段符号传递给FORM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆