2008 Jul 03 9:11 AM
Hi frnds,
I have a requirement where i have tables like
IT_BAPI_COND_RECS
IT_BAPI_KEY_FIELDS
IT_BAPI_DATA_FIELDS
IT_COND_HEADER
IT_COND_ITEM
IT_COND_QUANTITY_SCALE
IT_COND_VALUE_SCALE.
i have data for these tables in presentation server.
i have to use one gui_upload and upload data into these tables.
so can anyone help me how to use PERFORM using formal parameters and using to upload data.
regards,
satya
Hi,
Try this logic.
1. Create a FIELD-SYMBOLS which will contain your table name.
2. Pass that FIELD-SYMBOLS to parameter data_tab of GUI_upload.
3. Depending on the file you are uploading assign table name to that field symbol
FIELD-SYMBOLS <itab> type ANY TABLE.
check Typing Addition - generic_type for suitale table type.
after this u can assign any table name at runtime.for example
ASSIGN IT_BAPI_COND_RECS TO <itab>
then call function.
FORM upload_file.
v_fdpath = p_loadf.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_fdpath "file path form screen
write_field_separator = 'X'
TABLES
data_tab = <itab>
IF sy-subrc <> 0.
ENDIF.
ENDFORM. "download_file
2008 Jul 03 9:22 AM
Hi,
use this code:
Form upload using p_tabname.
data:stru_tab type ref to data.
field-symbols:<tab> type table.
create data stru_tab type standard table of (p_tabname).
assign stru_tab->* to <tab>.
Pass the field-symbol <tab> to the FM GUI_UPLOAD. After the call, you have the data in this table structured in according of p_tabname' s structure.
endform.
2008 Jul 03 9:27 AM
2008 Jul 03 9:29 AM
HI Sathya,
Here is a sample code to upload data from excel sheet directly using a diff function module.
This method is much simpler.
Sample Code
REPORT ZEXCELTOITABFS.
DATA: L_INTER LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE ,
L_INDEX TYPE I.
types: begin of TY_DATA,
MAT_NO(018),
MAKTX(040),
end of TY_DATA.
DATA: RECORD1 TYPE STANDARD TABLE OF TY_DATA,
RECORD TYPE TY_DATA.
FIELD-SYMBOLS <FS>.
parameter P_INFILE LIKE RLGRAP-FILENAME.
at selection-screen on value-request for P_INFILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_INFILE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_INFILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 4
I_END_COL = 2
I_END_ROW = 38
TABLES:
INTERN = L_INTER
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
.
SORT L_INTER BY ROW COL.
LOOP AT L_INTER .
MOVE L_INTER-COL TO L_INDEX.
ASSIGN COMPONENT L_INDEX OF STRUCTURE RECORD TO <FS>.
MOVE L_INTER-VALUE TO <FS>.
AT END OF ROW.
APPEND RECORD to RECORD1.
clear record.
ENDAT.
ENDLOOP.
Regards
VIjay
2008 Jul 03 9:37 AM
Hi frnds,
Below i am giving my code.
<code>
DATA : IT_BAPI_COND_RECS LIKE BAPICONDCT OCCURS 0 WITH HEADER LINE,
IT_BAPI_KEY_FIELDS LIKE BAPICONDDD OCCURS 0 WITH HEADER LINE,
IT_BAPI_DATA_FIELDS LIKE BAPICONDDD OCCURS 0 WITH HEADER LINE,
IT_COND_HEADER LIKE BAPICONDHD OCCURS 0 WITH HEADER LINE,
IT_COND_ITEM LIKE BAPICONDIT OCCURS 0 WITH HEADER LINE,
IT_COND_QUANTITY_SCALE LIKE BAPICONDQS OCCURS 0 WITH HEADER LINE,
IT_COND_VALUE_SCALE LIKE BAPICONDVS OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_CONTAB TYPE T681-KOTABNR,
P_upload LIKE RLGRAP-FILENAME,
P_dwnld LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK BLK1.
DATA: FILE_UPLOAD1 TYPE STRING,
FILE_UPLOAD2 TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_upload.
PERFORM GET_FILE1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_dwnld.
PERFORM GET_FILE2.
START-OF-SELECTION.
PERFORM DATA_UPLOAD USING TABLES IT_BAPI_COND_RECS
IT_BAPI_KEY_FIELDS
IT_BAPI_DATA_FIELDS
IT_COND_HEADER
IT_COND_ITEM
IT_COND_QUANTITY_SCALE
IT_COND_VALUE_SCALE.
I am confused how to write the form bcoz in my form there is
only one gui_upload involved.
frnds please help me its urgent issue.
regards
satya
2008 Jul 03 9:38 AM
Hi,
Try this logic.
1. Create a FIELD-SYMBOLS which will contain your table name.
2. Pass that FIELD-SYMBOLS to parameter data_tab of GUI_upload.
3. Depending on the file you are uploading assign table name to that field symbol
FIELD-SYMBOLS <itab> type ANY TABLE.
check Typing Addition - generic_type for suitale table type.
after this u can assign any table name at runtime.for example
ASSIGN IT_BAPI_COND_RECS TO <itab>
then call function.
FORM upload_file.
v_fdpath = p_loadf.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_fdpath "file path form screen
write_field_separator = 'X'
TABLES
data_tab = <itab>
IF sy-subrc <> 0.
ENDIF.
ENDFORM. "download_file
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |