REPORT ZME12_BDC1.
*REPORT demo_select_dynamic_conditions .
TABLES: makt,dd02t,marc.
TYPE-POOLS : ABAP.
DATA where_tab() OCCURS WITH HEADER LINE.
DATA where_tab2() OCCURS WITH HEADER LINE.
DATA : wa_itab LIKE makt OCCURS WITH HEADER LINE.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA:wa LIKE idetails WITH HEADER LINE. DATA:BEGIN OF get_table occurs ,
tabname TYPE string,"表名
fieldname LIKE dd03l-fieldname,"字段名称
rollname LIKE dd03l-rollname,"资料元素
inttype LIKE dd03l-inttype, "类型
END OF get_table. SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS:p_field TYPE string OBLIGATORY.
PARAMETERS: s_trx TYPE string LOWER CASE." LOWER CASE 大小写不转换
SELECTION-SCREEN END OF BLOCK B1. INITIALIZATION. START-OF-SELECTION.
*--->去掉前导
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
* EXPORTING
* input = s_trx
* IMPORTING
* output = s_trx.
*IF cl_abap_matcher=>matches(
* pattern = '^(-?[1-9]\d*(\.\d*[1-9])?)|(-?0\.\d*[1-9])$'
* text = s_trx ) = abap_true.
*
** WRITE '数字'.
* CONCATENATE p_field ' EQ ''' s_trx '''' INTO where_tab.
*ELSE.
*
** WRITE '非数字'.
* CONCATENATE p_field ' LIKE ''%' s_trx '%''' INTO where_tab.
*ENDIF.
* CONCATENATE p_field ' LIKE ''%' s_trx '%''' INTO where_tab.
* APPEND where_tab. * CONCATENATE p_field ' NE ''''' INTO where_tab2.
* APPEND where_tab2.
* CLEAR where_tab2. TYPE-POOLS : ABAP.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat. DATA:wa_structure TYPE lvc_s_fcat,
wa_structure1 TYPE lvc_s_fcat,
gt_structure TYPE lvc_t_fcat. DATA: gs_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE slis_fieldcat_alv. START-OF-SELECTION.
PERFORM data_table.
PERFORM get_col.
PERFORM alv_show.
END-OF-SELECTION. FORM data_table.
DATA: l_count TYPE i. DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
DATA : ef_is_unicode LIKE /bdl/tasks-status.
DATA:l_value TYPE string.
DATA: l_index TYPE sy-tabix,
lv_comt TYPE i,
l_num TYPE i,
p_len TYPE n. gs_layout-colwidth_optimize = 'X'.
p_len = strlen( s_trx ).
"查询ABAP 所有table表格
SELECT dd02vv~TABNAME
dd03l~fieldname
dd03l~rollname
dd03l~inttype
COUNT(*) FROM dd02vv
INNER JOIN dd02l ON dd02l~tabname EQ dd02vv~tabname
INNER JOIN dd03l ON dd03l~tabname EQ dd02vv~tabname
* UP TO ROWS
INTO CORRESPONDING FIELDS OF TABLE get_table
WHERE dd02vv~tabclass IN ('TRANSP','CLUSTER','POOL') AND " 透明表
dd02vv~contflag NE 'L' AND " 存储时资料的表格,空传送
dd02vv~as4local NOT IN ( 'N','T' ) AND " 未启用,临时版本
( dd03l~fieldname EQ p_field OR
dd03l~rollname EQ p_field ) AND
* dd02vv~tabname NOT IN ( 'DF50D' ,'DF40D' ) AND
dd03l~LENG >= p_len AND
is_gtt NE 'X' " X全局临时表 N 没有全局临时表
GROUP BY dd02vv~tabname dd03l~fieldname
dd03l~rollname dd03l~inttype. "字符小写转换大写
TRANSLATE p_field to UPPER CASE.
"创建内表结构
PERFORM new_teble.
" 创建内表
PERFORM create_dynamic_itab. LOOP AT get_table.
l_index = sy-tabix.
CLEAR: l_num.
"查询表格内容是否有值
SELECT COUNT(*) INTO l_num
UP TO ROWS
FROM (get_table-tabname).
IF sy-subrc <> .
DELETE get_table INDEX l_index.
CONTINUE.
ENDIF.
** DESCRIBE TABLE get_table-tabname LINES index_z
** n = lines(get_table-tabname).
*
* "***获取表结构
* CLEAR:ef_is_unicode,idetails[],xdetails,
* ref_table_des.
* " check the system is unicode or nonunicode
* CALL FUNCTION '/BDL/CHECK_UNICODE'
* IMPORTING
* ef_is_unicode = ef_is_unicode.
** get the structure of the table.
* ref_table_des ?=
* cl_abap_typedescr=>describe_by_name( get_table-tabname ).
* idetails[] = ref_table_des->components[].
*
* "先获取每个table字段 与查找的table是否相同
* READ TABLE idetails INTO wa WITH KEY name = p_field BINARY SEARCH.
* IF sy-subrc = .
"--->1.abap 字典类型为 p x i f 8 字段调用动态 sql会down
"--->2.为知 b s g y u v h V r l a e j k z 类型 调用动态 sql是否会down
CLEAR:l_value.
IF get_table-inttype EQ 'P' OR
get_table-inttype EQ 'X' OR
get_table-inttype EQ 'I' OR
get_table-inttype EQ 'F' OR
get_table-inttype EQ ''. * SELECT (p_field)
* FROM (get_table-tabname)
* INTO @l_value. ASSIGN COMPONENT 'TABLE_NAME' OF
STRUCTURE <dyn_wa> TO <dyn_field>. <dyn_field> = get_table-tabname. ASSIGN COMPONENT 'FIELD' OF
STRUCTURE <dyn_wa> TO <dyn_field>. <dyn_field> = get_table-fieldname. ASSIGN COMPONENT 'VALUE' OF
STRUCTURE <dyn_wa> TO <dyn_field>. <dyn_field> = l_value . ASSIGN COMPONENT 'ACCURACY' OF
STRUCTURE <dyn_wa> TO <dyn_field>.
IF l_value EQ s_trx.
<dyn_field> = .
ELSE.
<dyn_field> = .
ENDIF. APPEND <dyn_wa> TO <dyn_table>. CLEAR <dyn_wa>.
ELSE.
CLEAR:where_tab[].
CONCATENATE get_table-fieldname ' LIKE ''%' s_trx '%'''
INTO where_tab.
APPEND where_tab. SELECT SINGLE (get_table-fieldname)
FROM (get_table-tabname)
INTO @l_value
WHERE (where_tab).
IF sy-subrc = .
ASSIGN COMPONENT 'TABLE_NAME' OF
STRUCTURE <dyn_wa> TO <dyn_field>. <dyn_field> = get_table-tabname. ASSIGN COMPONENT 'FIELD' OF
STRUCTURE <dyn_wa> TO <dyn_field>. <dyn_field> = get_table-fieldname. ASSIGN COMPONENT 'VALUE' OF
STRUCTURE <dyn_wa> TO <dyn_field>. <dyn_field> = l_value . ASSIGN COMPONENT 'ACCURACY' OF
STRUCTURE <dyn_wa> TO <dyn_field>.
IF l_value EQ s_trx. <dyn_field>
= .
ELSE. <dyn_field>
= .
ENDIF. APPEND <dyn_wa> TO <dyn_table>. CLEAR <dyn_wa>.
ENDIF.
ENDIF. * ENDIF.
ENDLOOP.
ENDFORM. *&---------------------------------------------------------------------*
*& form create_dynamic_itab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form create_dynamic_itab.
* create dynamic internal table and assign to fs
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING i_length_in_byte
= 'x' it_fieldcatalog
= ifc
IMPORTING ep_table
= dy_table.
ASSIGN dy_table->* TO <dyn_table>.
* create dynamic work area and assign to fs
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. *&---------------------------------------------------------------------*
*& Form NEW_TEBLE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM NEW_TEBLE .
CLEAR xfc.
* xfc-tabname = 'TABLE_NAME'. xfc
-fieldname = 'TABLE_NAME' . xfc
-datatype = 'C'. xfc
-inttype = 'C'. xfc
-intlen = .
"小数点
* xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
CLEAR xfc.
* xfc-tabname = 'TABLE_FIELD'. xfc
-fieldname = 'FIELD'."p_field . xfc
-datatype = 'C'. xfc
-inttype = 'C'. xfc
-intlen = .
"小数点
* xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc. CLEAR xfc.
* xfc-tabname = 'TABLE_FIELD'. xfc
-fieldname = 'VALUE'. xfc
-datatype = 'C'. xfc
-inttype = 'C'. xfc
-intlen = .
"小数点
* xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc. CLEAR xfc.
* xfc-tabname = 'TABLE_FIELD'. xfc
-fieldname = 'ACCURACY'. xfc
-datatype = 'P'. xfc
-inttype = 'P'. xfc
-intlen = .
"小数点 xfc
-decimals = .
APPEND xfc TO ifc.
ENDFORM. FORM get_col.
DEFINE FILEDCAT. gt_fieldcat
-fieldname = &. "对应内表的字段名 gt_fieldcat
-seltext_l = &. "输出列文本 gt_fieldcat
-outputlen = &. "長度
APPEND gt_fieldcat.
END-OF-DEFINITION. FILEDCAT 'TABLE_NAME' '表格名称' . FILEDCAT
'FIELD' '表格字段' . FILEDCAT
'VALUE' '值' . FILEDCAT
'ACCURACY' '值的精确度' .
ENDFORM. *&---------------------------------------------------------------------*
*& Form ALV_SHOW
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM ALV_SHOW . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING I_CALLBACK_PROGRAM
= SY-REPID IS_LAYOUT
= GS_LAYOUT IT_FIELDCAT
= GT_FIELDCAT[] I_SAVE
= 'A'
TABLES T_OUTTAB
= <dyn_table>
EXCEPTIONS PROGRAM_ERROR
=
OTHERS = .
ENDFORM.

