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: 

BDC for Uploading data from XL sheet with unknown order of fields

Former Member
0 Kudos

Hi SAP Gurus,

My requirement is as follows,

A BDC is to be developed for uploading data from an XL sheet, but the problem here is , the order of fileds in the sheet can be changed .

ie, for example the fields in the XL sheet are :-

  matnr    maktx   menge  amount 

but the user can give as

  matnr  amount  menge  maktx

or

 maktx   matnr  amount  menge 

how i can solve this problem.

Thanks and Regards,

pavan.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

Better you take every field like 40 chars and provide radio buttons in selection screen.based on the selection of option take the data in appropriate comnbination.

types:begin of st,

data1(40),

data2(40),

data3(40),

data4(40),

end of st.

Based on the radio button change the position of the variable in the recording.

regards,

Manesh

4 REPLIES 4

Former Member
0 Kudos

Step-by-Step Process

Task 1: Recording

1. Give transaction SHDB ( Transaction Recorder ), this is used to record our transaction

Press New Recording, Give Recording name, Give Transaction, And Press Start Recording.

2. You will get the following screen, Give the selection screen inputs as below, finally

Save.

3. The following screen comes when you save, this shows table name and filed name

Which stores the data given in respected selection screen of transaction. Next Press

F3 to come back.

Task 2: Creating ABAP Report based on recording done

Now select your Recording and press Create program icon.

You will be asked to fill the following selection screens

􀃎 Using SE11 get the Length of the fields. It must be supplied in MS-Excel

Now we are going to Upload the following fields in

Task 3: Writing ABAP report to do data transfer

Now Four Steps in ABAP Editor:

1. Create an internal table for above fields in the report after Include bdcrecx1.

2. Next call upload function after start-of-selection

3. Put Loop after perform open group

Close loop using Endloop.

4. Now replace the constants in perform statement within loop by internal table name

With field name. Make the values used in recording in u201C. Then Save, Activate

This is your data in MS-Excel. This order must be in the Internal table of ABAP report.

Unformatted Excel

Selectu2018Textu2018

Now Give respected Length for each fields. By placing Cursor in each column, Right Click, Select Column Width.

Since LIFNR are 16 give that width.

After that save the excel file. And save a copy as Formatted text space delimited

Give OK, Yes, Then Close Excel by giving No.

Now come to ABAP editor and run the report, you will get the screen.

Select Call transaction Radio Button, and run in a mode. Press F8

Now in next screen Give the .prn file you saved previously. ( .prn must be selected )

Then press Transfer.

You will get following screen, Just Check for correct order of data, if yes, Press Enter

Next Screen comes, Press Enter.

The vendor created. And system shows log. If small errors you can select that from F4 help and run the report.

Testing

Former Member
0 Kudos

Hi,

In excel sheet header line is used?for example

Manterial Description Quantity

1 ABCD 2

2 EFGH 3

Or direct data will be present ? like

1 ABCD 2

2 EFGH 3

If Header line is present in Excel sheet then it is possible to up load data provided Header line descriptions remain same for columns in excel sheet. Else its not possible.

Former Member
0 Kudos

hi,

Better you take every field like 40 chars and provide radio buttons in selection screen.based on the selection of option take the data in appropriate comnbination.

types:begin of st,

data1(40),

data2(40),

data3(40),

data4(40),

end of st.

Based on the radio button change the position of the variable in the recording.

regards,

Manesh

dhirendra_pandit
Active Participant
0 Kudos

Hi Pavan,

You need to handle it by your self, you can create a dynamic table based on the file value.

The field name pass from file with the record as a header, and based on the header name create your dynamic table.

afterward you can pass your value to BDC.

for creating dynamic table you can use this method

call method cl_alv_table_create=>create_dynamic_table

exporting

  • i_style_table =

it_fieldcatalog = it_field[]

  • i_length_in_byte =

importing

ep_table = dyn_tab

  • e_style_fname =

exceptions

generate_subpool_dir_full = 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.

-Dhirendra