ALV Styles in Field catalogue using OOPS

转自http://www.saptechnical.com/Tutorials/ALV/Styles/demo.htm

By Swarna S, Tata Consultancy Services

*&---------------------------------------------------------------------*
*& Report  ZALV_STYLES                                                 *
*& Published at SAPTechnical.COM                                      *
*&---------------------------------------------------------------------*
*& AS : ALV Styles in a fieldcatalogue.                                *
*& The ALV is developed using OOPS and various styles are given for    *
*& each column in the fieldcatalogue                                   *
*&---------------------------------------------------------------------*
REPORT  zalv_styles.
*Include for ALV styles
INCLUDE <cl_alv_control>.
*Type ppols for alv
TYPE-POOLS : slis.
*structure for t582a tbale
TYPES : BEGIN OF ty_table,infty TYPE infty,pnnnn TYPE pnnnn_d,zrmkz TYPE dzrmkz,zeitb TYPE dzeitb,dname TYPE dianm,edynr TYPE edynp,ldynr TYPE ldynp,stypt TYPE stypt,sytxt TYPE sytxt,davo TYPE davo,davoe TYPE davoe,END OF ty_table.
*Structure for infotype text
TYPES : BEGIN OF ty_itext,infty TYPE infty,itext TYPE intxt,sprsl TYPE sprsl,END OF ty_itext.
*Structure for output display
TYPES : BEGIN OF ty_output,infty TYPE infty,itext TYPE intxt,pnnnn TYPE pnnnn_d,zrmkz TYPE dzrmkz,zeitb TYPE dzeitb,dname TYPE dianm,edynr TYPE edynp,ldynr TYPE ldynp,stypt TYPE stypt,sytxt TYPE sytxt,davo TYPE davo,davoe TYPE davoe,text(6) TYPE c,sradio(6) TYPE c,scheck(6) TYPE c,END OF ty_output.
*internal table and work area declarations
DATA : it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,it_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,it_ittext TYPE STANDARD TABLE OF ty_itext INITIAL SIZE 0,wa_table TYPE ty_table,wa_output TYPE ty_output,wa_ittext TYPE ty_itext.
*Data declarations for ALV
DATA: c_ccont TYPE REF TO cl_gui_custom_container,   "Custom container c_alvgd         TYPE REF TO cl_gui_alv_grid,   "ALV grid objectit_fcat            TYPE lvc_t_fcat,            "Field catalogueit_layout          TYPE lvc_s_layo.           "Layout
*Field symbols declarations for style
FIELD-SYMBOLS : <wa_fcat> TYPE lvc_s_fcat.
*initialization event
INITIALIZATION.
*start of selection event
START-OF-SELECTION.
*select the infotypes maintainedSELECT inftypnnnnzrmkzzeitbdnameedynrldynrstyptsytxtdavodavoeFROM t582a UP TO 25 ROWSINTO CORRESPONDING FIELDS OF TABLE it_table.
* *Select the infotype textsIF it_table[] IS NOT INITIAL.SELECT itextinftysprslFROM t582sINTO CORRESPONDING FIELDS OF TABLE it_ittextFOR ALL ENTRIES IN it_tableWHERE infty = it_table-inftyAND sprsl = 'E'.ENDIF.
*Apppending the data to the internal table of ALV outputLOOP AT it_table INTO wa_table.
    wa_output-infty = wa_table-infty.wa_output-pnnnn = wa_table-pnnnn.wa_output-zrmkz = wa_table-zrmkz.wa_output-zeitb = wa_table-zeitb.wa_output-dname = wa_table-dname.wa_output-edynr = wa_table-edynr.wa_output-ldynr = wa_table-ldynr.wa_output-stypt = wa_table-stypt.wa_output-sytxt = wa_table-sytxt.wa_output-davo = wa_table-davo.wa_output-davoe = wa_table-davoe.
* For texts
    READ TABLE it_ittext INTO wa_ittext WITH KEY infty = wa_table-infty.wa_output-itext = wa_ittext-itext.wa_output-text = wa_ittext-sprsl.
    APPEND wa_output TO it_output.CLEAR wa_output.
  ENDLOOP.
* Calling the ALV screen with custom container
  CALL SCREEN 0600.