F1 相似查找字段存在的table的更多相关文章

  1. mysql通过字段注释查找字段名称

    原文:mysql通过字段注释查找字段名称 有时候表的字段太多,只是大致记得表的注释,想通过字段注释查找字段名称,可以用如下语句: SELECT COLUMN_NAME,column_comment F ...

  2. openEntityForm时候如何给关于(regardingobjectid)类型查找字段赋值?

    本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复264或者20170924可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...

  3. Dynamics 365中使用Web API将查找字段的值设置为空值的方法。

    摘要: 本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复270或者20180424可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyon ...

  4. Dynamics CRM2016 Web Api之查询查找字段的相关属性

    之前有篇博文介绍了如何获取查找字段的name值(跳转),本篇在此基础上再延伸下,实现的效果类似于EntityReference,可以取到查找字段的id,name,localname. 这里我以客户实体 ...

  5. Dynamics CRM2016 Web API之删除单个查找字段值

    之前的博文中有介绍过,Web Api中的一个删除单个属性的Api但没提供查找字段的删除方法,本篇补充上,这里给出的示例代码是C#的(主要看url的拼接),看下url中最后的/$ref,这个标示表明了当 ...

  6. openEntityForm如何给关于(regardingobjectid)类型查找字段赋值?

    本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复264或者20170924可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...

  7. Sed+Grep 快速替换查找字段(批量替换字符串)

    格式: sed -i "s/查找字段/替换字段/g" `grep 查找字段 -rl路径` 命令分解: grep 查找字段 -rl路径   列出”路径”中” 查找字段” 的所有文件 ...

  8. mysql通过字段凝视查找字段名称

    有时候表的字段太多.仅仅是大致记得表的凝视,想通过字段凝视查找字段名称,能够用例如以下语句: SELECT COLUMN_NAME,column_comment FROM INFORMATION_SC ...

  9. 查找字段的筛选-使用addCustomView

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复231或者20161031可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong. ...

