2008 Nov 24 12:42 PM
Hi guys,
I need to upload a ".txt " file in the internal table ITAB1 & ITAB2 having structure as below.
If u see the 6 fields in both the table are same.I need to use the same text file to upload data in two different internal table.Please guide.
itab1: CUSTOMER(10), "Customer
PART_CODE(18), "Parts Code
REF_NO(35), "Ref No.
REF_DATE(10), "Ref Date
QTY(12), "Parts Qty
TEXT(100), "Remark
itba2: CUSTOMER(10), "Customer
PART_CODE(18), "Parts Code
REF_NO(35), "Ref No.
REF_DATE(10), "Ref Date
QTY(12), "Parts Qty
PRICE(15), "Parts Price
WAERK(5), "Parts Currency
TEXT(100), "Remark
Hi guys,
I need to upload a ".txt " file in the internal table ITAB1 & ITAB2 having structure as below.
If u see the 6 fields in both the table are same.I need to use the same text file to upload data in two different internal table.Please guide.
itab1: CUSTOMER(10), "Customer
PART_CODE(18), "Parts Code
REF_NO(35), "Ref No.
REF_DATE(10), "Ref Date
QTY(12), "Parts Qty
TEXT(100), "Remark
itba2: CUSTOMER(10), "Customer
PART_CODE(18), "Parts Code
REF_NO(35), "Ref No.
REF_DATE(10), "Ref Date
QTY(12), "Parts Qty
PRICE(15), "Parts Price
WAERK(5), "Parts Currency
TEXT(100), "Remark
2008 Nov 24 12:46 PM
2008 Nov 24 12:46 PM
Use the FM GUI_UPLOAD to upload the file from local computer to SAP. Upload the file with the second structure and move it to the table you want to save it.
Saludos, Regards,
Enrique Ortiz.
2008 Nov 24 12:48 PM
Hi Alka,
Upload that text file into it_tab1 using FM GUI_UPLOAD.
Now use the following code:
Loop at it_tab1 into wa_tab1.
move corresponding wa_tab1 to wa_tab2.
append wa_tab2 to it_tab.
clear: wa_tab1,
wa_tab2..
endloop.
Hope this will help.
Regards,
Nitin.
2008 Nov 24 12:51 PM
hi,
To upload the data from txt file to an internaltable both the file and table should have the same structure.
but the internal tables specified here do not have the same structures.
upload to the table that have same structure as file and then move corresponding fields to other table...
hope it helps you
2008 Nov 24 12:57 PM
Data : begin of itab occurs 0,
CUSTOMER(10), "Customer
PART_CODE(18),
REF_NO(35), "Ref No.
REF_DATE(10), "Ref Date
QTY(12), "Parts Qty
TEXT(100), "Remark
end of itab.
Data : begin of itab1 occurs 0,
CUSTOMER(10), "Customer
PART_CODE(18), "Parts Code
REF_NO(35), "Ref No.
REF_DATE(10), "Ref Date
QTY(12), "Parts Qty
PRICE(15), "Parts Price
WAERK(5), "Parts Currency
TEXT(100), "Remark
end of itab1.
selection-screen begin of block b3 with frame title text-007.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-006.
PARAMETERS:p_file(90) modif id bbb.
SELECTION-SCREEN END OF BLOCK b1.
selection-screen end of block b3.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = space
def_path = space
mask = ',.,..'
mode = space
title = space
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0 AND sy-subrc <> 3.
MESSAGE e102(yb) WITH 'Error Selecting File'(007).
ENDIF.
DATA: filename TYPE string.
filename = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = 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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Loop at itab.
move-corresponding itab to itab1.
append itab1.
clear: itab1,itab.
endloop.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |