• WDA 程序文本翻译OTR


    1.针对直接使用表字段,数据元素的情况:

       1.1修改数据元素对应的语言值:DD04T。

       1.2模拟SE63插入翻译条目:LXE_LOG

       1.3运行时文件翻译条目:DDFTX

    *&---------------------------------------------------------------------*
    *& Report  ZHSICRM_TEXTMD
    *&
    *&---------------------------------------------------------------------*
    *&
    *&批量维护数据元素文本,保证使用数据元素文本的屏幕位置能正常显示多语言
    *&李渊 20170113  创建
    *&上传文件以表DD04T为结构字段
    *&---------------------------------------------------------------------*
    REPORT ZHSICRM_TEXTMD.
    
    TABLES:DD04T,LXE_LOG,DDFTX.
    
    DATA:GT_DD04T TYPE TABLE OF DD04T,
         GW_DD04T LIKE LINE OF GT_DD04T,
         GS_DD04T LIKE LINE OF GT_DD04T,"数据元素多语言描述
         GT_LXE_LOG TYPE TABLE OF LXE_LOG,
         GW_LXE_LOG LIKE LINE OF GT_LXE_LOG,
         GS_LXE_LOG LIKE LINE OF GT_LXE_LOG,
         GT_DDFTX TYPE TABLE OF DDFTX,
         GW_DDFTX LIKE LINE OF GT_DDFTX,
         GS_DDFTX LIKE LINE OF GT_DDFTX.
    
    
    
    SELECTION-SCREEN:BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-001.
    PARAMETERS:P_TBMA TYPE CRMTABLES-TABNAME NO-DISPLAY, "RSRD1-TBMA_VAL,
               P_FILE LIKE RLGRAP-FILENAME.
    SELECTION-SCREEN END OF BLOCK BLK01.
    
    *SELECTION-SCREEN FUNCTION KEY 1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      PERFORM FRM_GET_FILEPATH.
    
    
    START-OF-SELECTION.
    CHECK P_FILE IS NOT INITIAL.
    PERFORM PRM_UPLOAD_EXCEL.
    PERFORM PRM_UPDATE_TABLE.
    
    
    
    
    
    
    
    
    
    *&---------------------------------------------------------------------*
    *&      Form  FRM_GET_FILEPATH
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM FRM_GET_FILEPATH .
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          MASK             = ',Excel(*.xls),*.XLS,*.XLSX,'
          TITLE            = '选择文件'(100)
        IMPORTING
          FILENAME         = P_FILE
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      IF SY-SUBRC <> 0.
        "      MESSAGE e100(zdev) WITH '选择文件出错!'(007).
      ENDIF.
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  PRM_UPLOAD_EXCEL
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM PRM_UPLOAD_EXCEL .
    IF P_FILE IS NOT INITIAL.
    *将excel数据传入内表
        CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'
          EXPORTING
            FILENAME    = P_FILE
            I_BEGIN_COL = '1'
            I_BEGIN_ROW = '2'
            I_END_COL   = '300'
            I_END_ROW   = '50000'
          TABLES
            INTERN      = GT_DD04T.
      ENDIF.
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  PRM_UPDATE_TABLE
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM PRM_UPDATE_TABLE .
      CHECK GT_DD04T[] IS NOT INITIAL.
    
      LOOP AT GT_DD04T INTO GW_DD04T.
        GS_LXE_LOG-CUSTMNR = '999999'.
        CASE GW_DD04T-DDLANGUAGE.
          WHEN 'E'.
            GS_LXE_LOG-TARGLNG = 'enUS'.
    *      WHEN '1'.
    *        GS_LXE_LOG-TARGLNG = 'enUS'.
          WHEN 'I'.
            GS_LXE_LOG-TARGLNG = 'itIT'.
          WHEN 'D'.
            GS_LXE_LOG-TARGLNG = 'deDE'.
          WHEN 'S'.
            GS_LXE_LOG-TARGLNG = 'esES'.
          WHEN 'J'.
            GS_LXE_LOG-TARGLNG = 'jaJP'.
          WHEN OTHERS.
            CONTINUE.
        ENDCASE.
    
        GS_LXE_LOG-OBJTYPE = 'DTEL'.
        GS_LXE_LOG-OBJNAME = GW_DD04T-ROLLNAME.
        GS_LXE_LOG-UNAME = SY-UNAME.
        GS_LXE_LOG-UDATE = SY-DATUM.
        GS_LXE_LOG-UTIME = SY-UZEIT.
        APPEND GS_LXE_LOG TO GT_LXE_LOG.
    
        SELECT SINGLE * INTO GS_DDFTX FROM DDFTX
          WHERE TABNAME = GW_DD04T-ROLLNAME
          AND   DDLANGUAGE = 'E'
          AND   ROLLNAME = GW_DD04T-ROLLNAME.
          IF SY-SUBRC = 0.
            GS_DDFTX-DDLANGUAGE = GW_DD04T-DDLANGUAGE.
            GS_DDFTX-SCRTEXT_S = GW_DD04T-SCRTEXT_S.
            GS_DDFTX-SCRTEXT_M = GW_DD04T-SCRTEXT_S.
            GS_DDFTX-SCRTEXT_L = GW_DD04T-SCRTEXT_S.
            GS_DDFTX-REPTEXT   = GW_DD04T-REPTEXT.
            GS_DDFTX-FIELDTEXT   = GW_DD04T-DDTEXT.
            APPEND GS_DDFTX TO GT_DDFTX.
          ENDIF.
    
      ENDLOOP.
    
      MODIFY DD04T FROM TABLE GT_DD04T.
      MODIFY LXE_LOG FROM TABLE GT_LXE_LOG.
      IF GT_DDFTX[] IS NOT INITIAL.
        MODIFY DDFTX FROM TABLE GT_DDFTX.
      ENDIF.
      IF SY-SUBRC = 0.
        MESSAGE '导入成功' TYPE 'S'.
      ELSE.
        MESSAGE '导入失败' TYPE 'S' DISPLAY LIKE 'E'.
        EXIT.
      ENDIF.
    ENDFORM.

    2.WDA程序中用TEXT写死的值

       2.1SOTR_EDIT 

    可获取单个的文本和KEY值。

      2.2重新进入维护修改值。

      可参考修改SOTR_TEXT

    3.定义全局的文本,并翻译

    使用SOTR_EDIT ,创建文本对象,记录别名,维护对应语言的文本

    在使用的地方,直接调用

    lv_title cl_wd_utilities=>get_otr_text_by_alias'ZWDA/LABEL_TEST' ).

      

  • 相关阅读:
    Frame内容页向Frame页传值的问题。
    Silverlight 要求使用更新版本
    Siverlight 中RichTextBox 中注入控件无法使用的问题
    PHP_判断是否为数字
    CentOS中vsftp安装与配置
    全面认识F5负载均衡
    如何让php自动进行二级域名泛解析
    【Thinkphp教程】 如何实现URL伪静态
    LVS+heartbeat+ldirectord高可用负载均衡集群解决方案
    ThinkPHP小结
  • 原文地址:https://www.cnblogs.com/sapSB/p/6289144.html
Copyright © 2020-2023  润新知