Application Development and Automation 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: 
Read only

Upload data from flat file into module pool program

sachin_soni
Active Participant
0 Likes
2,107

Hi all,

i have data in my flat file in the following format:

0:2000:2029:34

now i have a module pool interface and i need to catch the figures into text boxes on the click of that button.if somebody can help i shall be delighted.

thanks and regards,

sachin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,528

sachin ,

try this 1st upload the data into the internal table.using GUI_upload

Map the fields of the internal table to the fields of the module pool interface.

you have to write ur code in the PAI on the click of that button.

say if that button is display.

when 'display'.

call function GUI_upload.

map the fields and then display it..........

12 REPLIES 12
Read only

Former Member
0 Likes
1,529

sachin ,

try this 1st upload the data into the internal table.using GUI_upload

Map the fields of the internal table to the fields of the module pool interface.

you have to write ur code in the PAI on the click of that button.

say if that button is display.

when 'display'.

call function GUI_upload.

map the fields and then display it..........

Read only

0 Likes
1,528

and ankur , can V upload ':' separated values into ITABs???

Read only

0 Likes
1,528

declare the itab with field type string.

and upload the data into itab.

using split statement separate the values into different fields.

move this field values to screen fields.

Read only

0 Likes
1,528

sachin ,

Try using this

HAS_FIELD_SEPARATOR = '<b>:</b>'

i guess you can do it

else the next option is take a string upload the data in the string and then split the data using SPLIT as told by sudha................

Read only

0 Likes
1,528

check this code.............

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = i_file

filetype = 'ASC'

TABLES

data_tab = it_datatab "ITBL_IN_RECORD[]

EXCEPTIONS

file_open_error = 1

OTHERS = 2.

Read only

0 Likes
1,528

hi Sachin,

Here is the dummy code for you...............

say there are only 4 fields in the flat file as mentioned

0:2000:2029:34

data : begin of itab occurs 0 ,

f1,

f2(4),

f3(4),

f4(2),

end of itab.

DATA: i_file type string

value 'C:\Documents and Settings\amarwaha\Desktop\test.txt'.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = i_file

  • filetype = 'ASC'

TABLES

data_tab = it_datatab "ITBL_IN_RECORD[]

EXCEPTIONS

file_open_error = 1

OTHERS = 2.

loop at it_datatab.

split it_datatab-row at ':' into itab-f1 itab-f2 itab-f3 itab-f4.

append itab.

endloop.

now itab has all the data in the four fields...........

Read only

0 Likes
1,528

ankur , the code doesnt takes care of ':' separator here

Read only

0 Likes
1,528

thx pal , u made it simple.

Read only

0 Likes
1,528

I just want to add one note: gui_upload reads the file from your local pc, and doesn't work in background.

If the file is not reachable from your PC or you want to read it from a batch job, you should use open dataset/read dataset instead.

Read only

Former Member
0 Likes
1,528

Use the SPLIT statement.

SPLIT <fieldname> at ':' into <field1>....

Hope this helps.

Sudha

Read only

0 Likes
1,528

sudha can u be a bit more clear please ,

Read only

Former Member
0 Likes
1,528

just create internal table with character dat type and in pbo module write

module upload, double click on upload and

in code

call function 'GUI_UPLOAD'

exporting

importing

tables

i_itab = tablename[]

...

reward points if helpful.

with regards,

suresh babu.