‎2008 Feb 07 2:24 PM
Hi,
I want to modify a z-table from an internal table. However the z-table has fewer columns hence I only want to write selected columns from my internal table.
I tried:
LOOP AT IT_RECORD INTO WA_RECORD.
MODIFY ZTEST FROM WA_RECORD.
ENDLOOP.
This does not work the way I want because it writes to the wrong columns. Any suggestions?
‎2008 Feb 07 2:27 PM
DATA: wa_ztest TYPE ztest.
LOOP AT IT_RECORD INTO WA_RECORD.
MOVE-CORRESPONDING wa_record TO wa_ztest.
MODIFY ZTEST FROM wa_ztest.
ENDLOOP.
‎2008 Feb 07 2:25 PM
‎2008 Feb 07 2:26 PM
You can, but willl not suggest you to modify any standard DB table. You custom table is ok.
But remember to pass all the key fields while modifying.
Jayant Sahu
‎2008 Feb 07 2:27 PM
DATA: wa_ztest TYPE ztest.
LOOP AT IT_RECORD INTO WA_RECORD.
MOVE-CORRESPONDING wa_record TO wa_ztest.
MODIFY ZTEST FROM wa_ztest.
ENDLOOP.
‎2008 Feb 07 2:27 PM
Hi Kulbir Paji
Hope it wil help you.
modify itab_lcplanning from wa_struct transporting tasstdate tasenddate
where phcode = wa_struct-phcode and wpcode = ' ' and actcode = ' ' and tascode = ' ' and
fitgapcd = ' ' and subtascd = ' ' and dlcode = ' '.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 7, 2008 6:22 PM
‎2008 Feb 07 2:30 PM
‎2008 Feb 07 11:33 PM
What about this:
LOOP AT it_record INTO wa_record.
UPDATE ztest
SET zf1 = wa_record-f1
zf2 = wa_record-f2
* etc.
WHERE key1 = wa_record-key1
AND key2 = wa_record-key2.
* AND etc.
ENDLOOP.
Rob
‎2008 Feb 08 8:22 AM
‎2008 Feb 08 2:40 PM
‎2008 May 26 9:45 AM
Hi,
I have written a small programm which reads from the local csv
file and writes it first in the internal and then in the database table. I have not tried to write the record directly in the database table because in the db table i have used float datatypes and 'GUI_UPLOAD' function return only string.
The colums in the CSV file should not be separated through ; or , but should separated through . It can be achieved through macros or simply Replace function in most of the editors. so here is the Code. I hope it will be helpful.
CSV STRUCTURE:
...
4711 1 -0.113959745 -0.128854014 0.014869883
4711 2 0.229442479 -0.045338936 0.274622951
4711 3 0.424455196 0.575343255 -0.152001065
4711 4 0.967714968 0.938023954 0.030049754
4711 5 -0.239151217 -0.288232776 0.04890217
4711 6 -0.38852287 -0.390814502 0.00228029
4711 7 -0.64254495 -0.457956474 -0.183518857
4711 8 0.861369672 0.862771555 -0.001417447
...ABAP CODE
REPORT zfash_csvupload.
"Struktur zum einlesen einzelnen spalten von eine CSV datei.
"Datentyp müssen String sein.
TYPES: BEGIN OF typestr_csv_daten,
geschfnr TYPE string,
histotag TYPE string,
bw_fx_zins TYPE string,
bw_fx TYPE string,
bw_zins TYPE string,
END OF typestr_csv_daten.
"Struktur zum Konvertieren string in enstprechenden datentypen.
TYPES: BEGIN OF type_csv_daten,
geschfnr TYPE i,
histotag TYPE i,
bw_fx_zins TYPE f,
bw_fx TYPE f,
bw_zins TYPE f,
END OF type_csv_daten.
DATA it_csv_str TYPE TABLE OF typestr_csv_daten.
DATA wa_csv_str TYPE typestr_csv_daten.
DATA it_csv TYPE TABLE OF type_csv_daten.
DATA wa_csv TYPE type_csv_daten.
DATA wa_bw_fx_zins LIKE zfash_bw_fx_zins.
START-OF-SELECTION.
" GUI_UPLOAD zum hochladen einer Datei. GUI_Download zum downloaden einer Datei.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:Testdaten2.csv' "CSV-datei kann auch .txt endung haben
filetype = 'ASC'
has_field_separator = 'X' "Wenn X dann Separator in CSV muss vorhanden sein. Separator ist TABULAOR
* HEADER_LENGTH = 50
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = it_csv_str "interne tabelle wo csv daten geladen werden.
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
.
"Prüfen ob alles gut gelaufen ist.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
LOOP AT it_csv_str INTO wa_csv_str.
"Konvertierung lassen wir ABAP handeln :)
wa_csv-geschfnr = wa_csv_str-geschfnr.
wa_csv-histotag = wa_csv_str-histotag.
wa_csv-bw_fx_zins = wa_csv_str-bw_fx_zins.
wa_csv-bw_fx = wa_csv_str-bw_fx.
wa_csv-bw_zins = wa_csv_str-bw_zins.
"Working Area in interne Tabelle hinfügen.
INSERT wa_csv INTO TABLE it_csv.
MOVE-CORRESPONDING wa_csv TO wa_bw_fx_zins.
MODIFY zfash_bw_fx_zins FROM wa_bw_fx_zins.
WRITE: / wa_csv-geschfnr, ' ', wa_csv-histotag, ' ',
wa_csv-bw_fx_zins, ' ', wa_csv-bw_fx, ' ', wa_csv-bw_zins.
ENDLOOP.
ENDIF.
END-OF-SELECTION.