[Legacy System Migration Workbench] LSMW Version Number : 4.0.0 LSMW Version Date : 08/31/2004 R/3 Installation Number : 0020821257 R/3 System Id : JIM R/3 Release : 702 R/3 Client : 300 R/3 Operating System : Linux R/3 Database System : DB6 R/3 Hostname : jim-dv-sapjim User Id : JIKAUFFMAN Date : 02/04/2019 Time : 14:48:40 Local Date : 02/04/2019 Local Time : 14:48:40 Local Timezone : EST [Project Information] [Project Name ] : SAPLSMW [Project Text ] : Repository for SAPLSMW.com /SAPDMC/LSGPRO SAPLSMW JKAUFFMAN 20160916 /SAPDMC/LSGPROT ESAPLSMW Repository for SAPLSMW.com [Central Rules] [User-Routines] [User Routine ] : DC_TOOLS [User Routine Text] : Data conversion tools /SAPDMC/LSRATT SAPLSMW URDC_TOOLS 000 000 0000JIKAUFFMAN 20190204 /SAPDMC/LSRTXT ESAPLSMW URDC_TOOLS Data conversion tools /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0001* * * * * * * * * * * * * * * * * * * * * * * * * * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0002* * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0003* These functions were written by Jim Kauffman * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0004* and are free to use. More documentation is * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0005* available at http://www.saplsmw.com * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0006* * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0007* * * * * * * * * * * * * * * * * * * * * * * * * * /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0008 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0009 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0010* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0011* This function finds the number of a view for a material based /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0012* on the material number and the description of the view on the /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0013* "Select Views" screen. If the view doesn't exist for the material /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0014* then the function returns a zero value. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0015* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0016form FindKZSEL /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0017 using cMATNR like MARA-MATNR /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0018 cViewDesc like T133B-DYTXT /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0019 cTCODE like T130M-TCODE /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0020 changing nViewKZSEL. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0021* tables: MARA, T130M. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0022 data: lvMARA like MARA, lvT130M like T130M. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0023 data: cFound(1) type c, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0024 lBILDTAB like MBILDTAB, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0025 KZ_BILDS_CHANGED, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0026 BILDSEQUENZ like T133K-BILDS, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0027 lvMATNR(18) type c, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0028 TKSTATUS like T130M-PSTAT. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0029 DATA: BEGIN OF BILDTAB OCCURS 30. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0030 INCLUDE STRUCTURE MBILDTAB. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0031 DATA: END OF BILDTAB. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0032* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0033* Find the specific material in the MARA table. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0034* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0035 move cMATNR to lvMATNR. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0036 if lvMATNR co ' 1234567890'. "Numeric material needs leading zeros. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0037 shift lvMATNR right deleting trailing space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0038 overlay lvMATNR with '000000000000000000'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0039 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0040 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0041 select * from MARA into lvMARA where MATNR eq lvMATNR. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0042* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0043* We default to the screen reference (TRREF) '01' as that's the /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0044* reference for MM02 and most other transactions. This is easier than /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0045* pulling the value from the T130M table for each transaction code. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0046* Using the industry and material type from the material we get the /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0047* "Screen Sequence Number". /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0048* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0049 CALL FUNCTION 'BILDSEQUENZ_IDENTIFY' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0050 EXPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0051 KZRFB = ' ' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0052 BRANCHE = lvMARA-MBRSH /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0053 MATERIALART = lvMARA-MTART /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0054 TCODE_REF = '01' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0055 IMPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0056 BILDSEQUENZ = BILDSEQUENZ /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0057 KZ_BILDS_CHANGED = KZ_BILDS_CHANGED. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0058 if cTCODE eq 'MM01'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0059 CALL FUNCTION 'MATERIAL_INIT' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0060 EXPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0061 TCODE = 'MM01' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0062 KZ_BERPRF = 'X' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0063 IMPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0064 IT130M = lvT130M /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0065 TKSTATUS = TKSTATUS. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0066 else. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0067 TKSTATUS = lvMARA-PSTAT. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0068 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0069* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0070* Now we use the "Screen Sequence Number" and the Pflegestatus /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0071* (Maintenance Status) from the material to build an internal table /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0072* with the views ordered just like on MM02 "Select Views" screen. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0073* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0074 CALL FUNCTION 'SELECTION_VIEWS_FIND' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0075 EXPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0076 BILDSEQUENZ = BILDSEQUENZ /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0077 PFLEGESTATUS = TKSTATUS /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0078 TABLES /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0079 BILDTAB = BILDTAB. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0080 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0081 nViewKZSEL = 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0082* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0083* Now, loop through the internal table to find the desired view. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0084* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0085 loop at BILDTAB into lBILDTAB. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0086 if cFound ne 'X'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0087 add 1 to nViewKZSEL. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0088 if lBILDTAB-DYTXT eq cViewDesc. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0089 cFound = 'X'. "Stop counting, we have the KZSEL. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0090 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0091 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0092 endloop. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0093 endselect. "MARA /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0094 if cFound ne 'X'. "View not found! /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0095 nViewKZSEL = 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0096 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0097endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0098 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0099form CleanseText using inValue changing outValue. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0100 data: nLength type i, cTemp(100) type c. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0101 translate inValue to UPPER CASE. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0102 nLength = strlen( inValue ). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0103 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0104 do nLength times. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0105 subtract 1 from nLength. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0106 if '''ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-&`´ÑØÃßßÄäÖöÜüÅÉé' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0107 cs inValue+nLength(1). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0108 concatenate inValue+nLength(1) cTemp into cTemp. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0109 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0110 enddo. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0111 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0112 outValue = cTemp. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0113endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0114 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0115form CountDecimalPlaces using cValue changing lvDecimals. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0116 data: lvLength type i. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0117 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0118 condense cValue. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0119 if cValue cs '.'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0120 shift cValue right deleting trailing space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0121 shift cValue right deleting trailing '0'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0122 shift cValue right deleting trailing '.'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0123 shift cValue left deleting leading space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0124 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0125 if cValue cs '.'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0126 lvLength = strlen( cValue ). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0127 find '.' in cValue. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0128 lvDecimals = ( lvLength - sy-fdpos ) - 1. "Decimal places /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0129 else. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0130 lvDecimals = 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0131 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0132endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0133 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0134 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0135form KillQuotes changing inValue. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0136 condense inValue. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0137 if inValue+0(1) eq '"'. "Quotes. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0138 shift inValue left deleting leading '"'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0139 shift inValue right deleting trailing space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0140 shift inValue right deleting trailing '"'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0141 shift inValue left deleting leading space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0142 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0143endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0144 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0145form ZPROGRESSTIME using lvCurrent lvCount. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0146 statics: lvtimlo like sy-timlo, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0147 lvstarted like sy-timlo, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0148 cRemaining(70) type c, cPercentage(40) type c. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0149 data: lvPercentage type f, lvPercent type i, lvcTotal(8) type c. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0150 if cRemaining eq ''. cRemaining = 'X'. lvStarted = sy-timlo. endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0151 get time. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0152 if sy-timlo ne lvtimlo and lvCurrent gt 1 and lvCount gt 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0153 cRemaining = /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0154 ( ( sy-timlo - lvstarted ) / lvcurrent ) * ( lvcount - lvcurrent ). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0155 cRemaining = cRemaining div 1. condense cremaining no-gaps. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0156 lvPercentage = 100 * lvCurrent / lvCount. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0157 lvPercent = lvPercentage. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0158 lvcTotal = g_cnt_transactions_transferred. condense lvcTotal. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0159 cPercentage = 100 * ( lvCurrent / lvCount ). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0160 cPercentage = cPercentage div 1. condense cPercentage no-gaps. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0161 concatenate '[ Percent complete:' cPercentage /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0162 '][ Seconds remaining:' cRemaining /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0163 '][ Transferred:' lvcTotal ']' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0164 into cRemaining separated by space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0165 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0166 call function 'SAPGUI_PROGRESS_INDICATOR' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0167 exporting /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0168 PERCENTAGE = lvPercentage /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0169 TEXT = cRemaining /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0170 exceptions /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0171 others = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0172 lvtimlo = sy-timlo. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0173 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0174 " The following line prevents LSMW from calling the /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0175 " SAPGUI_PROGRESS_INDICATOR function by setting the /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0176 " counter to 0; it calls at 500 and sets to 0 again. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0177 g_cnt_records_read_progress = 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0178endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0179form GetTotalRecords changing lvTotalRecords. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0180 CALL FUNCTION '/SAPDMC/LSM_FILE_INFO_GET' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0181 EXPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0182 project = g_project /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0183 subproj = g_subproj /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0184 object = g_object /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0185 IMPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0186 file_read = g_dsn_in /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0187 file_conv = g_dsn_out /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0188 EXCEPTIONS /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0189 no_such_object = 1 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0190 OTHERS = 2. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0191 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0192 open dataset g_dsn_in for input in binary mode. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0193 while sy-subrc eq 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0194 READ DATASET g_dsn_in INTO g_hex_record_length. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0195 IF sy-subrc eq 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0196 g_record_length = g_hex_record_length. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0197 ASSIGN g_max_buffer(g_record_length) TO . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0198 READ DATASET g_dsn_in INTO . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0199 IF sy-subrc eq 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0200 gs_buffer = . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0201 g_record = gs_buffer-record. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0202 ADD 1 TO lvTotalRecords. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0203 ENDIF. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0204 ENDIF. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0205 endwhile. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0206 close dataset g_dsn_in. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0207endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0208 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0209Form CheckSettings. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0210 data: lvUSR01 like USR01. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0211 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0212 select * from USR01 into lvUSR01 where BNAME eq sy-uname. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0213 if lvUSR01-DATFM ne '1'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0214 write: / 'The date format for this user is not set correctly.' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0215 color col_negative. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0216 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0217 if lvUSR01-DCPFM ne 'X'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0218 write: / 'The date format for this user is not set correctly.' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0219 color col_negative. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0220 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0221 endselect. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0222endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0223 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0224form InternalTableToExcel /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0225 using it_Table type standard table /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0226 nvkeys type i /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0227 lvSPRAS like DD04T-DDLANGUAGE. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0228 "*** Data for Excel Spreadsheet function /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0229 data: data_starting_at type i, " erste Zeile der Datentabelle /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0230 data_ending_at type i, " letzte Zeile der Datentabelle /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0231 filename like gxxlt_f-file, " Dateiname für Listobjekt /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0232 header_1 like gxxlt_p-text, " Titelzeile /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0233 header_2 like gxxlt_p-text, " Untertitel /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0234 n_vrt_keys type i, " Anzahl vertikale Merkmale /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0235 " (= Anzahl Merkmalsspalten) /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0236 n_hrz_keys type i, " Anzahl horizontale Merkmale /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0237 " (= Anzahl der Spaltenmerkmale /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0238 " für Kennzahlspalten) /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0239 n_att_cols type i, " Anzahl der Kennzahlspalten /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0240 rcode type i, " Return-Code für XXL /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0241 sotitle like gxxlt_f-so_title," Titel für SAPoffice-Dokument /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0242 nostart(1), " X = EXCEL nicht starten /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0243 nodialog(1), " X = kein XXL-Dialog /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0244 nSEMA type i. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0245 data: begin of vkey occurs 10. " Ausprägung vertikale Merkm. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0246 include structure gxxlt_v. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0247 data: end of vkey. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0248 data: begin of hkey occurs 10. " Ausprägung horizontale Merkm. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0249 include structure gxxlt_h. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0250 data: end of hkey. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0251 data: begin of sema occurs 10. " Spaltenbeschreibung /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0252 include structure gxxlt_s. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0253 data: end of sema. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0254 data: begin of print_text occurs 10. " Drucktexte /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0255 include structure gxxlt_p. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0256 data: end of print_text. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0257 data: begin of online_text occurs 10. " online-Texte /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0258 include structure gxxlt_o. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0259 data: end of online_text. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0260 DATA: t_descr TYPE REF TO CL_ABAP_TABLEDESCR, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0261 wa_keys type ABAP_KEYDESCR. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0262 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0263 t_descr ?= CL_ABAP_TABLEDESCR=>describe_by_data( it_Table ). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0264 n_vrt_keys = 0. n_att_cols = 0. n_hrz_keys = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0265 loop at t_descr->key into wa_keys. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0266 if n_vrt_keys lt nvkeys. "Populate these first. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0267 add 1 to n_vrt_keys. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0268 vkey-COL_NO = n_vrt_keys. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0269 vkey-COL_NAME = wa_keys-NAME. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0270 select DDTEXT from DD04T into vkey-COL_NAME /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0271 where ROLLNAME eq wa_keys-NAME and DDLANGUAGE eq lvSPRAS. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0272 endselect. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0273 append vkey. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0274 else. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0275 add 1 to n_att_cols. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0276 hkey-COL_NO = n_att_cols. hkey-ROW_NO = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0277 hkey-COL_NAME = wa_keys-NAME. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0278 select DDTEXT from DD04T into hkey-COL_NAME /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0279 where ROLLNAME eq wa_keys-NAME and DDLANGUAGE eq lvSPRAS. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0280 endselect. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0281 append hkey. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0282 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0283 endloop. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0284 nSEMA = N_VRT_KEYS + N_ATT_COLS. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0285 do nSEMA times. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0286 sema-COL_NO = sy-index. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0287 sema-COL_TYP = 'STR'. "Just make them all text. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0288 sema-COL_OPS = 'DFT'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0289 append sema. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0290 enddo. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0291 data_starting_at = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0292 describe table it_Table lines data_ending_at. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0293 filename = 'Output'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0294 header_1 = 'Output'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0295 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0296 nodialog = space. " mit Dialog /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0297 call function 'XXL_CHECK_API' " Test, ob XXL gestartet werden /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0298 exporting question = 'STARTABLE' " kann /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0299 importing return_code = rcode. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0300 if rcode = 0. " XXL kann gestartet werden /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0301 nostart = space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0302 sotitle = space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0303 else. " XXL kann nicht gestartet werden /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0304 nostart = 'X'. " nur Ablage als SAPoffice- /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0305 sotitle = 'Output'. " Dokument sinnvoll /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0306 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0307 if data_ending_at ne 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0308 call function 'XXL_FULL_API' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0309 exporting /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0310 n_hrz_keys = n_hrz_keys /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0311 n_vrt_keys = n_vrt_keys /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0312 n_att_cols = n_att_cols /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0313 data_starting_at = data_starting_at /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0314 data_ending_at = data_ending_at /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0315 filename = filename /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0316 header_1 = header_1 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0317 header_2 = header_2 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0318 no_dialog = nodialog /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0319 so_title = sotitle /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0320 no_start = nostart /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0321 tables /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0322 vkey = vkey /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0323 hkey = hkey /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0324 data = it_Table /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0325 sema = sema /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0326 online_text = online_text /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0327 print_text = print_text /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0328 exceptions /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0329 cancelled_by_user = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0330 else. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0331 write: / 'No records to output.'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0332 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0333endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0334 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0335form CheckRuntime. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0336 statics: /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0337 lxstarted like SY-UZEIT , /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0338 cRemaining(1) type c. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0339 data: lvSeconds type i, lv_popup_ans type string, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0340 lvNow like SY-UZEIT. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0341 if cRemaining eq ''. cRemaining = 'X'. lxStarted = SY-UZEIT. endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0342 get time field lvNow. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0343 lvSeconds = lvNow - lxStarted. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0344 if lvSeconds gt 900. " 15 minutes... /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0345 call function 'POPUP_TO_CONFIRM' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0346 exporting /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0347 titlebar = 'Time expired.' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0348 text_question = 'Keep going?' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0349 text_button_1 = 'OK'(011) /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0350 default_button = '1' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0351 display_cancel_button = 'X' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0352 popup_type = 'ICON_MESSAGE_CRITICAL' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0353 importing /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0354 answer = lv_popup_ans. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0355* lxStarted = SY-UZEIT. "Restart timer. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0356 get time field lxStarted. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0357 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0358endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0359 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0360form SendEmail tables LT_MAILTXT using lvRecipient lvSubject. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0361 DATA: /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0362 LT_MAILSUBJECT TYPE SODOCCHGI1, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0363 LT_MAILRECIPIENTS TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER LINE. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0364 "Recipients /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0365 LT_MAILRECIPIENTS-REC_TYPE = 'U'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0366 LT_MAILRECIPIENTS-RECEIVER = lvRecipient. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0367 APPEND LT_MAILRECIPIENTS . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0368 CLEAR LT_MAILRECIPIENTS . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0369 "Subject. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0370 LT_MAILSUBJECT-OBJ_NAME = 'TEST'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0371 LT_MAILSUBJECT-OBJ_LANGU = SY-LANGU. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0372 LT_MAILSUBJECT-OBJ_DESCR = lvSubject. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0373 "Send Mail /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0374 CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0375 EXPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0376 DOCUMENT_DATA = LT_MAILSUBJECT /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0377 DOCUMENT_TYPE = 'RAW' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0378 PUT_IN_OUTBOX = ' ' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0379 COMMIT_WORK = 'X' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0380 TABLES /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0381 OBJECT_CONTENT = LT_MAILTXT /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0382 RECEIVERS = LT_MAILRECIPIENTS /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0383 EXCEPTIONS /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0384 others = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0385 IF SY-SUBRC EQ 0. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0386 COMMIT WORK. " Push mail out from SAP outbox /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0387 SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0388 ENDIF. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0389endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0390 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0391form ExportTable using lvTable lvFilename. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0392* Note: This code performs no error checking. It is assumed that /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0393* the table name and the file name are both valid. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0394 data: lvDD03L like DD03L, lvMessage type string, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0395 tab type c value cl_abap_char_utilities=>horizontal_tab. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0396 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0397* Let the user know what is happening to reduce boredom. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0398 concatenate 'Exporting' lvTable '. . .' into lvMessage /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0399 separated by space. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0400 call function 'SAPGUI_PROGRESS_INDICATOR' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0401 exporting /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0402 TEXT = lvMessage /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0403 exceptions /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0404 others = 1. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0405 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0406* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0407* First we make the header for the text file. It's simply /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0408* concatenating fieldnames from the DD03L table. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0409* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0410 types: begin of t_Header, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0411 header(3000) type c, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0412 end of t_Header. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0413 data: it_Header type standard table of t_Header initial size 0, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0414 wa_Header type t_Header. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0415 select * from DD03L into lvDD03L /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0416 where TABNAME eq lvTable and ROLLNAME ne '' order by POSITION. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0417 if wa_Header-header eq ''. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0418 wa_Header-header = lvDD03L-FIELDNAME. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0419 else. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0420 concatenate wa_Header-header lvDD03L-FIELDNAME /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0421 into wa_Header-header separated by tab. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0422 endif. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0423 endselect. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0424 append wa_Header to it_Header. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0425* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0426* Now we have an internal table with one record holding a /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0427* tab-delimited string with all the field names. We write /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0428* this as the beginning of the file. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0429* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0430 perform ExportTableWrite using it_Header lvFilename ''. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0431 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0432* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0433* Now we create a flexible internal table with the contents of the /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0434* table to be exported. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0435* /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0436 data: w_tabname type w_tabname, /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0437 w_dref type ref to data. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0438 FIELD-SYMBOLS: TYPE standard TABLE, . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0439 w_tabname = lvTable. translate w_tabname to UPPER CASE. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0440 CREATE DATA w_dref TYPE standard TABLE OF (w_tabname). /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0441 ASSIGN w_dref->* TO . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0442 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0443* Load the contents of the table to be exported into an internal table. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0444 select * from (w_tabname) into table . /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0445 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0446* Now we append the contents of the internal table to the text /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0447* file that already has the header row. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0448 perform ExportTableWrite using lvFilename 'X'. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0449endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0450 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0451Form ExportTableWrite using lvInternalTable type standard table /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0452 lv_Filename lv_Append. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0453 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0454 CALL FUNCTION 'GUI_DOWNLOAD' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0455 EXPORTING /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0456 FILENAME = lv_Filename /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0457 FILETYPE = 'ASC' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0458 APPEND = lv_Append /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0459 CODEPAGE = '4310' "UTF-8 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0460 WRITE_FIELD_SEPARATOR = 'X' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0461 HEADER = '00' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0462 TRUNC_TRAILING_BLANKS = 'X' /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0463 TABLES /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0464 DATA_TAB = lvInternalTable /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0465 EXCEPTIONS /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0466 FILE_WRITE_ERROR = 1 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0467 OTHERS = 2. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0468endform. /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0469 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0470 /SAPDMC/LSRCOD SAPLSMW URDC_TOOLS 0471 [Documentation ]