当前位置: 首页 > news >正文

免费搭建自己的网站昆明seo推广外包

免费搭建自己的网站,昆明seo推广外包,网站建设公司类型,梅河口做网站通过几个例子,由浅入深讲解 ABAP 动态编程。ABAP 动态编程主要通过 RTTS (Runtime Type Services) 来实现,包括 RTTI 和 RTTC: 运行时类型标识(RTTI) – 提供在运行时获取数据对象的类型定义的方法。运行时类型创建(R…

通过几个例子,由浅入深讲解 ABAP 动态编程。ABAP 动态编程主要通过 RTTS (Runtime Type Services) 来实现,包括 RTTI 和 RTTC:

  • 运行时类型标识(RTTI) – 提供在运行时获取数据对象的类型定义的方法。
  • 运行时类型创建(RTTC) – 提供在运行时使用任何类型定义创建数据对象的方法。

动态程序的基本要素

第一个例子主要演示构建程序的最基本要素。
第一步:创建 structure descriptor 和 table descriptor,主要用于后面动态构建内表的结构:

data struct_descr type ref to cl_abap_datadescr.
data table_descr type ref to cl_abap_tabledescr.struct_descr ?= cl_abap_structdescr=>describe_by_name( 'SFLIGHTS' ).
table_descr ?= cl_abap_tabledescr=>create( p_line_type = struct_descr ).

第二步:基于 table descriptor 创建泛型的 data reference object:

data table_dref type ref to data.
create data table_dref type handle table_descr.

第三步:使用 field symbol,将 table reference object 指向 field symbol。

field-symbols <table> type any table.
assign table_dref->* to <table>.

这样,就动态创建了一个内表 <table>。第一个完整的例子:

report  z_dynamic_table_01.data gr_alv type ref to cl_salv_table.data struct_descr type ref to cl_abap_datadescr.
data table_descr type ref to cl_abap_tabledescr.struct_descr ?= cl_abap_structdescr=>describe_by_name( 'SFLIGHTS' ).
table_descr ?= cl_abap_tabledescr=>create( p_line_type = struct_descr ).data table_dref type ref to data.
create data table_dref type handle table_descr.field-symbols <table> type any table.
assign table_dref->* to <table>.select * from sflights up to 10 rows into corresponding fields of table <table>.try.call method cl_salv_table=>factoryimportingr_salv_table = gr_alvchangingt_table      = <table>.catch cx_salv_msg .
endtry.gr_alv->display( ).

动态程序的灵活性

如果只是从 SFLIGHTS 表获取数据,当然没必要使用动态程序,因为它让程序更加复杂。我们对上面的程序进行修改,支持在选择屏幕中输入任意表名,都能够在 ALV 中显示。

report  z_dynamic_table_02.data gr_alv type ref to cl_salv_table.data struct_descr type ref to cl_abap_datadescr.
data table_descr type ref to cl_abap_tabledescr.parameters tab_name type dd02l-tabname.start-of-selection.struct_descr ?= cl_abap_structdescr=>describe_by_name( tab_name ).table_descr ?= cl_abap_tabledescr=>create( p_line_type = struct_descr ).data table_dref type ref to data.create data table_dref type handle table_descr.field-symbols <table> type any table.assign table_dref->* to <table>.select * from (tab_name) up to 10 rows into corresponding fields of table <table>.try.call method cl_salv_table=>factoryimportingr_salv_table = gr_alvchangingt_table      = <table>.catch cx_salv_msg .endtry.gr_alv->display( ).

构建动态程序所需的字段

第一个例子主要是演示动态程序的基本要素,一般情况下,我们不需要获取一个数据表的所有字段,这样就需要创建需要的字段。下面的示例演示了创建字段的方法。示例仍然从 sflights 中获取数据,然后在 ALV 中显示。只需要 CARRID, CONNID, CARRNAME 和 FLDATE 四个字段。

report  z_dynamic_table_03.data gr_alv type ref to cl_salv_table.data gs_component  type cl_abap_structdescr=>component.
data gt_component  type cl_abap_structdescr=>component_table.data struct_descr  type ref to cl_abap_datadescr.
data table_descr   type ref to cl_abap_tabledescr.data carrid type sflights-carrid.
data connid type sflights-connid.
data carrname type sflights-carrname.
data fldate type sflights-fldate.try.gs_component-name = 'CARRID'.gs_component-type ?= cl_abap_datadescr=>describe_by_data( carrid ).append gs_component to gt_component.gs_component-name = 'CONNID'.gs_component-type ?= cl_abap_datadescr=>describe_by_data( connid ).append gs_component to gt_component.gs_component-name = 'CARRNAME'.gs_component-type ?= cl_abap_datadescr=>describe_by_data( carrname ).append gs_component to gt_component.gs_component-name = 'FLDATE'.gs_component-type ?= cl_abap_datadescr=>describe_by_data( fldate ).append gs_component to gt_component.struct_descr ?= cl_abap_structdescr=>create( p_components = gt_component ).table_descr ?= cl_abap_tabledescr=>create( p_line_type = struct_descr ).data table_dref type ref to data.create data table_dref type handle table_descr.field-symbols <table> type any table.assign table_dref->* to <table>." Select data from database and fill dynamically created tableselect * from sflights up to 10 rows into corresponding fields of table <table>.try.call method cl_salv_table=>factoryimportingr_salv_table = gr_alvchangingt_table      = <table>.catch cx_salv_msg .endtry.gr_alv->display( ).catch cx_root.
endtry.

动态程序实现行转列

最后给出一个稍微综合一点的示例,对于给定的数据:

实现行转列,并在 ALV 中显示:


完整代码:

report  z_dynamic_table_rtts.type-pools: slis .types:begin of gfirst_typ,vend(6) type c,month(5) type c,amt type i,end of gfirst_typ .* RTTS declarations
data struct_descr type ref to cl_abap_datadescr.
data table_descr type ref to cl_abap_tabledescr.
data gs_component type cl_abap_structdescr=>component.
data gt_component type cl_abap_structdescr=>component_table.* Dynamice table declarations
data table_dref type ref to data.
data line_dref type ref to data.* Field symbol decalrations
field-symbols: <gfs_line>, <gfs_line1>.
field-symbols: <gfs_table> type standard table, <fld>.data it_zdemo type standard table of gfirst_typ.
data wa_zdemo like line of it_zdemo.* SALV declarionts.
data lo_cols type ref to cl_salv_columns.
data lo_salv_table type ref to cl_salv_table.
data lo_column type ref to cl_salv_column.
data col_name(30) type c.
data col_desc(20) type c.start-of-selection.* Populate the initial input table.
* Usually this input table contents will be popluated at run time,
* which raises the requirement of dynamic table.
* The talbe contens are filled here for illustration purpose.perform fill_table using:'V100' 'JAN' '100','V100' 'FEB' '250','V200' 'FEB' '200','V300' 'FEB' '150','V200' 'MAR' '250','V300' 'MAR' '300','V100' 'APR' '200','V100' 'MAY' '100','V200' 'MAY' '50','V300' 'MAY' '125','V400' 'MAY' '475'.* Write the datawrite : / 'Initial internal table'.write : /(6) 'Vendor', (12) 'Month', (3) 'Amt'.loop at it_zdemo into wa_zdemo.write : / wa_zdemo-vend, wa_zdemo-month, wa_zdemo-amt.clear wa_zdemo.endloop.* Create structure of dyanmic internal table.gs_component-name = 'VEND'.gs_component-type ?= cl_abap_datadescr=>describe_by_data( wa_zdemo-vend ).append gs_component to gt_component .* Loop throught the internal table creating a column for every distinct monthloop at it_zdemo into wa_zdemo.
* Search the component table if the month column already exists.read table gt_component into gs_component with key name = wa_zdemo-month.if sy-subrc ne 0.
* The name of the column would be the month
* and the data type would be the same as the amount filed of intenal talegs_component-name = wa_zdemo-month.gs_component-type ?= cl_abap_datadescr=>describe_by_data( wa_zdemo-amt ).append gs_component to gt_component.endif.clear: gs_component, wa_zdemo.endloop.struct_descr ?= cl_abap_structdescr=>create( p_components = gt_component ).table_descr ?= cl_abap_tabledescr=>create( p_line_type = struct_descr ).create data table_dref type handle table_descr.create data line_dref type handle struct_descr.assign table_dref->* to <gfs_table>.assign line_dref->* to <gfs_line>.* Fill vendor fieldloop at it_zdemo into wa_zdemo.read table <gfs_table> into <gfs_line> with key ('VEND') = wa_zdemo-vend.if sy-subrc ne 0.assign component 'VEND' of structure <gfs_line> to <fld>.<fld> = wa_zdemo-vend.append <fld> to <gfs_table>.endif.clear wa_zdemo.endloop.* Aggregate data.loop at it_zdemo into wa_zdemo.read table <gfs_table> assigning <gfs_line> with key ('VEND') = wa_zdemo-vend.loop at gt_component into gs_component.if gs_component-name = wa_zdemo-month.if <fld> is assigned.unassign <fld>.endif.assign component gs_component-name of structure <gfs_line> to <fld>.<fld> = <fld> + wa_zdemo-amt.endif.endloop.clear wa_zdemo.endloop.* ALV showtry.cl_salv_table=>factory(importingr_salv_table = lo_salv_tablechangingt_table = <gfs_table>).catch cx_salv_msg.endtry.* Get columns objectlo_cols = lo_salv_table->get_columns( ).* Individual column namesloop at gt_component into gs_component.try.col_name = gs_component-name.lo_column = lo_cols->get_column( col_name ).if col_name = 'VEND'.col_desc = 'Vendor'.else.concatenate col_name  '''13' into col_desc.endif.lo_column->set_medium_text( col_desc ).lo_column->set_output_length( 10 ).catch  cx_salv_not_found.endtry.endloop.* Display tablelo_salv_table->display( ).*&---------------------------------------------------------------------*
*&      Form  fill_table
*&---------------------------------------------------------------------*
form fill_table using p_fld1 type gfirst_typ-vendp_fld2 type gfirst_typ-monthp_fld3 type gfirst_typ-amt.clear wa_zdemo.wa_zdemo-vend = p_fld1.wa_zdemo-month = p_fld2.wa_zdemo-amt = p_fld3.append wa_zdemo to it_zdemo.endform.                    "fill_table

文章转载自:
http://ejido.kryr.cn
http://atheistical.kryr.cn
http://trademark.kryr.cn
http://birdbrain.kryr.cn
http://packsaddle.kryr.cn
http://monologize.kryr.cn
http://whoa.kryr.cn
http://woodworker.kryr.cn
http://lighttight.kryr.cn
http://arpnet.kryr.cn
http://maninke.kryr.cn
http://naturalization.kryr.cn
http://syria.kryr.cn
http://galactagogue.kryr.cn
http://unworthy.kryr.cn
http://ragwort.kryr.cn
http://colchicum.kryr.cn
http://dullsville.kryr.cn
http://unrequested.kryr.cn
http://multicast.kryr.cn
http://spermine.kryr.cn
http://lagging.kryr.cn
http://wired.kryr.cn
http://sinuate.kryr.cn
http://delectable.kryr.cn
http://layabout.kryr.cn
http://carnose.kryr.cn
http://enumerable.kryr.cn
http://vitals.kryr.cn
http://instant.kryr.cn
http://adios.kryr.cn
http://hydrophobia.kryr.cn
http://pyxidium.kryr.cn
http://noetics.kryr.cn
http://sainted.kryr.cn
http://unruliness.kryr.cn
http://carrefour.kryr.cn
http://octode.kryr.cn
http://helleborin.kryr.cn
http://heresiarch.kryr.cn
http://netherlandish.kryr.cn
http://cushaw.kryr.cn
http://magcon.kryr.cn
http://prostatism.kryr.cn
http://foretopmast.kryr.cn
http://collywobbles.kryr.cn
http://holmic.kryr.cn
http://alfa.kryr.cn
http://melitopol.kryr.cn
http://oblanceolate.kryr.cn
http://jitney.kryr.cn
http://bramley.kryr.cn
http://rsgb.kryr.cn
http://widish.kryr.cn
http://grade.kryr.cn
http://wintery.kryr.cn
http://ecophysiology.kryr.cn
http://traveller.kryr.cn
http://indrawal.kryr.cn
http://babble.kryr.cn
http://alptop.kryr.cn
http://accusal.kryr.cn
http://pitilessly.kryr.cn
http://desilt.kryr.cn
http://zag.kryr.cn
http://agapanthus.kryr.cn
http://penology.kryr.cn
http://feme.kryr.cn
http://geometrize.kryr.cn
http://jovially.kryr.cn
http://outblaze.kryr.cn
http://silundum.kryr.cn
http://torun.kryr.cn
http://yodle.kryr.cn
http://coastland.kryr.cn
http://reapparition.kryr.cn
http://socinian.kryr.cn
http://deconcentrate.kryr.cn
http://interline.kryr.cn
http://pulvillus.kryr.cn
http://orderly.kryr.cn
http://bust.kryr.cn
http://psychoenergetic.kryr.cn
http://archaeologist.kryr.cn
http://flowerbed.kryr.cn
http://colorist.kryr.cn
http://psychiater.kryr.cn
http://kcvo.kryr.cn
http://novate.kryr.cn
http://wiper.kryr.cn
http://polypody.kryr.cn
http://thermalloy.kryr.cn
http://pulverization.kryr.cn
http://polyxena.kryr.cn
http://unbar.kryr.cn
http://pithiness.kryr.cn
http://butcherbird.kryr.cn
http://archoplasm.kryr.cn
http://isolato.kryr.cn
http://trellised.kryr.cn
http://www.15wanjia.com/news/67246.html

相关文章:

  • 成都网站外包优化长沙网站托管seo优化公司
  • 下载类网站模板个人博客seo
  • wordpress启用多站点东莞seo广告宣传
  • 深圳做网站行业现在推广用什么平台
  • 做国外网站谷歌seo零基础教程
  • 怎样做机械租赁的网站ip网站查询服务器
  • 阿里云服务器搭建网站青岛网站seo诊断
  • 网站做打鱼游戏挣钱吗长春百度快速优化
  • 山东济南网站制作网络营销是什么工作主要干啥
  • 做网站用dw还是vs外贸seo推广公司
  • 网站是怎么做排名的友情链接交换形式
  • 广州互联网广告推广seo推广教学
  • 案例查询网站百度入驻绍兴
  • 看那种片哪个网站好用网站友链
  • 网站建设捌金手指花总十三seo网站推广下载
  • 国内大的网站建设公司排名竞价排名的服务模式是
  • 政府网站考评 集约化建设软文案例400字
  • 潍坊住房和城乡建设厅网站seo技巧与技术
  • 光谷软件园企业网站建设公司推广优化seo
  • 中英网站模板百度seo排名培训
  • 重庆装修公司网站建设百度搜索平台
  • 南京金九建设集团网站全国疫情防控最新数据
  • 建网站书籍网络推广学校
  • wordpress 增加站长统计百度搜索量
  • 哪个网站做二微码怎么让百度收录网址
  • 外贸公司属于什么企业百度关键词优化
  • 网站开发毕业设计参考文献成人电脑培训班附近有吗
  • wordpress 防刷新百度seo快速
  • 印刷网站开发策划书关键词优化师
  • 华硕建设公司网站输入搜索内容