2011 Mar 18 11:16 AM
Hi,
My requirement is, I have to upload a file with number of columns being dynamic.
My Input file column number can vary based on the input data. For one entry it can have 10 columns of input and for another entry it can have just 5. First few columns are common for all entries and then from one particular column the next columns can vary based on the input data.
I have come across FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' , but for this FM we have to pass the scope of the excel, like the column and row details which is not the required thing in my case.
Please let me know as to how to achieve the requirement of uploading a file with he number of columns varying.
Thanks in advance.
Regards,
Dedeepya Thota
Hi,
My requirement is, I have to upload a file with number of columns being dynamic.
My Input file column number can vary based on the input data. For one entry it can have 10 columns of input and for another entry it can have just 5. First few columns are common for all entries and then from one particular column the next columns can vary based on the input data.
I have come across FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' , but for this FM we have to pass the scope of the excel, like the column and row details which is not the required thing in my case.
Please let me know as to how to achieve the requirement of uploading a file with he number of columns varying.
Thanks in advance.
Regards,
Dedeepya Thota
2011 Mar 18 11:29 AM
2011 Mar 18 12:07 PM
Hi,
Your saying in you excel sheet your entering the details.
As you said, Suppose your data is 5 columns. And each entry various
there are 3 records in excel sheet
one entry contains 5 columns of data
second entry contains only 2 columns of data
third entry contains 4 columns of data
As shown below
Column1 Column2 Column3 Column4 Column5
100 AA AA1 AA2 AA3
200 BB BB2
300 CC CC2 CC3
Now your excel sheet contains data as shown above.
When you upload this file to your internal table 3 entries will be uploaded and every column contains according to that column value in itab.
In this case record second entry column3 contains value BB2 will store in itab-column3, But as per our requirement it should store in itab-column4. Same will happen for third entry also.
In above case you report will not work.So wat you have to do is, definatly we know there is some maximum colums in entries.
You fix for that maximum no.columns in excel and declare your itab.
In excel you maintian the values according to the columns value which has to maintian.
For example like below.
Column1 Column2 Column3 Column4 Column5
100 AA AA1 AA2 AA3
200 BB BB2
300 CC CC2 CC3
If some columns are not having data that will be empty. It wont be any problem. Just you have to maintain your template for data
and according to your template you have declare itab in your report.
Regards,
Shankar.
2011 Mar 18 12:15 PM
Hi ,
try this way.
data : begin of itab occurs 0,
text(3000),
end of Itab.
data : begin of t_fiields occurs 0,
text(3000),
end of t_fiields .
Try to save the excel file in CSV(Comma Seprate value) Format.
and use GUI_UPLOAD ..
next all data in itab .
now split the First line into column into Number of columns
Split itab-text into table
Now create a Dynamic internal table With t_fields.
and next processs the Dynamic internal table table..
PrabhuD@s
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |