在运行时可能生成ABAP报告吗? [英] Generation of ABAP report in runtime possible?

查看:133
本文介绍了在运行时可能生成ABAP报告吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何可以生成ABAP代码的功能模块。
例如:FM将表名和连接条件作为输入并生成与之对应的ABAP代码。

Is there any Function module that can generate ABAP code. For eg: FM takes tables name and join conditions as input and generate ABAP code corresponding to that.

谢谢

推荐答案

1。可能会生成通用报告。

您的问题是,您将必须对什么是
通用对象进行严格的界定,而对于不是,意味着,某些东西必须是通用的,它会处理
的任何内容,而您之前想要做的(主要是选择),在处理过程中的
(主要是操纵--->为此,我会提供一个badi) ,并输出。
这意味着,至少存在输出步骤,该步骤对于之前步骤产生的所有
数据均有效。
考虑一个通用的ALV-table_output,回购中有很多示例。
如果您想成为简单地打印成列表的内容,则可能包括
的更多工作,例如,结构有多大,Dou You换行时等等,请考虑使用标志

Your problem is, that You will have to draw a strict frame of what is generic and what not, this means, some stuff MUST be that generic, that it will deal with WHATEVER You want to do before ( mostly the selection ) , during ( mostly manipulation ---> I would offer a badi for that ), and output. This means, that there is at least the output-step, which can be valid for ALL data resulting from the steps before. Consider a generic ALV-table_output, there are a lot of examples in the repo. If You want to be the stuff printed out simple as list, this might include more work, like, how big is the structure, when Dou You wrap a line, and so on, consider using a flag which allows to toggle the type of output .

2。通用报表是可传输的对象。

这是指第一点。定义明确的阶段和界限。该报告做什么,它不能做什么。因为即使在客户的命名空间中,每个修改仍将被放入传输层。因此,必须对特征/限制进行严格定义,以使由于哦,但我们也需要语句而导致的传输量不会变成无限大。

This refers to point one. Define clear stages and limits. What does the report do, and what is it not able to do. Because, even if it is in customer's namespace, each modification still will be put into transport-layers. Therefore a strict definition of features/limits is necessary so that the amount of transports due to "oh, but we also need that"-statements will not become infinite.

<强> 2。通用报告很严格。

这是什么意思?如果未正确设置,则可能要解析传递的数据(表名称,join-binding,selection-parameter-values)并引发异常。很多工作。你应该为此提供一个巴迪。如果您不这样做,请期待转储。让它转储。最后,您的report-api的用户应该知道(也许是通过文档)如何调用它。否则,将导致动态SQL转储。

What does that mean ? You might want to parse the passed data ( table names, join-binding, selection-parameter-values ) and throw exceptions, if not properly set. Much work. You should offer a badi for that. If You do not do this, expect a dump. let it dump. In the end the user of Your report-api should know ( by documentation perhaps) how to call it. If not, a dynamic SQL-dump will be the result.

3。常规报告可能会受益于badis / exit。

我认为这是不言而喻的。特别是通用/动态选择/修改/显示数据应该可以根据
自定义修改进行扩展。当您检查时,f4-search-help出口的工作方式是什么,您会明白我的意思。

This is self explanaining, I think. Especially generic/dynamic selection/modification/displaying of data should be extendable in terms of custom-modifications. When You inspect, what a f4-search-help exit works like, You will understand, what I mean.

4。通用代码很难调试,主要是黑箱。
自我解释,在下面的代码部分中,我可以标记其中一些部分。

4. Generic coding is hard to debug, mostly a blackbox. Self explaining, in the code-section below I can mark some of those sections.

5。通用编码在回购协议中有一些最好的规范示例。

不要重新发明轮子。通过调试来检查se16n的工作方式,
通过调试来检查se11的工作方式。检查SQL-Query-builder
在调试器中的外观。您很快就会想到这个主意,
和复制粘贴应该是您工作中最简单的部分。

Do not reinvent the wheel. Check, how the se16n works by debugging it, check how se11 works by debugging it. Check, what the SQL-Query-builder looks like in the debugger. You will get the idea very soon, and the copy-paste should be the most simple part of Your work.

6。那就是您可能使用的基本部分。

Where子句确定和设置参数。

Where clause determination and setting the params.

 data lt_range     type rsds_trange.
 data ls_range_f   type rsds_frange.
 data lt_where     type rsds_twhere.
 data ls_where     like line of lt_where.


ls_range_f =  value #( sign   = _sign
                       option = _option
                       low    = _low
                       high   = _high ). 


.
.
.

append ls_frange to lt_range.
.
.
.

 call function 'FREE_SELECTIONS_RANGE_2_WHERE'
  exporting
    field_ranges  = lt_range
  importing
    where_clauses = lt_where.

您有了参数,让我们创建选择结果表。

You have the parameter, let us create the select-result-table.

data(lt_key) = value abap_keydescr_tab( for line in _joinfields)
                                                  ( name = fieldname ) ).
data(lo_structdescr) = cast cl_abap_structdescr(    cl_abap_structdescr=>describe_by_name( _struct_name ) ).
data(lo_tabledescr)  = cl_abap_tabledescr=>create( line_type  = lo_structdescr                                                       p_key        = lt_key ).

create data ro_data type handle lo_tabledescr.



. . .

 select  (sel_st)
    from    (sel_bind)
    into    corresponding fields of table t_data
    where   (dyn_where).

然后将seelct-table-result-reference分配给该选择的通用表。

Then assign the seelct-table-result-reference to the generic table of this select.

您是否需要更多提示?

这篇关于在运行时可能生成ABAP报告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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