cancel
Showing results for 
Search instead for 
Did you mean: 

Upload Flat File in Z-table

Former Member
0 Kudos

Hello everyone,

We have a Z custom table which contains data about Customer Class. I was wondering if it is possible to load a flat file into the Z Table. Kindly advice how to load a flat file in z-table.

Thanks,

Sanju

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Sanju,

You need to develop a small ABAP. This program will use WS_UPLOAD or GUI_UPLOAD function module to upload flat file to an internal table. Then the Ztable can be inserted/updated using this internal table by using open sql statements.

Rgds,

Sarah.

Former Member
0 Kudos

Sarah,

Thanks for the vital input. I will modify the code. However, as I have not designed this ZTable and I wanted to look into the ABAP program - and I am using Tcode SE11.

Since I have display access to SE11, I can only see the fields in the table. I was wondering if there is any way to look at the ABAP code behind the Ztable.

Thanks,

Tushar

Former Member
0 Kudos

Hai Sanju,

I am not sure if this would work...but you could debug the code..can't you? just enter /H in the box(at top left where u enter the transaction code). If the table is readonly, then search for the word "SHOW" for your field and then change it to "EDIT". But this is not a good practise. may be you can try SE80..

shiva_kumar6
Explorer
0 Kudos

PLS WATCH THE CODE and kindly tell me the error

REPORT z_test.

TABLES: mara.

FIELD-SYMBOLS : <fs> .

DATA : fldname(50) TYPE c.

DATA : col TYPE i.

DATA : cmp LIKE TABLE OF rstrucinfo WITH HEADER LINE.

DATA: progname LIKE sy-repid,

dynnum LIKE sy-dynnr.

DATA itab TYPE TABLE OF alsmex_tabline WITH HEADER LINE.

DATA: BEGIN OF ZUPLOAD1_T OCCURS 0 ,

matnr like mara-matnr,

ersda like mara-ersda,

ernam like mara-ernam,

laeda like mara-laeda,

END OF ZUPLOAD1_T.

*DATA: ZUPLOAD1_T LIKE mara OCCURS 0 WITH HEADER LINE.

DATA: wa_data LIKE TABLE OF ZUPLOAD1_T WITH HEADER LINE.

  • selection-screen

SELECTION-SCREEN: BEGIN OF BLOCK blk WITH FRAME TITLE text-001.

SELECTION-SCREEN : SKIP 1.

PARAMETERS : p_file LIKE rlgrap-filename.

SELECTION-SCREEN : SKIP 1.

SELECTION-SCREEN : END OF BLOCK blk.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    • F4 Value for File

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

static = 'X'

  • MASK = ' '

CHANGING

file_name = p_file

EXCEPTIONS

mask_too_long = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = P_FILE

i_begin_col = 1

i_begin_row = 1

i_end_col = 5

i_end_row = 12507

tables

intern = ITAB

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = SY-REPID

fieldname = 'ZMARA'

tables

components = CMP.

LOOP AT itab.

AT NEW row.

IF sy-tabix = 1.

APPEND ZUPLOAD1_T.

ENDIF.

ENDAT.

col = itab-col.

READ TABLE cmp INDEX col.

CONCATENATE 'ZUPLOAD1_T-' cmp-compname INTO fldname.

ASSIGN (fldname) TO <fs>.

<fs> = itab-COL.

APPEND ZUPLOAD1_T.

ENDLOOP.

DELETE ZUPLOAD1_T where matnr eq space.

LOOP AT ZUPLOAD1_T INTO wa_data.

  • insert mara from wa_data .

WRITE: / ZUPLOAD1_T-matnr, 20 ZUPLOAD1_T-ersda , 45 ZUPLOAD1_T-ernam, 55 ZUPLOAD1_T-laeda.

*HERE IAM JUST CHECKING I NEED TO UPDATE A ZTABLE

ENDLOOP.

insert ZMARA FROM table itab ACCEPTING DUPLICATE KEYS.

Edited by: shivu kishu on Feb 7, 2011 10:29 AM

0 Kudos

I have 1 Small Tool... ABAP Report which can upload any Custom Table without any Effort.. Like SM30, LSMW, or SE16.

You can Upload with Excel File , It has Basic Master Data check to Avoid Data Inconsistency, Simulation Mode with ALV Grid as Output.

http://sapabapcodes.blogspot.in/2012/03/upload-any-custom-config-table-via.html

For More Detail Visit my Blog.

Former Member
0 Kudos

have you tried LSMW to lead it?Am not sure if it would work with custom tables.