04-06-2011 10:02 PM
Hi Dev Gurus,
I'm trying to update/insert a record in a table (represented through a field symbol) by an internal table (represented through another field symbol).
MODIFY <DBTABLE> FROM <T_ITAB>.
I can't seem to make this work no matter which approach I try.
Any help would be appreciated.
Thanks,
Brian
Edited by: bwaugh06 on Apr 6, 2011 11:04 PM
04-07-2011 6:39 AM
Hi
Use
MODIFY (lv_table_name) FROM TABLE <fs_table_data>.
(FIELD-SYMBOLS : <fs_table_data> TYPE ANY TABLE.)
Regards
Renu
04-07-2011 6:39 AM
Hi
Use
MODIFY (lv_table_name) FROM TABLE <fs_table_data>.
(FIELD-SYMBOLS : <fs_table_data> TYPE ANY TABLE.)
Regards
Renu
04-07-2011 7:23 AM
04-07-2011 7:32 AM
Hello Brian,
I'm trying to update/insert a record in a table (represented through a field symbol) by an internal table (represented through another field symbol).
You can't represent a DB table using FIELD-SYMBOL. Dynamic tokens are represented by brackets '( )'. May be i'm missing something here.
BR,
Suhas
04-07-2011 1:28 PM
Here is my complete code for reference. Simply making it so a user can input the Table and Select File and the itab is created dynamically and the file is imported into the table. I have tried vinraaj idea but with no sucess as it doesn't accept <DBTABLE>. Renu Gusain I think you might have the right idea but I don't understand how the standard table <DBTABLE> is supposed to defined and assigned. (DBTABLE) ? Suhas thanks for your input, I will look into dynamic tokens.
TABLES SSCRFIELDS.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data.
DATA: FILE_PATH LIKE RLGRAP-FILENAME,
FILE_PATH_STR TYPE STRING.
DATA: TOTAL_RECORDS TYPE I .
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE," ANY TABLE.
<DBTABLE> TYPE w_tabname,
<BLAH> TYPE ANY.
SELECTION-SCREEN BEGIN OF BLOCK OPTIONS WITH FRAME TITLE TEXT-F00 .
PARAMETERS: P_TABLE TYPE w_tabname DEFAULT 'ZLAB_CERTS_MACRO'.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT:/1(20) text-001.
SELECTION-SCREEN PUSHBUTTON 33(20) FILE_P USER-COMMAND CLICK.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT:/1(79) text-002.
SELECTION-SCREEN SKIP 4.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT:1(25) text-003.
SELECTION-SCREEN POSITION 26.
PARAMETERS: P_DEL AS CHECKBOX.
SELECTION-SCREEN End of LINE.
SELECTION-SCREEN END OF BLOCK OPTIONS.
ASSIGN P_TABLE TO <DBTABLE>.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = 'CLICK'.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'FILE_LOC' "Here file_LOC is the text Element name on Screen.
IMPORTING
file_name = FILE_PATH.
ENDIF.
INITIALIZATION.
MOVE 'Select text file' to FILE_P.
START-OF-SELECTION .
IF FILE_PATH IS INITIAL.
MESSAGE S000(ZC) WITH 'Please select file path'.
CALL TRANSACTION 'ZUPLOADFILE'.
ELSEIF P_TABLE IS INITIAL.
MESSAGE S000(ZC) WITH 'Please select file path'.
CALL TRANSACTION 'ZUPLOADFILE'.
ENDIF.
* ---------------------------------------------------------------------
* Dynamically assign the table
* ---------------------------------------------------------------------
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
* ---------------------------------------------------------------------
* Read in the data from the external file
* ---------------------------------------------------------------------
FILE_PATH_STR = FILE_PATH.
"In FILE_PATH you get the excel file path , ehich you want to upload in Internal table ex: E:\Prem\Premral_details.xls' and we pass this file name to the following function Module which Return back the Internal table of its own Format ."
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = FILE_PATH_STR
has_field_separator = 'X' "file is TAB delimited
TABLES
data_tab = <t_itab>
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.
IF sy-subrc NE 0.
MESSAGE S000(ZC) WITH 'Error uploading file'.
CALL TRANSACTION 'ZUPLOADFILE'.
endif.
MODIFY (DBTABLE) FROM TABLE <T_ITAB>.
04-07-2011 1:56 PM
07-08-2011 11:00 AM
could you please tell me how you solved this problem? I am also facing the same problem while modifying a DB table from a dynamic internal table(with the same schema).
Thanks
Sanjay