*On this statement double click  it takes you to the screen painter SE51.
*Enter the attributes
*Create a Custom container and name it CC_CONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
* PBO of the actual screen ,
* Here we can give a title and customized menus
*&---------------------------------------------------------------------*
*&      Module  STATUS_0600  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0600 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.
ENDMODULE.                 " STATUS_0600  OUTPUT
* calling the PBO module ALV_GRID.
*&---------------------------------------------------------------------*
*&      Module  ALV_GRID  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE alv_grid OUTPUT.CREATE OBJECT c_ccontEXPORTINGcontainer_name = 'CC_CONT'.CREATE OBJECT c_alvgd
EXPORTING
i_parent = c_ccont.
*  SET field for ALVPERFORM alv_build_fieldcat.
* Setting the styles for the ALV grid control
* using field-symbols
  LOOP AT it_fcat ASSIGNING <wa_fcat>.
*For Each and every line of the fieldcatCASE sy-tabix.
*Color Styles
*Background/Font/Group/positive/negativeWHEN '1'.<wa_fcat>-style = alv_style_color_inv_positive.WHEN '2'.<wa_fcat>-style = alv_style_color_int_negative.WHEN '3'.<wa_fcat>-style = alv_style_color_inv_negative.WHEN '4'.<wa_fcat>-style = alv_style_color_int_positive.WHEN '5'.<wa_fcat>-style = alv_style_color_background.<wa_fcat>-style = alv_style_color_inv_background.WHEN '6'.<wa_fcat>-style = alv_style_color_group.<wa_fcat>-style = alv_style_color_int_background.
*Style for F4WHEN '7'.<wa_fcat>-style = alv_style_f4.
*Style for Alignment(others are also possible)WHEN '8'.<wa_fcat>-style = alv_style_align_left_bottom.
*Style for Font Underlined/Bold and Italic are possibleWHEN '9'.<wa_fcat>-style = alv_style_font_underlined.
*Style for button typeWHEN '10'.<wa_fcat>-style = alv_style_button.
*Style for Font SymbolWHEN '11'.<wa_fcat>-style = alv_style_font_symbol.
*Style for RadiobuttonWHEN '12'.<wa_fcat>-style = alv_style_radio_checked.
*Style for  checkboxWHEN '13'.<wa_fcat>-style = alv_style_checkbox_checked.
*Style for column style characteristics(highlighting the col)WHEN '14'.<wa_fcat>-style = alv_col_style_characteristic.
*Styles for Enabling the columnWHEN '15'.<wa_fcat>-style = alv_style_enabled.
    ENDCASE.
  ENDLOOP.
* Set ALV attributes FOR LAYOUTPERFORM alv_report_layout.
  CHECK NOT c_alvgd IS INITIAL.
* Call ALV GRID
  CALL METHOD c_alvgd->set_table_for_first_displayEXPORTINGis_layout                     = it_layoutCHANGINGit_outtab                     = it_outputit_fieldcatalog               = it_fcatEXCEPTIONSinvalid_parameter_combination = 1program_error                 = 2too_many_lines                = 3OTHERS                        = 4.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.
ENDMODULE.                 " ALV_GRID  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  alv_build_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_IT_FCAT  text
*----------------------------------------------------------------------*
*subroutine to build fieldcat
FORM alv_build_fieldcat.
  DATA lv_fldcat TYPE lvc_s_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '1'.lv_fldcat-fieldname = 'INFTY'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 8.lv_fldcat-scrtext_m = 'Infotype'.lv_fldcat-icon = 'X'.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '2'.lv_fldcat-fieldname = 'PNNNN'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 15.lv_fldcat-scrtext_m = 'Structure'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '3'.lv_fldcat-fieldname = 'ITEXT'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 60.lv_fldcat-scrtext_m = 'Description'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '4'.lv_fldcat-fieldname = 'TEXT'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 5.lv_fldcat-scrtext_m = 'General'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '5'.lv_fldcat-fieldname = 'ZRMKZ'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 1.lv_fldcat-scrtext_m = 'PERIOD'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '6'.lv_fldcat-fieldname = 'ZEITB'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 60.lv_fldcat-scrtext_m = 'Time constraint'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '7'.lv_fldcat-fieldname = 'DNAME'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 15.lv_fldcat-scrtext_m = 'Dialogmodule'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '8'.lv_fldcat-fieldname = 'EDYNR'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'Single screenno'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '9'.lv_fldcat-fieldname = 'LDYNR'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'List screenno'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '10'.lv_fldcat-fieldname = 'STYPT'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'SubtypeTable'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '11'.lv_fldcat-fieldname = 'SYTXT'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'Font Symbol'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '12'.lv_fldcat-fieldname = 'SRADIO'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'RADIO'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '13'.lv_fldcat-fieldname = 'SCHECK'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'CHECK'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '14'.lv_fldcat-fieldname = 'DAVO'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'Start Date'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
  lv_fldcat-row_pos   = '1'.lv_fldcat-col_pos   = '15'.lv_fldcat-fieldname = 'DAVOE'.lv_fldcat-tabname   = 'IT_OUTPUT'.lv_fldcat-outputlen = 10.lv_fldcat-scrtext_m = 'End date'.lv_fldcat-icon = ''.APPEND lv_fldcat TO it_fcat.CLEAR lv_fldcat.
