Code: Alles auswählen.
report zsdvm011 no standard page heading
line-size 085
line-count 65.
**DDIC Strukturen
tables: usr21
,adrp
.
data: begin of tb_input occurs 0
, line(100)
, end of tb_input.
data: begin of tb_daten occurs 0
,persb(10)
,persn(10)
,name(50)
,kostl like usr21-kostl
,bname like usr21-bname
,accnt like uslogond-accnt
,end of tb_daten.
data: begin of tb_protokoll occurs 0
,bname like usr21-bname
,end of tb_protokoll.
data: begin of tb_table occurs 0,
name(128),
size type epsfilsiz,
rc type epsftprc,
end of tb_table.
data: datei like rlgrap-filename
,delimiter(1) value ';'
,bdcdata like bdcdata occurs 0 with header line
,tcode like sy-tcode "Transaktionskode
,datei_txt(100)
,datei_csv(100)
,string(100)
,anzahl type i
,anzahl1 type i
,text(10)
,text1(10)
,filename like epsf-epsfilnam
,a type i
,b type i
,forinv(1)
.
*Bildschirm
selection-screen begin of block 1 with frame title text-001.
selection-screen skip.
selection-screen begin of line.
selection-screen comment 1(13) text-011.
parameters: p_pfad like epsf-epsdirnam lower case.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(13) text-012.
parameters: p_datei like epsf-epsdirnam lower case.
selection-screen end of line.
selection-screen skip.
selection-screen end of block 1.
initialization.
move '\\Servername\Laufwerk\Verzeichnis\' to p_pfad.
move 'Dateiname.csv' to p_datei.
start-of-selection.
if p_pfad is initial.
perform message using 'Servername und Pfad eingeben.'.
stop.
endif.
if p_datei is initial.
perform message using 'Dateiname eingeben.'.
stop.
endif.
a = strlen( p_datei ).
b = a - 3.
concatenate p_datei(b) 'txt' into datei_txt.
move p_datei to datei_csv.
*CSV Datei vorhanden ??
move datei_csv to filename.
perform get_direktory_files.
concatenate p_pfad datei_txt into datei.
perform fortschritt using 'Lösche Textdatei' 0.
perform delete_file.
perform fortschritt using 'Erstelle Textdatei' 0.
perform rename_file. "Umbenennen von csv in txt
wait up to 10 seconds.
*TXT Datei vorhanden ??
move datei_txt to filename.
perform get_direktory_files.
perform fortschritt using 'Importiere Textdatei' 0.
perform get_input.
perform fortschritt using 'Abrechnungsnummer wird eingepflegt' 0.
perform su01.
perform fortschritt using 'Erstelle Bearbeitungsprotokoll' 0.
perform protokoll.
*---------------------------------------------------------------------*
* FORM get_input *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form get_input.
open dataset datei for input in text mode encoding non-unicode.
if sy-subrc ne 0.
perform message using text-015.
stop.
endif.
do.
read dataset datei into tb_input.
if sy-subrc ne 0. exit. endif.
append tb_input.
enddo.
close dataset datei.
loop at tb_input.
check sy-tabix > 2.
clear tb_daten.
split tb_input-line at delimiter into
tb_daten-persb tb_daten-persn tb_daten-name
tb_daten-kostl
tb_daten-bname tb_daten-accnt.
append tb_daten.
endloop.
describe table tb_daten lines anzahl.
endform.
*---------------------------------------------------------------------*
* FORM su01 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form su01.
clear anzahl1.
loop at tb_daten.
select single * from usr21
where bname eq tb_daten-bname.
if sy-subrc ne 0.
move tb_daten-bname to tb_protokoll-bname.
append tb_protokoll.
add 1 to anzahl1.
else.
move anzahl to text.
move sy-tabix to text1.
concatenate: 'Von' text 'Benutzern, wird der'
text1 '. bearbeitet' into string separated by space.
perform fortschritt using string 0.
clear bdcdata.
refresh bdcdata.
* PERFORM open_group.
perform bdc_dynpro using 'SAPLSUU5' '0050'.
perform bdc_field using 'BDC_OKCODE'
'=CHAN'.
perform bdc_field using 'USR02-BNAME'
tb_daten-bname.
perform bdc_dynpro using 'SAPLSUU5' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=LOGO'.
perform bdc_dynpro using 'SAPLSUU5' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_field using 'USLOGOND-ACCNT'
tb_daten-accnt.
* PERFORM bdc_transaction USING 'SU01'.
* PERFORM close_group.
* STOP.
call transaction 'SU01' using bdcdata mode 'E'.
clear tb_daten.
endif.
endloop.
endform.
*---------------------------------------------------------------------*
* FORM open_group *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form open_group .
data: holddate like sy-datum.
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = 'Abrechnung'
user = sy-uname
keep = 'X'
holddate = holddate.
endform.
*---------------------------------------------------------------------*
* FORM close_group *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form close_group.
call function 'BDC_CLOSE_GROUP'.
endform.
*---------------------------------------------------------------------*
* FORM BDC_DYNPRO *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PROGRAM *
* --> DYNPRO *
*---------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
append bdcdata.
endform.
*---------------------------------------------------------------------*
* FORM bdc_transaction *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> TCODE *
*---------------------------------------------------------------------*
form bdc_transaction using tcode.
call function 'BDC_INSERT'
exporting
tcode = tcode
tables
dynprotab = bdcdata.
refresh bdcdata.
endform.
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
clear bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
append bdcdata.
endform.
*---------------------------------------------------------------------*
* FORM rename_file *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form rename_file.
concatenate '/c rename' p_pfad datei_csv into string.
concatenate string datei_txt into string separated by space.
call function 'GUI_RUN'
exporting
command = 'cmd'
parameter = string.
endform.
*---------------------------------------------------------------------*
* FORM delete_file *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form delete_file.
call function 'GUI_DELETE_FILE'
exporting
file_name = datei
exceptions
failed = 1
others = 2.
endform.
*---------------------------------------------------------------------*
* FORM protokoll *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form protokoll.
format intensified on.
write: 'Protokoll zur Benutzerpflege der Abrechnungsnummer'.
skip.
write: 'Von ',anzahl, ' Benutzern, konnten ',anzahl1,' Benutzer'
,' nicht gefunden werden.'.
skip 2.
format reset.
loop at tb_protokoll.
perform zebra.
write: / tb_protokoll-bname.
endloop.
endform.
*---------------------------------------------------------------------*
* FORM message *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> TEXT *
*---------------------------------------------------------------------*
form message using text.
call function 'POPUP_TO_INFORM'
exporting
titel = 'Änderung der Abrechnungsnummer.'
txt2 = space
txt1 = text.
endform.
*---------------------------------------------------------------------*
* FORM fortschritt *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> IP_TEXT *
* --> IP_PROZ *
*---------------------------------------------------------------------*
form fortschritt using ip_text ip_proz.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
percentage = ip_proz
text = ip_text.
endform. " fortschritt
*---------------------------------------------------------------------*
* FORM get_direktory_files *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form get_direktory_files.
* Dateien aus dem Verzeichnis in die Filetabelle (DSN_TABLE) laden.
call function 'EPS_GET_DIRECTORY_LISTING'
exporting
dir_name = p_pfad
file_mask = filename
tables
dir_list = tb_table
exceptions
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7.
case sy-subrc.
when 0.
when 4.
perform message using text-004.
stop.
when 5.
perform message using text-003.
stop.
when 7.
perform message using text-006.
stop.
when others.
perform message using text-005.
stop.
endcase.
endform.
*---------------------------------------------------------------------*
* FORM zebra *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form zebra.
if forinv eq 'J'.
format color 2 intensified.
forinv = ' '.
else.
format color 2 intensified off.
forinv = 'J'.
endif.
endform. .