文章目录
- 代码
- 有原始数据内表作为主表连接STXL的示例
- 获取物料分类
- 获取物料分类的文本的宏
- 读取分类
https://blog.csdn.net/DeveloperMrMeng/article/details/118354649
代码
"第三种:读取底表获取文本
DATA: LT_TLINE TYPE STANDARD TABLE OF TLINE.
DATA: LS_TLINE TYPE TLINE.
"定义只有两列的结构和内表
TYPES: BEGIN OF TY_STXL_RAW,CLUSTR TYPE STXL-CLUSTR,CLUSTD TYPE STXL-CLUSTD,END OF TY_STXL_RAW.DATA: LT_STXL_RAW TYPE STANDARD TABLE OF TY_STXL_RAW,LS_STXL_RAW TYPE TY_STXL_RAW.DATA: LV_STR TYPE STRING.SELECTTDOBJECT,TDNAME,TDID,CLUSTR,CLUSTDFROM STXL AS AWHERE TDID = '0004' "文本标识AND TDNAME = '1000100000100744000000300000003701' "名称AND TDOBJECT = 'KNMT' "文本对象AND TDSPRAS = '1' "语言INTO TABLE @DATA(LT_STXL).LOOP AT LT_STXL INTO DATA(LS_STXL).LS_STXL_RAW-CLUSTR = LS_STXL-CLUSTR.LS_STXL_RAW-CLUSTD = LS_STXL-CLUSTD.APPEND LS_STXL_RAW TO LT_STXL_RAW.CLEAR LT_TLINE[].IMPORT TLINE = LT_TLINE FROM INTERNAL TABLE LT_STXL_RAW."IMPORT ITAB = LT_TLINE FROM INTERNAL TABLE LT_STXL_RAW.
ENDLOOP.IF NOT LT_TLINE IS INITIAL.CLEAR LS_TLINE.LS_TLINE-TDFORMAT = ''.MODIFY LT_TLINE FROM LS_TLINE TRANSPORTING TDFORMAT WHERE TDFORMAT NE ''."把内表转成字符串CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'EXPORTINGFLAG_NO_LINE_BREAKS = 'X'
* LINE_LENGTH =LANGU = SY-LANGUIMPORTINGTEXT = LV_STRTABLESTEXT_TAB = LT_TLINE.
ENDIF.WRITE:'读取底表获取文本:',LV_STR.
有原始数据内表作为主表连接STXL的示例
获取物料分类
*┏--------Begin-------- Add By Liuhongyu 2024.11.06 -------------
* -------- ★ --------〔业务顾问:ldm 请求号:S4DK907145〕"--> 获取物料分类DATA: LT_TEXT_ZWLFL TYPE STANDARD TABLE OF ZSDSTEXT,LS_TEXT_ZWLFL TYPE ZSDSTEXT.DATA: LT_TLINE TYPE STANDARD TABLE OF TLINE.DATA: LS_TLINE TYPE TLINE."定义只有两列的结构和内表TYPES: BEGIN OF TY_STXL_RAW,CLUSTR TYPE STXL-CLUSTR,CLUSTD TYPE STXL-CLUSTD,END OF TY_STXL_RAW.DATA: LT_STXL_RAW TYPE STANDARD TABLE OF TY_STXL_RAW,LS_STXL_RAW TYPE TY_STXL_RAW.DATA: LV_STR TYPE STRING."拼接TDNAMESELECTVKORG, "销售组织VTWEG, "分销渠道KUNNR, "客户编码MATNR, "物料CONCAT( VKORG, CONCAT( VTWEG, CONCAT( KUNNR,MATNR ) ) ) AS TDNAME "文本名称FROM @LT_DATA AS AINTO TABLE @DATA(LT_TDNAME)."获取文本的内容SELECTB~TDOBJECT, "对象A~TDNAME, "名称B~TDID, "IDB~CLUSTR, "B~CLUSTD "FROM @LT_TDNAME AS ALEFT JOIN STXL AS B ON A~TDNAME = B~TDNAMEINTO TABLE @DATA(LT_ZWLFL_STXL).LOOP AT LT_ZWLFL_STXL INTO DATA(LS_ZWLFL_STXL).MOVE-CORRESPONDING LS_ZWLFL_STXL TO LS_STXL_RAW.APPEND LS_STXL_RAW TO LT_STXL_RAW.CLEAR LT_TLINE[].IMPORT TLINE = LT_TLINE FROM INTERNAL TABLE LT_STXL_RAW.IF NOT LT_TLINE IS INITIAL.CLEAR LS_TLINE.LS_TLINE-TDFORMAT = ''.MODIFY LT_TLINE FROM LS_TLINE TRANSPORTING TDFORMAT WHERE TDFORMAT NE ''."把内表转成字符串CALL FUNCTION 'SOTR_SERV_TABLE_TO_STRING'EXPORTINGFLAG_NO_LINE_BREAKS = 'X'
* LINE_LENGTH =LANGU = SY-LANGUIMPORTINGTEXT = LV_STRTABLESTEXT_TAB = LT_TLINE."去除前置空格(左侧的)SHIFT LV_STR LEFT DELETING LEADING SPACE.MOVE-CORRESPONDING LS_ZWLFL_STXL TO LS_TEXT_ZWLFL.LS_TEXT_ZWLFL-LTEXT = LV_STR.APPEND LS_TEXT_ZWLFL TO LT_TEXT_ZWLFL.ENDIF.ENDLOOP.SORT LT_TEXT_ZWLFL BY TDNAME TDID.
* -------- End -------------------------------------------------------┛
获取物料分类的文本的宏
* --获取物料分类的文本的宏DEFINE READ_TEXT_ZWLFL."获取长文本READ TABLE LT_TEXT_ZWLFL INTO LS_TEXT WITH KEY TDNAME = &1 TDID = &2 BINARY SEARCH.IF SY-SUBRC EQ 0.&3 = LS_TEXT-LTEXT.ENDIF.END-OF-DEFINITION.
读取分类
"--> 读取物料分类 ADD BY LHY 20241106READ_TEXT_ZWLFL: IV_NAME '0004'<FS_OUT>-ZWLFL. "ADD BY LHY 20241106