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