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

ztable upload

Former Member
0 Likes
578

Hi Experts,

data is coming from flatfile with 16 fields

we have to upload the data into ztable .

but the ztable having another two fields( STATUS and DATE)

if the correct record comes from flat file, the status filed in ztable should be updated with 'C'.

if the error record comes from flat file , the status filed in ztable should be updated with 'E'.

please help me

Regards,

Vinayaka

4 REPLIES 4
Read only

andreas_mann3
Active Contributor
0 Likes
532

1) define a structure for your input in se11

-> move input in this struc.

2) create check-routines in your upload-program

-> check your data and fill status

3) move sy-datum to your struc

4) insert data in ztable

A.

Read only

Former Member
0 Likes
532

upload data with GUI_UPLOAD into a internal table....( all must have char type flds..)

assign one by one into 16 flds....

check the data and accordingly change the status code....

then use... modify table

Read only

Former Member
0 Likes
532

Use FM "GUI_UPLOAD" to upload the file into an internal table.Then check the status to populate an internal table type "Z" table.Lastly use INSERT/MODIFY statement to save the data in the "Z" table.

Read only

Former Member
0 Likes
532

Hi,

first declare a structure(t_uplaod) of the ztable which u have to upload.

Also

declare the below mentioned data.

DATA: i_upload TYPE STANDARD TABLE OF t_upload,

x_upload TYPE t_upload,

g_data(1000),

x_download TYPE ztable,

idownload TYPE STANDARD TABLE OF ztable.

After that,

DATA: g_dataset TYPE v_filenaci-fileextern VALUE 'file name with file path'.

*CONSTANTS: g_sep TYPE d VALUE '09'.

DATA: w_vline TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

OPEN DATASET g_dataset IN TEXT MODE FOR INPUT ENCODING DEFAULT.

IF NOT sy-subrc IS INITIAL.

  • MESSAGE

EXIT.

ENDIF.

DO.

***Read the file***

READ DATASET g_dataset INTO g_data.

if sy-subrc <> 0.

exit.

endif.

SPLIT g_data AT w_vline INTO

x_upload-field1

x_upload-field2

x_upload-field3.

if sy-subrc = 0.

x_upload-status = 'S'.

else.

x_upload-status = 'E'.

endif.

MOVE-CORRESPONDING x_upload TO x_download.

APPEND x_download TO i_download.

CLEAR x_download.

ENDDO.

***Close the file***

CLOSE DATASET g_dataset.

MODIFY ztable FROM TABLE i_download.

please note that the flat file has only the entries and not the field names as first line.

Reward me the points if useful to you.