ENDFORM.                    " alv_build_fieldcat
*&---------------------------------------------------------------------*
*&      Form  alv_report_layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_IT_LAYOUT  text
*----------------------------------------------------------------------*
*Subroutine for setting alv layout
FORM alv_report_layout.it_layout-cwidth_opt = 'X'.it_layout-zebra = 'X'.it_layout-col_opt = 'X'.
ENDFORM.                    " alv_report_layout
* PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes
*and based on the user command we can do the coding.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0600  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0600 INPUT.
ENDMODULE.                 " USER_COMMAND_0600  INPUT

Output

Part 1

(Continued output)

Part 2 

转载于:https://www.cnblogs.com/kalasitifen/archive/2012/10/16/2726260.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/294930.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

自称“房奴”的博士靠开店卖SCI论文10年盈利近百万,论文买卖你怎么看?

全世界只有3.14 % 的人关注了爆炸吧知识本文来源&#xff1a;中国青年报、武汉晚报 首席记者杨佳峰导读&#xff1a;10年前&#xff0c;一位自称“房奴博士”的刚毕业博士生在网上开启了他的SCI售卖小铺。每篇 1-2 万元&#xff0c;声称一年内卖出去的论文中有 8 篇都进了SCI索…

既生瑜何生亮 access_token VS refresh_token

中国有句老话, 既生瑜何生亮, 既然有我周瑜在世, 为什么老天还要一个诸葛亮啊&#xff1f;同样的, 众所周知, 在 OAuth 2.0 授权协议中, 也有两个令牌 token , 分别是 access_token 和 refresh_token, 为什么已经有了 access_token, 还需要 refresh_token 呢?我们先看下面两者…

关于计算机软件系统的知识,二、计算机软件系统基本知识

一、计算机软件系统图示咱们先来直观的看一下&#xff0c;我就直接上图了打开今日头条&#xff0c;查看更多精彩图片计算机软件系统(一)系统软件在说系统软件之前我想用一张图让大家清晰的了解下&#xff0c;计算机硬件系统与软件系统的关系&#xff1a;计算机硬件系统与软件系…

Nature评选年度十大科学发现:北师大博士凭借天眼研究入选!

全世界只有3.14 % 的人关注了爆炸吧知识本文来源&#xff1a;Bio生物世界、北京师范大学新闻网、百度百科、北京师范大学官网近日&#xff0c;Nature 盘点了2020年度十大科学发现&#xff0c;这其中即包括新冠病毒研究、冷冻电镜突破、压力导致白发的原因、HIV治疗、银河系中的…

Android之集成友盟推送功能

友盟是中国最大的移动开发者服务平台,为移动开发者提供免费的应用统计分析、社交分享、消息推送、自动更新、在线参数、移动推广效果分析、微社区等app开发和运营解决方案。 如何快速集成友盟推送功能&#xff1a; 1. 注册友盟账号 友盟开发者账号的注册地址:http://www.umeng.…

Win11手机应用大改!全新界面来袭

在 Windows 11 中&#xff0c;应用商店、画图、照片、计算器等系统内置应用都获得了全新的改进&#xff0c;这回终于轮到你的手机应用了。在今年 9 月的微软 Windows 11 硬件暨全新 Surface 设备发布会上&#xff0c;微软曾简要地展示了 Windows 11 内置应用 Your Phone&#x…

serialization机制

首先说明一下序列化的知识&#xff1a; java中的序列化(serialization)机制能够将一个实例对象的状态信息写入到一个字节流中&#xff0c;使其可以通过socket进行传输、或者持久化存储到数据库或文件系统中&#xff1b;然后在需要的时候&#xff0c;可以根据字节流中的信息来重…

java2的7次方怎么表示_静态市盈率要怎么看?

静态市盈率是估值一个公司质地的指标&#xff0c;同时它也就是大家常说的市盈率。它体现的是一个企业按照目前的盈利水平&#xff0c;我们买入后需要多长时间才能回本。那么静态市盈率高好还是低好呢&#xff1f;静态市盈率低好&#xff0c;高就意味着该股高估了。静态市盈率是…

中国科幻扛鼎之作,原来真的不止刘慈欣

