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

Z* tables update

Former Member
0 Likes
1,211

Dear All,

The requirement is to update any Ztable, the user inputs in the selection screen and the file corresponding to Ztable .

Basically, User will input any Z*table name and select the file present in desktop .

The file data has to be uploaded into Ztable entered in the selection screen.

Can someone suggest or tell how we can do this?

Regards

Dear All,

The requirement is to update any Ztable, the user inputs in the selection screen and the file corresponding to Ztable .

Basically, User will input any Z*table name and select the file present in desktop .

The file data has to be uploaded into Ztable entered in the selection screen.

Can someone suggest or tell how we can do this?

Regards

9 REPLIES 9
Read only

Former Member
0 Likes
1,183

Record BDC for SM30 for particular Z table. Then upload the fle which you want and replace the field value with uploaded information. You need to define dynamic internal table with Z table structure.

Regards

Nilesh Shete

Read only

Former Member
0 Likes
1,183

Hi

Write a simple program

Decalre 2 paramters on selection screen one for Ztable and other for file

use the GUI_DOWNLOAD to download the file to Internal table which is similar to the Entered z table.

Insert the data into the ZTABLE with the entries from Internal table. Update it.

Reward points if useful

Regards

Anji

Read only

0 Likes
1,183

No No, it's not for a particular Ztable.

Let's say first time user enters ZTABLE1 and file1, it has to update ZTABLE1.

Next time user enters ZTABLE2 and file2, it has to update ZTABLE2 and so on.

It has to be dynamic.

Regards

Read only

0 Likes
1,183

Then you need to create the Dynamic internal table. That internal table has to be created based on the table structure which you have entered in the selection screen. Then pass the data from presentation server to that internal table and then insert data into data base table based on that internal table.

For creating dynamic internal table find the help from below link.

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

Regards,

Raj

Read only

0 Likes
1,183

u have to select the fields of the table from dd03l. then create an internal table for that. see sample code.

DATA: wa_fldcat TYPE LVC_S_FCAT.

DATA: it_fldcat TYPE LVC_T_FCAT.

DATA: it TYPE REF TO DATA.

*parameters : p_week type kweek.

parameters : p_tabnm type TABNAME16.

FIELD-SYMBOLS: <fs_table> TYPE TABLE.

FIELD-SYMBOLS: <fs_temp> TYPE ANY.

data : t_dd03 like dd03l occurs 0 with header line.

select * from dd03l into corresponding fields of table t_dd03

where tabname = p_tabnm.

loop at t_dd03.

wa_fldcat-fieldname = t_dd03-fieldname.

wa_fldcat-tabname = 'IT'.

wa_fldcat-datatype = t_dd03-rollname.

append wa_fldcat to it_fldcat.

endloop.

*CREATE THE DYNAMIC INTERNAL TABLE

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fldcat[]

IMPORTING

EP_TABLE = it.

ASSIGN it->* TO <fs_table>.

now u have an internal table ( field symbol) with structure of your table mentioned on selection screen. now play with this

Read only

0 Likes
1,183

Hi Sujamol,

Good Answer.

The dymamic internal table is created with the given Ztable in the selection screen.

Now the problem is when I try to upload this table <fs_table> using function module 'UPLOAD'.

The first column of flat file is getting updated in Mandt of <fs_table>.

I want to update Sy-mandt in MANDT of <fs_table> and the rest of the fields with flat file data.

e.g.

Flat file data:

100 white

101 black

<fs_table> structure is getting uploaded as below

mandt zcode zdesc

100 white

101 black

if the clint is 700

it has to be uploaded as

mandt zcode zdesc

700 100 white

700 101 black

Can you suggest me how to go about this or anyone who has any idea.

Regards

Read only

0 Likes
1,183

The blunt way of doing it is...

1. declare an internal table which has only one field which holds the entire record with tab delimiters.(itab)

data: begin of itab occurs 0,

record type string,

end of itab.

2. dynamic internal table(itab1)

3. upload ur file to itab

4. process itab splitting the record at the tab delimit and populate itab1.

5. now that you have your itab1 as that of ztable, update ztable.

Award points if it helps.

Read only

0 Likes
1,183

YOu caould do the way Vinni suggested, or if the MANDT field can be removed from the Z table. However it needs to be removed from all the Z tables since it can be used for any Z table.

However there could be some tables without the mandt field.

ALso noth that the method Vinni has suggested might give errors of the table dosent have the MANDT field.

I think sooo, so please check that sceniaro as well.

Shreekant

Read only

0 Likes
1,183

Hi Vinni,

Could you also explain on how can we transfer internal table contents itab to <fs_tab>. Like spliting and transfering to <fs_tab>.

Regards