Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

function module GUI_UPLOAD

Former Member
0 Kudos

Hi ,

Iam using GUI_UPLOAD function module to upload file from desktop to the internal table .Iam using more than 1 rows of data in text TAB delimated file .But when iam using the function module , it always take first record from the file and put it into internal table.

************************************************************************

  • Start-of-selection

************************************************************************

START-OF-SELECTION.

IF p_ppath IS NOT INITIAL.

l_filenm = p_ppath.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_filenm

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = itab_item

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.

ENDIF.

Regards,

Sri

21 REPLIES 21

Former Member
0 Kudos

Hi ,

gui

whikle formating the table itab_item and moving into another internal table..

ignore the first line it contains header

loop at itab_item.

if sy-tabix > 1.

split and move into another internal table..

Endif.

endloop.

or pass...


"pass this field in exporting it will solve u r problem

HEADER_LENGTH = 1

Regards,

Prabhudas

Edited by: Prabhu Das on May 21, 2009 5:55 PM

Former Member
0 Kudos

Hi,

You can create a seperate work area in which you can populate the Table for the Data and then you can pass the same to the function module.

You need to loop the table. Example

Loop at itab into WA.

fill the data tab.

clear WA.

Endloop.

Hope this will help. Just fill the work area and the internal Table properly.

Thanks,

Samantak.

0 Kudos

Hi Guys,

Iam dooing the same but iam still facing the problem .The code is as below

LOOP AT itab_item INTO wa_item.

MOVE-CORRESPONDING wa_item TO wa_final.

wa_final-zcre_date = sy-datum.

wa_final-zcre_by = sy-uname.

wa_final-zlast_chon = sy-datum.

wa_final-zlast_chby = sy-uname.

wa_final-d1= 'X'.

wa_final-d2 = 'X'.

wa_final-d3 = 'X'.

wa_final-d4 = 'X'.

wa_final-d5 = 'X'.

APPEND wa_final TO itab_final.

CLEAR: wa_item, wa_final.

  • Endloop.

Regards,

Sri

Former Member
0 Kudos

Try this code...

data : begin of itab_item occurs 0,

name(30),

address(30),

end of itab_item.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'c:\test.txt'

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = itab_item

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.

just take text file

Devolpment quality

production quality

0 Kudos

I Dont know why it is not working for me .

Regards,

Sri

0 Kudos

Hi,

Can you debug your code and see what exactly is getting filled in the table that is being passed??

Hope that will tell you the true picture.

Thanks,

Samantak

0 Kudos

can you able to show your declarations...

for me it is working fine.

please send your declarations data then we will with that structure only...

0 Kudos

try with

DAT_MODE = 'X'

0 Kudos

Hi Sekar,

Wether decleration is correct which i send ?

Regards,

Sri

Former Member
0 Kudos

Hi Sriram,

If you declared intenral table with header line then change data_tab under tables with body option.

TABLES
data_tab = itab_item[]

Otherwise, are you filling data in text file in a single row by tab delimited of entires records ?

Thanks,

Vinay

0 Kudos

Hi ,

The decleration is as of below ,

TYPES: Begin of T_Record,

MANDT type MANDT,

ZITEM TYPE ZTEST_STAGING-ZITEM,

END OF ty_item.

Regards,

Sri

0 Kudos

Look at this once...

Hope this clears your problem.

TYPES: Begin of ty_item,

MANDT type MANDT,

ZITEM TYPE ZTEST_STAGING-ZITEM,

END OF ty_item.

data : itab_item type standard table of ty_item.

************************************************************************

  • Start-of-selection

************************************************************************

START-OF-SELECTION.

IF p_ppath IS NOT INITIAL.

l_filenm = p_ppath.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_filenm

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = itab_item

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.

0 Kudos

Hi ,

Still facing problem,

When iam chaning decleration of some other structure , it is working .But it is not working for my structure.

Regards,

Sri

0 Kudos

can you post your full program code ?

0 Kudos

Here is the code ,

TYPES: Begin of Ty_item,

MANDT type MANDT,

ZITEMrr TYPE Zdata-ZITEMrr,

ZMPNNtt TYPE Zdata-ZMPNNtt,

ZWERKSrr TYPE Zdata-ZWERKSrr,

ZCODErr TYPE Zdata-CODErr,

ZCODEgdg TYPE Zdata-ZCODEdg,

ZCODEdg1 TYPE Zdata-ZCODEdg1,

ZCODEdg TYPE Zdata-CODEdg,

ZNOdg TYPE Zdata-NOdg,

ZPERCENTdg TYPE Zdata-PERCENTdg,

ZACTIVEdg TYPE Zdata-activedg,

ZDATEdg TYPE SY-DATUM,

END OF Ty_item.

DATA: itab_item TYPE STANDARD TABLE OF ty_item INITIAL SIZE 0,

wa_item TYPE ty_item.

DATA: itab_final TYPE STANDARD TABLE OF ty_item INITIAL SIZE 0,

wa_final TYPE ty_item.

DATA: l_filenm TYPE string.

************************************************************************

  • Selection Screen

************************************************************************

PARAMETERS: p_ppath TYPE char128.

************************************************************************

  • At Selection screen on Value Request

************************************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ppath.

PERFORM sub_get_filename CHANGING p_ppath.

************************************************************************

  • Start-of-selection

************************************************************************

START-OF-SELECTION.

IF p_ppath IS NOT INITIAL.

l_filenm = p_ppath.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_filenm

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = itab_item[]

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.

ENDIF.

LOOP AT itab_item INTO wa_item.

MOVE-CORRESPONDING wa_item TO wa_final.

.

APPEND wa_final TO itab_final.

CLEAR: wa_item, wa_final.

Endloop.

REFRESH itab_item.

IF NOT itab_final[] IS INITIAL.

MODIFY Zdata FROM TABLE itab_item.

COMMIT WORK.

ENDIF.

&----


*& Form sub_get_filename

&----


FORM sub_get_filename CHANGING p_file TYPE char128.

DATA : l_path TYPE string. " For Directory

DATA : l_path1 TYPE string. " For Directory

DATA : l_path2 TYPE string. " For Directory

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = sy-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = p_file.

0 Kudos

Hi,

check ur declaration once as you have posted earlier as below,

TYPES: Begin of T_Record,

MANDT type MANDT,

ZITEM TYPE ZTEST_STAGING-ZITEM,

END OF ty_item.

The Begin of dosn't match with End of.

0 Kudos

Hi Guys,

Fine now it is working.But header record (empty row ) is also updating into data base table .

Can any one tell me how can i skip this?

Regards,

Sri

0 Kudos

Hi,

As you are clearing the work area dont think it will effect the database and seeing your code,

 IF NOT itab_final[] IS INITIAL. MODIFY Zdata FROM TABLE itab_item. COMMIT WORK. ENDIF. 

guess you should be using,

IF NOT itab_final[] IS INITIAL. MODIFY Zdata FROM TABLE itab_final. COMMIT WORK.ENDIF.

Thanks

Ramana

Former Member
0 Kudos

Hi,

Can you debug and check after calling functinal module,how many records are getting into internal table.

if only one record is getting fetched then, check the flat file, sometimes spaces in the flat file will make difference,in particular after the end of first record's last field value.

Thanks

Ramana

Former Member
0 Kudos

Ans

0 Kudos

Hi,

I tried all your suggestions but it is not working. I am trying to upload an Excel sheet.

Thanks

Jean