▲ 点击查看50年前的某天&#xff0c;一个小孩和一群大人一起仰望着晴朗的天空&#xff0c;看着中国第一颗人造卫星“东方红一号”&#xff0c;默默地担心它会撞到其他星星。而这份小小的担心&#xff0c;成了他后来开始创造科幻的动力和梦想。这个仰望晴空的小孩叫刘慈欣。如果…

程学旗 计算机,徐明伟-青年科学家奖-中国计算机学会

2010CCF青年科学家奖获奖者徐明伟 教授清华大学分别于1994年和1998年在清华大学计算机科学与技术系获工学学士和工学博士学位。现为清华大学计算机系教授&#xff0c;博士生导师&#xff0c;网络所所长&#xff0c;计算机学会YOCSEF AC委员&#xff0c;中国通信标准化协会技术管…

.net6给winform带来的新功能

首先简化了Program文件&#xff0c;引入了全局命名空间&#xff0c;但顶级语句由于Main函数的特性[STAThread]没有引用进来。namespace WinFormsDemo {internal static class Program{/// <summary>/// The main entry point for the application./// </summary>[…

男生的哪个“不要”是真的不要?

1 每天一个被炒小技巧&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼2 今天你能接到水算我输&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼3 如何形容自己没钱&#xff1f;&#xff08;素材来源网络&#xff0c;侵删&#xff09;▼4 猜中了开头没猜中结…

Git之如何解决Error:pathspec ‘/layout/radar_chart.xml‘ did not match any file(s) known to

不废话&#xff0c;先爆错误图片 问题产生原因&#xff1a; 我把android studio里面的项目提交到github里面的时候&#xff0c;出现了了error: pathspec app/src/main/res/layout/radar_chart.xml did not match any file(s) known to git.&#xff0c;因为我一开始新建了一个文…

江诗丹顿geneve系列_江诗丹顿的另一面

江诗丹顿在售表款目录里&#xff0c;不算阁楼工匠定制系列&#xff0c;你猜最贵的是哪一款&#xff1f;​答案不是包含三问、万年历和陀飞轮功能的传袭系列超卓复杂腕表&#xff0c;而是一枚具有简单时分功能的高级珠宝表款。打开江诗丹顿的官方微信公众号&#xff0c;进入微信…

程序内存一直在泄漏,原来是异步死循环了 !

一&#xff1a;背景 1. 讲故事上个月有位朋友找到我&#xff0c;说他的程序出现了内存泄漏&#xff0c;不知道如何进一步分析&#xff0c;截图如下&#xff1a;朋友这段话已经说的非常言简意赅了&#xff0c;那就上 windbg 说话吧。二&#xff1a;Windbg 分析 1. 到底是哪一方面…

太巧了!学霸夫妻携手进入武大读博,两人的硕士导师也是一对夫妻

全世界只有3.14 % 的人关注了爆炸吧知识本文募格学术撰写。参考来源&#xff1a;湖北日报、双一流大学网、募格学术此前报道等科研人的爱情是什么样子&#xff1f;或许是在学术的路上他们相识相知&#xff0c;往后也将共同拼搏&#xff0c;在科研领域擦出更多火花~前段时间&…

github怎么隐藏自己的pr记录_记便签的软件哪个好?怎么及时记录自己的想法

我们在平时的工作和生活中&#xff0c;如果遇到一些需要及时记下来的东西时&#xff0c;很多人都会选用在便签中记录下来的方式。对于记便签的软件来说&#xff0c;不同的品牌有不同的特点&#xff0c;要想在众多便签软件中选择出一款适合自己的&#xff0c;就需要下点功夫了&a…

bkwin设置文本控件为多行模式

2019独角兽企业重金招聘Python工程师标准>>> 指定textmode&#xff0c; 给到文本控件的区域 <class name"xxxxx" textmode"40A011"/> textmode是DT_FROMT位或值 DrawText api对应的formt 转载于:https://my.oschina.net/u/2436679/bl…

性能测试组件CodeBenchmark V2发布

CodeBenchmark是一款可视化的性能测试组件&#xff0c;通过组件可以对一个或多个功能代码进行一个并发测试&#xff1b;最终通过详细的测试结果来对比不同代码的性能差异。组件的使用非常简单&#xff0c;构建一个控制台程序然后引入BeetleX.CodeBenchmark组件编写几个代码即可…

一所传闻要被“降级”的211高校,让这位网红教授“救活了”

全世界只有3.14 % 的人关注了爆炸吧知识本文来源&#xff1a;量子位&#xff08; ID: QbitAI&#xff09; 作者&#xff1a;金磊 发自 凹非寺太原理工大学&#xff0c;最近着实有点火。先是11月12日至13日&#xff0c;其官网一口气更新了3位「杰青」副校长&#xff0c;在高校任…