11-18-2009 4:39 PM
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.
12-10-2009 5:58 AM
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
12-09-2009 7:11 AM
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
12-09-2009 11:02 AM
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.
12-10-2009 5:58 AM
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
12-10-2009 10:33 AM
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