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

查看:21
本文介绍了将字段符号传递到 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天全站免登陆