随机推荐

  1. java 中类初始化,构造方法,静态成员变量,静态块的加载顺序

    1.编译和运行概念要搞清:编译即javac的过程,负责将.java文件compile成.class文件,主要是类型.格式检查与编译成字节码文件,而加载是指java *的过程,将.class文件加载到内 ...

  2. shell 判断大小

    test.sh #!/bin/bash read -p "" a read -p "" b if [ $a -eq $b ];then echo "= ...

  3. mysql(一)工作原理 & 数据库引擎

    参考文档 http://www.cnblogs.com/xiaotengyi/articles/3641983.html innodb:https://www.cnblogs.com/Aiapple/ ...

  4. poi导出word表格

    代码如下: package com.ksource.pwlp.util; import java.io.FileOutputStream; import java.math.BigInteger; i ...

  5. 为什么“四年一闰、百年不闰、四百年又闰”及 判断闰年的方法

    小学数学学习方法: 为什么"四年一闰.百年不闰.四百年又闰"及判断平年和闰年的妙法 三年级的小朋友们都知道:我们公历年份是4的倍数的那一年一般都是闰年,但公历年份是100的倍数时, ...

  6. SpringBoot项目中的全局异常处理器 Failed to invoke @ExceptionHandler method

    文件下载代码 @RequestMapping(value = { "/data/docking/picture/{id}/{empi}" }) public JsonApi pic ...

  7. some try on func swap about & and *

    import "fmt" func swap(x,y *int ) { //x ,y = y,x //fault /* t := *x *x = *y *y = t */ //tr ...

  8. MSSQL附加数据库时提示以下错误: 无法打开物理文件“***.mdf”。操作系统错误 5:“5(拒绝访问。)”。 (Microsoft SQL Server,错误: 5120)

    MSSQL附加数据库时提示以下错误: 无法打开物理文件“***.mdf”.操作系统错误 5:“5(拒绝访问.)”. (Microsoft SQL Server,错误: 5120) ***** 解决方法 ...

  9. Cassandra开发入门文档第一部分

    Cassandra的特点 横向可扩展性: Cassandra部署具有几乎无限的存储和处理数据的能力.当需要额外的容量时,可以简单地将更多的机器添加到集群中.当新机器加入集群时,Cassandra需要对 ...

  10. python初级(302) 6 对象(四)

    一.复习 1.什么是多态 2.复习上一节课内容 class Triangle: """ 三角形类 """ def __init__(self ...