在内部表 ABAP 中查找不可打印字符 [英] Looking for Non-Printable characters inside internal table ABAP

查看:27
本文介绍了在内部表 ABAP 中查找不可打印字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内部表,它被写入文件,然后作为数据源拉入 BW.有时,不可打印的字符会使其进入文件输出并将导入过程中断到 BW.下面是我的代码示例.由于 itab 不是类型 c 或字符串,我无法在其上使用查找/替换正则表达式.以前有没有其他人解决过此类问题?

I have an internal table this is written to file and then pulled into the BW as a datasource. Occasionally a non printable character makes it into the file output and breaks the import process into the BW. Below is a sample of my code. Since the itab is not type c or string I am unable to use the find/replace regex on it. Has anyone else had to solve this type of problem before?

    FORM eliminate_non_print_char TABLES p_shiptab STRUCTURE shiptab.     

  LOOP AT p_shiptab INTO wa_shiptab.

    FIND REGEX '[^[:print:]]+(?!$)'
      IN wa_shiptab
    IGNORING CASE.
    "RESULTS result.
    IF  sy-subrc = 0.

     REPLACE REGEX '[^[:print:]]+(?!$)'
        IN wa_shiptab WITH ''
     IGNORING CASE.

    ENDIF.
  ENDLOOP.

DATA: BEGIN OF shiptab OCCURS 2000.
        INCLUDE STRUCTURE ship1.
        INCLUDE STRUCTURE ship2.
DATA: landtx            LIKE vbrk-landtx,
      bl_konwa          LIKE vbak-waerk.                    
        INCLUDE STRUCTURE ship3.
        INCLUDE STRUCTURE ship4.
DATA: frght_amnt_usd    LIKE konv-kwert,                    
      revenue_amnt_usd  LIKE vbap-netwr,                    
      unit_price_usd    LIKE vbap-netpr,                    
      pgi_posting_date  LIKE mkpf-budat,                    
      ord_line_item_qty LIKE lips-lfimg,                    
      asm_no            LIKE kna1-kunnr,
      asm_username      LIKE adrc-sort1,
      va_augru_t        LIKE tvaut-bezei,         
      ship_to_name      LIKE adrc-name1,
      bill_to_name      LIKE adrc-name1,
      forward_to_name   LIKE adrc-name1,
      fmv_amnt           LIKE konv-kbetr,    
      va_butxt           LIKE t001-butxt,    
      sold_to_search_term LIKE adrc-sort1,   
      bill_to_search_term LIKE adrc-sort1,  
      va_prctr           LIKE vbap-prctr,    
      va_bezei           LIKE tvrot-bezei.   
        INCLUDE STRUCTURE zorder_attr.         
DATA: extended_bits_count(20),              
      va_bstkd_hdr LIKE char32.            
DATA: gsm_bp_katr6      LIKE kna1-katr6,    
      gsm_bp_vtext6     LIKE tvk6t-vtext,   
      asm_ze_katr7      LIKE kna1-katr7,    
      asm_ze_vtext7     LIKE tvk7t-vtext,   
      gsm_ze_katr6      LIKE kna1-katr6,    
      gsm_ze_vtext6     LIKE tvk7t-vtext.
DATA:  END OF shiptab

.

我得到的错误是:WA_SHIPTAB"必须是字符类型的数据对象(数据类型 C、N、D、T 或 STRING).我在 itab shiptab 中有非字符类型.我知道我可以单独对每个字段进行此查找,但是 itab 有 235 个字段,这似乎效率不高.

The error I get is: "WA_SHIPTAB" must be a character-type data object (data type C, N, D,T, or STRING). I have non character types in the itab shiptab. I know I can do this lookup on each field individually, but the itab has 235 fields and that does not seem efficient.

推荐答案

该程序有另一个主要 itab 的副本,它是基于字符的字段,我循环了这个并放置了以下代码:

The program has another copy of the main itab that is char based fields, I looped through this and placed the following code:

REPLACE ALL OCCURRENCES OF REGEX '[^[:print:]]+$'
  IN transtab WITH ''
  IGNORING CASE.

答案链接:

SCN 链接

Help.SAP 链接

这篇关于在内部表 ABAP 中查找不可打印字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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