Ex cel to Internal Table
hello friends i have written this piece of code, it dose not have any error but when ececuted it gives a dump.
tables : zash.
DATA : BEGIN OF it_table OCCURS 0,
vbeln LIKE zash-vbeln,
posnr LIKE zash-posnr,
uepos LIKE zash-uepos,
netwr LIKE zash-netwr,
matnr LIKE zash-matnr,
END OF it_table.
TYPE-POOLS: slis.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
DATA: it_fldcat TYPE lvc_t_fcat,
wa_it_fldcat TYPE lvc_s_fcat.
TYPE-POOLS : abap.
DATA: new_table TYPE REF TO data,
new_line TYPE REF TO data.
DATA: xcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text .
PARAMETERS: p_file TYPE rlgrap-filename DEFAULT
'C:\Test.csv'.
PARAMETERS: p_flds TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
Add X number of fields to the dynamic itab cataelog
DO p_flds TIMES.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
APPEND wa_it_fldcat TO it_fldcat .
ENDDO.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA new_line LIKE LINE OF <dyn_table>.
ASSIGN new_line->* TO <dyn_wa>.
Upload the excel
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'
TABLES
intern = xcel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
Reformt to dynamic internal table
LOOP AT xcel.
ASSIGN COMPONENT xcel-col OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc = 0.
<dyn_field> = xcel-value.
ENDIF.
AT END OF row.
APPEND <dyn_wa> TO it_table.
CLEAR <dyn_wa>.
ENDAT.
ENDLOOP.
the dump occurs at the append statement into the internal atble it_table.
any advice,
Shejal Shetty.
HI shejal,
In your program, you are trying
to create a dynamic internal table,
using some list of fields.
1.
For this purpose,
in my program,
<b> there is an INDEPENDENT FORM</b>
whose inputs are
<b> LIST OF FIELDS, (just as u require)</b>
and from those, it consructs dynamic table.
2. Here is the program.
the dynamic table name will be
<DYNTABLE>.
3. U can use this program (FORM in this program)
to generate any kind of internal table
by specifying list of fields.
4.
REPORT abc.
COMPULSORY
FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
FIELD-SYMBOLS: <dynline> TYPE ANY.
DATA: lt TYPE lvc_t_fcat.
DATA: ls TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA : fldname(50) TYPE c.
DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
field list
ddfields-fieldname = 'BUKRS'.
APPEND DDFIELDS.
ddfields-fieldname = 'MATNR'.
APPEND DDFIELDS.
PERFORM mydyntable .
see <DYNTABLE> in debug mode.
BREAK-POINT.
INDEPENDENT FORM
FORM mydyntable .
Create Dyn Table From FC
FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
FIELD-SYMBOLS: <fs_1>.
FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
DATA: lt_data TYPE REF TO data.
data : lt TYPE lvc_t_fcat .
CONSTRUCT FIELD LIST
LOOP AT ddfields.
ls-fieldname = ddfields-fieldname.
APPEND ls TO lt.
ENDLOOP.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Assign Dyn Table To Field Sumbol
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <dyntable>.
ENDFORM. "MYDYNTABLE
regards,
amit m.
Similar Messages
-
Create dynamic internal table with deep structure;cell coloring dynamic ALV
Hi,
My requirement is to do cell colouring for a dynamic ALV.
So I am creating a dynamic internal table using the following method.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcatalog[]
IMPORTING
ep_table = i_output.
But how do I define field COLORS which should be again an internal table ?
Is there any other way for cell colouring?
Putting my problem in another way:
How do I create a dynamic internal table with one field as another internal table.
Quick replies are highly appreciated.
Thanks,
Nisha Vengal.halo Nisha
Before building the display table . you can add the field in the feild catalog right . This display table gets generated from the field catalog right
1 Create a global structute say ZEXTEND_FIELDCAT
2 Have fields like STYLE type lvc_t_styl
COLOR type LVC_T_SCOL.
3 Now you have to extend ur fieldcatalog
l_fieldcat-fieldname = COLOR'.
l_fieldcat-ref_field = 'COLOR'.
l_fieldcat-ref_table = 'ZEXTEND_FIELDCAT'.
APPEND l_fieldcat TO lt_field_catalog.
CLEAR l_fieldcat. -
Coloring of Particular Cells in a dynamic internal table(field symbols)
Hi,
I have a requirement to introduce color into some particular cells in a dynamic internal table(Field symbol) based on some conditions.I know that color can be introduced at cell level in the case of static internal table.But, can anybody tell me whether it is possible to introduce color to particular cells in the dynamic internal table(Field Symbol) .Please suggest me on this issue.
Thanks in advance,
RajeshHi,
This is the sample coding for the colour cell report.
Kindly go through it. It will helps u.
REPORT YMS_COLOURTEST .
DATA: BEGIN OF TP OCCURS 10, ID, NR(8), TEXT(255), END OF TP.
DATA: LENGTH TYPE I VALUE 8, " Length of list
TESTSTRING(15) TYPE C VALUE '012345678901234',
WIDTH TYPE I. " Width of list
DATA: TXT_REPORT LIKE DOKHL-OBJECT.
START-OF-SELECTION.
PERFORM HEADING.
PERFORM OUTPUT_BODY.
FORM HEADING.
FORMAT INTENSIFIED OFF. " Remove any INTENSIFIED
ULINE AT (WIDTH). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED." Title color
WRITE: / SY-VLINE. " Left border
WRITE: 'No |Colour |intensified |intensified off|',
'inverse' NO-GAP.
WRITE: AT WIDTH SY-VLINE. " Right border
ULINE AT (WIDTH). " Line below titles
FORMAT COLOR OFF.
ENDFORM.
FORM OUTPUT_BODY.
DO LENGTH TIMES.
PERFORM WRITE_LINE USING SY-INDEX.
ENDDO.
ENDFORM.
FORM WRITE_LINE USING COUNT TYPE I.
DATA: HELP(14) TYPE C,
COUNT1 TYPE I.
COUNT1 = SY-INDEX - 1.
WRITE: / SY-VLINE NO-GAP.
WRITE: (4) COUNT1 COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
CASE COUNT1.
WHEN '0'.
HELP = 'COL_BACKGROUND'.
WHEN '1'.
HELP = 'COL_HEADING'.
WHEN '2'.
HELP = 'COL_NORMAL'.
WHEN '3'.
HELP = 'COL_TOTAL'.
WHEN '4'.
HELP = 'COL_KEY'.
WHEN '5'.
HELP = 'COL_POSITIVE'.
WHEN '6'.
HELP = 'COL_NEGATIVE'.
WHEN '7'.
HELP = 'COL_GROUP'.
ENDCASE.
WRITE: HELP COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED OFF NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INVERSE NO-GAP.
WRITE AT WIDTH SY-VLINE NO-GAP.
ENDFORM.
Thanks,
Shankar -
Coloring an ALV Cell with DYNAMIC INTERNAL TABLES
Hello Gurus,
I need your help regarding coloring of a cell in my ALV Grid report with DYNAMIC tables.
I have used the call method in calling my ALV. (CALL METHOD gr_alvgrid->set_table_for_first_display).
Now my problem is, I can not bring out the cellcolor succesfully, I always ended up to dump (GETWA_NOT_ASSIGNED = You attempted to access an unassigned field symbol
(data segment 32807).
What I have done:
I've created 2 internal tables:
*1st table
*After appended all of my columns to gt_fieldcat
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_both.
ASSIGN gp_both->* TO <i_xtab1>.
*2nd table
Appended these column for CellColor
CLEAR wa_gtfldcat.
wa_gtfldcat-fieldname = 'CELLCOLOR'.
wa_gtfldcat-ref_table = 'CALENDAR_TYPE'.
wa_gtfldcat-ref_field = 'COLTAB'.
APPEND wa_gtfldcat TO gt_fieldcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_alvgrid.
ASSIGN gp_alvgrid->* TO <i_xtab2>.
*Work Areas for tab1 and tab2
CREATE DATA dref1 LIKE LINE OF <i_xtab1>.
ASSIGN dref1->* TO <wa_xtab1>.
CREATE DATA dref2 LIKE LINE OF <i_xtab2>.
ASSIGN dref2->* TO <wa_xtab2>.
*Move contents of table1 to table2 and modify cellcolor column
LOOP AT <i_xtab1> ASSIGNING <wa_xtab1>.
*-----Cell color assignment
DESCRIBE TABLE gt_fieldcat.
DO sy-tfill TIMES.
READ TABLE gt_fieldcat INTO wa_gtfldcat INDEX sy-index.
ASSIGN COMPONENT wa_gtfldcat-fieldname
OF STRUCTURE <wa_xtab1> TO <fs4>.
IF sy-subrc NE 0. EXIT .ENDIF.
ASSIGN COMPONENT wa_gtfldcat-fieldname
OF STRUCTURE <wa_xtab2> TO <fs3>.
IF sy-subrc NE 0. EXIT .ENDIF.
<fs3> = <fs4>.
ENDDO.
ASSIGN COMPONENT 'CELLCOLOR' OF STRUCTURE <wa_xtab2> TO <fs3>.
IF sy-subrc = 0.
PERFORM modify_cell_color USING 'ZZMATNR' <fs3>.
ENDIF.
APPEND <wa_xtab1> TO <i_xtab2>.
ENDLOOP.
*Call ALV
gs_layout-ctab_fname = 'COLORCELL'
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = <i_xtab2d>[]
it_fieldcatalog = gt_fieldcat
it_sort = lt_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
*--->Exception handling
ENDIF.
FORM modify_cell_color USING p_fieldname TYPE lvc_fname
pt_cellcolor TYPE table.
DATA l_cellcolor TYPE lvc_s_scol.
CLEAR l_cellcolor.
l_cellcolor-fname = p_fieldname.
l_cellcolor-color-col = 6. " Red.
l_cellcolor-color-int = 0.
l_cellcolor-color-inv = 0.
INSERT l_cellcolor INTO TABLE pt_cellcolor.
ENDFORM. " MODIFY_CELL_COLORHi,
The internal tabl which you are using to display the output should have one column in the end.
The cell in this column will contain an internal table of type 'lvc_s_scol'.
The contents of this internal table will be the field names of all other columns of your main internal table in the field FNAME and the required color in the field COLOR.
Please note that the field COLOR will have a hex value for different colors.
In the stucture is_layout whihc you pass to the method 'set_table_for_first_display'
the name of this last column should be given to the field 'ctab_fname'.
This will help you to give the colors to each cell.
for example
I have my data table as follows:-
ITAB1
MATNR MAKTX COLOR_TAB
1 ABC FNAME COLOR NOKEYCOL
MATNR 8000
MAKTX 8000
2 XYZ MATNR 10000
MAKTX 10000
So my internal table ITAB1 had 3 columns MATNR MAKTX and COLOR_TAB.
And COLOR_TAB will contain an internal table with 3 columns FNAME COLOR and NOKEYCOL.
The value to importing parameter IS_LAYOUT-CTAB_FNAME will be COLOR_TAB.
This will help you to assign various colors to the cell of the internal table ITAB.
When you have to change any color, then you will have to just change the entries in cell COLOR_TAB for the particular row and cell.
Regards,
Ankur Parab -
How can I create an internal space from the border in every cell in a table?
How can I create an space between the text contents and the border inside in every cell in a table in Pages?
Change the Inset margin in the Inspector palette > T tab > Text
-
Fetching data from internal table in smartform
Hi,
I'm able to fetch data from one internal table, but in the table the fields are not coming perfectly, can anybody help me in this?
Thanks in advance.Hi
You have to to specify the text node that you have created for the table that it belong to which cell in the table. Also you styles to format the text(eg: left aligned, center alinged etc)
If you have further query please post.
If this resolves your query close the thread and reward points
Cheers
Shafiq -
Editable ALV-No change in internal table
Hello Experts,
I have an ALV output, in which I have a column as editable. I have generated the output using 'REUSE_ALV_GRID_DISPLAY'. I got to know that after changing the editable cell's value, if we double click the cell or if operate with any PF-status components, the value will automatically get changed in internal table also. For double click I am getting the expected result. But If I click a button the value doesn't get changed in internal table. Is there any other change I have to do for this. If I have checkbox in ALV will it be rectified. But my requirement is when I click the button only It has to be modified in the database table.
Thanks and regards,
Venkat.Hi Venkat,
In your form for User Command
write following
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
Case 'User-Command'.
Endcase.
or
data : i_grid_settings type lvc_s_glay.
"Calling ALV grid for display
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = i_callback_user_command
i_grid_settings = i_grid_settings
is_layout = is_layout
it_fieldcat = it_fieldcat
tables
t_outtab = it_final
"for call back values from editable grid cells
i_grid_settings-edt_cll_cb = 'X'.
Hope it helps you,
Pratik -
Invoice: How to use more than one Internal Table's info in one Table
Hi ,
I am doing an invoice, and have the info from internal table wa_itgen showing - Matnr, material description and quantity.
I want to also invlude the info Unit Price and Total price on the table line, but can't seem to do it.
I know that someone I must fill an internal table as I did on the Table itself : is_bil_invoice-it_gen INTO wa_ITGEN.
( TYPE IBBIL_INVOICE).
So now I need to insert:
IS_BIL_INVOICE-IT_PRICE INTO WA_ITPRICE.
Do I insert Program Lines, or do it via a LOOP. Obviously it needs to go under the same Table's cells to incluce it.
I tried a LOOP, Program lines under the CELL of the table where I want it displayed, and even a Second table.
If I have the first table's info, the page displays under VF03, but as soon as I try to insert the 2nd Table's info, under VF03 the screen just not show anymore.
Please help - I've started looking at local maps for bridges... yes, to jump from...Hi try this,
in the program lines fetch unit price and total price based on ur invoice number(as u are already in main loop which fetches invoice no material no etc).
now loop that internal table with condition inv no = current invoice no and item no = item number
and display those values on a new text field accordingly.
sample code...
select vbeln
posnr
j_3asize
FKIMG
KZWI1
from vbrp
into table itab
where vbeln = GS_IT_GEN-BIL_NUMBER.
loop at itab into wa where vbeln = GS_IT_GEN-BIL_NUMBER and
posnr = GS_IT_GEN-ITM_NUMBER .
move : wa-j_3asize to v_grid,
WA-FKIMG TO V_QTY,
wa-KZWI1 to v_val.
v_up = v_val / v_qty.
endloop.---->like this -
How to read only particualr columns from excel sheet to internal table
Hi,
I have and excel sheet which has around 20 columns, in which i want to read only 6 columns. They are at different column positions, means the 1st column, 6thcolumn, 8th column so on..
Can we do this in sap? do we have any FM to do this?
Thanks.
Praveena.hi,
Use the below logic to fetch the data into internal table..You need to read the data cell by cell and update the internal table,
DATA l_count TYPE sy-tabix.
CONSTANTS: lc_begin_col TYPE i VALUE '1',
lc_begin_row TYPE i VALUE '2',
lc_end_col TYPE i VALUE '2',
lc_end_row TYPE i VALUE '3000'.
CLEAR p_i_excel_data. REFRESH p_i_excel_data.
* Function module to read excel file and convert it into internal table
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_p_file
i_begin_col = lc_begin_col
i_begin_row = lc_begin_row
i_end_col = lc_end_col
i_end_row = lc_end_row
TABLES
intern = i_data
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
* Error in file upload
IF sy-subrc NE 0 .
MESSAGE text-006 TYPE 'E'.
EXIT.
ENDIF.
IF i_data[] IS INITIAL .
MESSAGE text-007 TYPE 'E'.
EXIT.
ELSE.
SORT i_data BY row col .
* Loop to fill data in Internal Table
LOOP AT i_data .
MOVE i_data-col TO l_count .
ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO <fs_source> .
MOVE i_data-value TO <fs_source> .
AT END OF row .
* Append data into internal table
APPEND p_i_excel_data.
CLEAR p_i_excel_data.
ENDAT .
ENDLOOP .
ENDIF . -
Internal table data 1E2 automatically convert to scientific format
Dear all,
I have been searched for solution moths from the forums and tried all possible methods, but still no way to solve my above problem. I found a way to solve it partially for us, but may be very helpful for others who meet similly case like mine, so I posted here.
my problem is when I export my internal table data to Excel, the Cell data with 1E2 auto becomes 1.00E02, and 1E8 becomes 1.00E08, we need it to be 1E2 and 1E8 in excel.
you can recreate my problem by
1, input 1E2 into your Microsoft Excel, then Enter, it will auto change into scientific format. which is we do not want.
2, use any of your SAP system open any table as long as there is a Char (>3) field in that table. add some
data entry in that field in the form "any amount (<15) of numeric 1 to 9"E"any one or two numeric 1 to 9". such as, 123E2, 1234E12 etc. then save this table's data to local file spread sheet, or use any FM to download it to a Excel file, when you open this
file by Excel, the cell with above form will display as scientific. but
if you put three or more numeric after the "E", such as 123E123 it will
display correctly.
what I have done:
I searched in SCN for similar thread:
Export to Excel 2007 - item number problem
Exceding the limit of numbers in Excel at target side
Excel download cell format problem
Formating as Text in excel through SAP
Converting of amount field into excel file through GUI DOWNLOAD
Data downloaded to excel gets converted to exponential format.
Problem with Excel download and scientific number
Re: Issue in displaying numbers in Excel?
CSV Flat File Data Problem (Number converting to Scientific Notation)
Tested accordingly, But none of these works in our case. because our
ultimate receiver of email attachment will be external third party, we cannot ask
them to change anything in their Excel.
Search Microsoft help about Excel, http://support.microsoft.com/kb/214233,
and it says this "Automatic Number Formatting" is a normal behaviour of excel.
no way to turn it off, the "work-around" way that Microsoft provides is not suitable for our
case.
We test CL_iXML recently arrording to weblog http://wiki.sdn.sap.com/wiki/display/Snippets/FormattedExcelasEmailAttachment
it successful controled the format. so this could be a solution for others whose internal table size is small. but our 2MB internal table bocome 6MB when converted to xml file attachment, which cannot be received by our end user's mail box. too big.
So please advise your ideas.
Many thanks in advance!
Peter Ding
Thank you very much for your time!Hi,
You can achieve this by describing the spreadsheet in XML with the help of the DOM classes.
The later releases of Excel can read and save spreadsheets as XML, providing your release supports this you can achieve it.
Check out the following Wiki
[Excel - XML|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/exporting%2bdata%2bto%2bexcel%2b-%2bxml%2bto%2bthe%2brescue]
Regards,
Darren -
Reading long text from excel file to an internal table
Hi
Can any body tell me how to read long text from excel file to an internal table.
When i am using this FM KCD_EXCEL_OLE_TO_INT_CONVERT then it is reading only 32 characters from each cell.
But in my excel sheet in one of the cell has very long text which i need to upload into a internal table.
may i know which FM or what logic i need to use for this problem.
RegardsHi,
Here is an example program. It will upload an Excel file with two columns. You could also assign the Excel structure dynamically, but I wanted to keep the example simple. The main point is that the internal table (it_excel in this example) must match the Excel structure that you want to convert.
Remember, this is just an example to help you figure out how to properly use the technique. It will certainly need to be modified to fit your requirements, and as always there may be a better way to get the Excel converted... this is just one possibility that has worked for me in the past.
*& Report zexcel_upload_test *
REPORT zexcel_upload_test.
TYPE-POOLS: truxs.
TYPES: BEGIN OF ty_excel,
col_a(10) TYPE n,
col_b(35) TYPE c,
END OF ty_excel.
DATA: l_data_tab TYPE TABLE OF string,
l_text_data TYPE truxs_t_text_data,
l_gui_filename TYPE string,
it_excel TYPE TABLE OF ty_excel.
FIELD-SYMBOLS: <wa_excel> TYPE ty_excel.
PARAMETERS: p_file TYPE rlgrap-filename.
* Pass the file name in the correct format
l_gui_filename = p_file.
* Upload data from PC
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_gui_filename
filetype = 'ASC'
has_field_separator = 'X'
CHANGING
data_tab = l_data_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
* MESSAGE ...
EXIT.
ENDIF.
* Convert from Excel into the appropriate itab
l_text_data[] = l_data_tab[].
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = l_text_data
i_filename = p_file
TABLES
i_tab_converted_data = it_excel
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ...
EXIT.
ENDIF.
LOOP AT it_excel ASSIGNING <wa_excel>.
* Do something here...
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM filename_get CHANGING p_file.
* FORM filename_get *
FORM filename_get CHANGING p_in_file TYPE rlgrap-filename.
DATA: l_in_file TYPE string,
l_filetab TYPE filetable,
wa_filetab TYPE LINE OF filetable,
l_rc TYPE i,
l_action TYPE i,
l_init_dir TYPE string.
* Set the initial directory to whatever you want it to be
l_init_dir = 'C:\'.
* Call the file open dialog without multiselect
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Load file'
default_extension = '.XLS'
default_filename = l_in_file
initial_directory = l_init_dir
multiselection = 'X'
CHANGING
file_table = l_filetab
rc = l_rc
user_action = l_action
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
REFRESH l_filetab.
ENDIF.
* Read the selected filename
READ TABLE l_filetab INTO wa_filetab INDEX 1.
IF sy-subrc = 0.
p_in_file = wa_filetab-filename.
ENDIF.
ENDFORM. " filename_get
Regards,
Jamie -
How to send internal table data through mail from report in foreground
hi all,
iam trying to convert the internal table data into excel format and sending it through mail by runnning the report in foreground.
mail is going sucessfully with excel format,but iam facing the problem in the excel format of the material column as follows:
the matrno shows the wrong format -2.63E+11 instead of displaying correct format-263215000000.
Pls suggest the alternative process for the above mentioned problem.
Thanks,
Sivagopal R.Hi Siva,
Try to copy 263215000000 in one of the cells of excel sheet and press enter.It will automatically convert into -2.63E+11 .
This means the default formatting of the excel sheet makes this happen.If you convert the format of the cell to "NUMBER" then u will get the required result.
But I doubt whether or not it is possible through ABAP programming.
Regards,
Vimal. -
Unable to read edited cell values from table view 'LineEDIT' mode
Hello Gurus,
Need urgent help on Cell binding - Here's what I have:
I have a bsp with one tableview for users to update shelf quantity.
Selection mode is <b>Lineedit</b>. I used this only bcos in this I need not select a row to update it - let me know if this is wrong.
Our users do not like to click on the row to select and edit it! I am not getting the edited values from the tableview.
Although I am using a contoller and view, it's not really an MVC. Can someone please guide me on this?
<b>
code in IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS
append initial line to p_column_definitions assigning <def>.
<def>-columnname = 'SHLQTY'.
<def>-title = 'Shelf Qty'.
<def>-EDIT = 'X'.
Code in IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.
p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY(
id = p_cell_id
* type = 'DATE'
* showhelp = 'TRUE'
* type = 'QUAN'
VALUE = val
cellvalue = 'TRUE'
_VALUE = P_CELL_BINDING )
</b>
I do not see anything coming in <b>P_CELL_BINDING</b> .
Tableview in layout
<b>
<htmlb:tableView id = "result"
design = "STANDARD"
headerText = "Header Text"
filter = "SERVER"
onNavigate = "onMyNavigate"
selectionMode = "lineedit"
emptyTableText = "No records found!"
onRowSelection = "onMyRowSelection"
allRowsEditable = "TRUE"
selectedRowKeyTable = "<%= rkTab %>"
table = "<%= datatab %>"
selectedRowIndexTable = "<%= sRTable %>"
iterator = "<%= iterator %>"
visibleRowCount = "10" >
</htmlb:tableView>
</b>
I update an internal table Datatab with all the values I require.
Any idea why the cell binding id not working?
Many thanks in advance.
MikeHi Mike,
databinding is not possible with application classes. There are just a nice way to handle "session variables". You can use them with MVC as well.
Before MVC there was flow logic. Single formfield-values are receved e.g. when declared as page parameters. Values from tableViews are received e.g. in OnInputProcessing" by fetching the TV-Object from HTMLB_MANAGER and then calling methods like "GET_CELL_VALUE".
DATA: tv type ref to CL_HTMLB_TABLEVIEW,
table_event type ref to CL_HTMLB_EVENT_TABLEVIEW.
tv ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
name = 'tableView'
id = 'mytv1' ).
table_event = tv->data.
myValue = table_event->get_cell_value( row_index = 1 column_index = 1 ).
good luck,
stefan. -
Display line items in Cells of a table- Smartform
Hello All,
Can any one help me achieving the below requirement.
I have a requirement of printing invoice with a smartform. I am displaying line items from a TABLE node by looping VBRP's internal table. There are 12 cells and the 5 th cell contains a number of Dicount rates.
I am displaying these discount rates from LOOP node by looping KONV's internal table within that CELL. The 7 th Cell has got 2 values which are required to be: one aligned to the TOP right corner of the cell and the other to the bottom right side of the cell.
Now the issue description is:
CELL-5: Contains unknown number of values for display within the cell to be positioned as MIDDLE justified for an item(POSNR) of the main item table.
CELL-7: Contains two fixed values :KWERT to be at Top right of the CELL-7and NETWR at the bottom right of CELL-7
I have managed to display the sub items in CELL-5 in the middle by giving values to SPACE BEFORE/SPACE AFTER sections of PARAGRAPH FORMAT in SMART STYLE.
Requirement: Irrespective of number of sub items in CELL-5 the 2 values in CELL- 7 to be aligned as one at the top right and the other to the bottom right cell flexibly . Same applies to other items(POSNR) of MAIN VBRP item table.
The ROWS of the MAIN Table to be flexible enough to shrink the space when then are less number of subitems in CELL-5.
Values in Cell-7 should be adjusted according to contents in CELL-5.
Thanks in advance for your valuable suggestions.Hi,
Do one thing while filling the 5th cell , count the number of values(counter) in it for each record and fill new internal table (Itab_cell7) as follws.
DATA : FLAG,
counter1 type n.
DO COUNTER TIMES.
counter1 = counter1 + 1.
CLEAR FLAG.
IF counter = 1.
WA_CELL7-VALUE = KWERT.
APPEND WA_CELL7 TO ITAB_CELL7.
FLAG = 'X'.
ENDIF.
IF counter1 = (counter1 - 1).
WA_CELL7-VALUE = KWERT.
APPEND WA_CELL7 TO ITAB_CELL7.
FLAG = 'X'.
EXIT.
ENDIF.
IF FLAG NE 'X'.
WA_CELL7-VALUE = ''.
APPEND WA_CELL7 TO ITAB_CELL7.
ENDIF.
ENDDO.
Adjust the code if need as per your data.
In cell 7 under loop node print ITAB_CELL7 values in a text. and prepare a paragragh for alingment.
if it does not work for send me the XML file for your smartform.
Regards,
Antim -
Problem in displaying internal table contents to excel(color)
Hello Gurus!!!!!
The code is given below :-
*& Module pool ZDEMO_DOWNLD1
PROGRAM ZDEMO_DOWNLD1.
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
DATA : f_name(120) type c,
f_name1(120) type c.
case sy-ucomm.
when 'ATTACH'.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = ' '
DEF_PATH = ' '
MASK = ' '
MODE = ' '
TITLE = ' '
IMPORTING
FILENAME = f_name
RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5
*f_name = DEF_FILENAME.
f_name1 = f_name.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
type-pools ole2.
data: h_excel type ole2_object, " Excel object
h_mapl type ole2_object, " list of workbooks
h_map type ole2_object, " workbook
h_zl type ole2_object, " cell
h_f type ole2_object, " font
h_interior type ole2_object. " Color
*tables: spfli.
DATA: ls_emp TYPE zpm_emp_det,
lt_emp TYPE zpm_emp_det OCCURS 0,
l_projectname TYPE zpm_emp_item_det-project_name,
l_projectname_last TYPE zpm_emp_item_det-project_name,
l_empid TYPE zpm_emp_item_det-empid,
l_empid_last TYPE zpm_emp_item_det-empid.
DATA: l_projectname_key TYPE lvc_nkey,
l_role_of_emp_key TYPE lvc_nkey,
l_last_key TYPE lvc_nkey.
DATA : lt_project_main TYPE TABLE OF zsach_pm ,
ls_project_main TYPE zsach_pm,
lt_project TYPE zsach_pm OCCURS 0,
ls_project TYPE zsach_pm.
internal table for excel headings
DATA : BEGIN OF lt_project_ex OCCURS 0,
line(50) TYPE c,
END OF lt_project_ex.
DATA: lt_project1 TYPE zsach_pm OCCURS 0,
ls_project1 TYPE zsach_pm.
DATA : lt_project_temp TYPE zsach_pm OCCURS 0 ,
ls_project_temp TYPE zsach_pm.
DATA: lt_project2 TYPE zsach_pm OCCURS 0,
ls_project2 TYPE zsach_pm.
TYPES: BEGIN OF st_username,
username TYPE zuser_names-username,
END OF st_username.
DATA: it_tab TYPE TABLE OF st_username,
wa_tab TYPE st_username.
data : lt_project_excel like zsach_pm occurs 0 with header line.
*DATA: f_name TYPE string.
data h type i.
table of flights
data: it_spfli like spfli occurs 10 with header line.
*& Event START-OF-SELECTION
SELECT empid
project_name
role_of_emp
competancy
manager
price_category
rate_per_hour
first_day_pro
last_day_pro
ckey
FROM zpm_emp_item_det
INTO CORRESPONDING FIELDS OF TABLE lt_project.
LOOP AT lt_project INTO ls_project.
ENDLOOP.
SELECT projectid project_name client begin_date end_date
FROM zpm_project_det
INTO CORRESPONDING FIELDS OF TABLE lt_project_temp FOR ALL ENTRIES IN lt_project
WHERE project_name = lt_project-project_name.
LOOP AT lt_project_temp INTO ls_project_temp.
MODIFY lt_project FROM ls_project_temp TRANSPORTING
projectid project_name client begin_date end_date
WHERE project_name = ls_project_temp-project_name.
ENDLOOP.
SELECT empid
employee_name
designation
employee_type
date_of_joining
FROM zpm_emp_head_det
INTO CORRESPONDING FIELDS OF TABLE lt_project1 FOR ALL ENTRIES IN lt_project
WHERE empid = lt_project-empid.
LOOP AT lt_project1 INTO ls_project1.
MODIFY lt_project FROM ls_project1 TRANSPORTING
empid
employee_name
designation
employee_type
date_of_joining
WHERE empid = ls_project1-empid.
ENDLOOP.
tell user what is going on
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-007
exceptions
others = 1.
start Excel
create object h_excel 'EXCEL.APPLICATION'.
perform err_hdl.
set property of h_excel 'Visible' = 1.
perform err_hdl.
tell user what is going on
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-008
exceptions
others = 1.
get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
perform err_hdl.
add a new workbook
call method of h_mapl 'Add' = h_map.
perform err_hdl.
tell user what is going on
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-009
exceptions
others = 1.
output column headings to active Excel sheet
perform fill_cell using 1 1 1 'Project ID'(001).
perform fill_cell using 1 2 1 'Emp ID'(002).
perform fill_cell using 1 3 1 'Project Name'(003).
perform fill_cell using 1 4 1 'Client'(004).
perform fill_cell using 1 5 1 'Begin Date'(005).
perform fill_cell using 1 6 1 'End Date'(006).
perform fill_cell using 1 7 1 'Role of Employee'(007).
perform fill_cell using 1 8 1 'Module / Competancy'(008).
perform fill_cell using 1 9 1 'Employee name'(009).
perform fill_cell using 1 10 1 'Price Category'(010).
perform fill_cell using 1 11 1 'Rate P/H'(011).
perform fill_cell using 1 12 1 '1st day in project'(012).
perform fill_cell using 1 13 1 'Last day in project'(013).
perform fill_cell using 1 14 1 'Currency'(014).
perform fill_cell using 1 15 1 'Manager'(015).
perform fill_cell using 1 16 1 'Emp Type'(016).
perform fill_cell using 1 17 1 'Designation'(017).
perform fill_cell using 1 18 1 'Joining Date'(018).
perform fill_cell using 1 19 1 'Last Date'(019).
loop at lt_project into ls_project.
*lt_project_excel[] = lt_project[].
endloop.
copy flights to active EXCEL sheet
h = sy-tabix + 1.
*perform fill_cell1 using h 1 0 ls_project-PROJECTID.
*perform fill_cell1 using h 2 0 ls_project-EMPID.
*perform fill_cell1 using h 3 0 ls_project-PROJECT_NAME.
*perform fill_cell1 using h 4 0 ls_project-client.
*perform fill_cell1 using h 5 0 ls_project-BEGIN_DATE.
*perform fill_cell1 using h 6 0 ls_project-END_DATE.
*perform fill_cell1 using h 7 0 ls_project-ROLE_OF_EMP.
*perform fill_cell1 using h 8 0 ls_project-COMPETANCY.
*perform fill_cell1 using h 9 0 ls_project-EMPLOYEE_NAME.
*perform fill_cell1 using h 10 0 ls_project-PRICE_CATEGORY.
*perform fill_cell1 using h 11 0 ls_project-RATE_PER_HOUR.
*perform fill_cell1 using h 12 0 ls_project-FIRST_DAY_PRO.
*perform fill_cell1 using h 13 0 ls_project-LAST_DAY_PRO.
*perform fill_cell1 using h 14 0 ls_project-CKEY.
*perform fill_cell1 using h 15 0 ls_project-MANAGER.
*perform fill_cell1 using h 16 0 ls_project-EMPLOYEE_TYPE.
*perform fill_cell1 using h 17 0 ls_project-DESIGNATION.
*perform fill_cell1 using h 18 0 ls_project-DATE_OF_JOINING.
*perform fill_cell1 using h 19 0 ls_project-LAST_WORKING_DAT.
perform fill_cell1 using h 1 0 lt_project_excel-PROJECTID.
perform fill_cell1 using h 2 0 lt_project_excel-EMPID.
perform fill_cell1 using h 3 0 lt_project_excel-PROJECT_NAME.
perform fill_cell1 using h 4 0 lt_project_excel-client.
perform fill_cell1 using h 5 0 lt_project_excel-BEGIN_DATE.
perform fill_cell1 using h 6 0 lt_project_excel-END_DATE.
perform fill_cell1 using h 7 0 lt_project_excel-ROLE_OF_EMP.
perform fill_cell1 using h 8 0 lt_project_excel-COMPETANCY.
perform fill_cell1 using h 9 0 lt_project_excel-EMPLOYEE_NAME.
perform fill_cell1 using h 10 0 lt_project_excel-PRICE_CATEGORY.
perform fill_cell1 using h 11 0 lt_project_excel-RATE_PER_HOUR.
perform fill_cell1 using h 12 0 lt_project_excel-FIRST_DAY_PRO.
perform fill_cell1 using h 13 0 lt_project_excel-LAST_DAY_PRO.
perform fill_cell1 using h 14 0 lt_project_excel-CKEY.
perform fill_cell1 using h 15 0 lt_project_excel-MANAGER.
perform fill_cell1 using h 16 0 lt_project_excel-EMPLOYEE_TYPE.
perform fill_cell1 using h 17 0 lt_project_excel-DESIGNATION.
perform fill_cell1 using h 18 0 lt_project_excel-DATE_OF_JOINING.
perform fill_cell1 using h 19 0 lt_project_excel-LAST_WORKING_DAT.
*endloop.
disconnect from Excel
*CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA =
PUT_IN_OUTBOX = ' '
SENDER_ADDRESS = SY-UNAME
SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = ' '
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
SENDER_ID =
TABLES
PACKING_LIST =
OBJECT_HEADER =
CONTENTS_BIN =
CONTENTS_TXT =
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS =
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
free object h_excel.
perform err_hdl.
ENDMODULE. " STATUS_0100 OUTPUT
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
form fill_cell using i j bold val.
call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
perform err_hdl.
set property of h_zl 'Value' = val .
perform err_hdl.
get property of h_zl 'Font' = h_f.
perform err_hdl.
set property of h_f 'Bold' = bold .
perform err_hdl.
SET PROPERTY OF h_f 'ColorIndex' = 11 .
perform err_hdl.
endform.
*& Form fill_cell1
text
-->P_H text
-->P_1 text
-->P_0 text
-->P_IT_SPFLI_CARRID text
form fill_cell1 using i j bold val.
call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
perform err_hdl.
set property of h_zl 'Value' = val .
perform err_hdl.
get property of h_zl 'Font' = h_f.
perform err_hdl.
set property of h_f 'Bold' = bold .
perform err_hdl.
SET PROPERTY OF h_f 'ColorIndex' = 14 .
perform err_hdl.
endform. " fill_cell1
*& Form ERR_HDL
outputs OLE error if any *
--> p1 text
<-- p2 text
form err_hdl.
if sy-subrc <> 0.
write: / 'Error in OLE-Automation:'(010), sy-subrc.
stop.
endif.
endform. " ERR_HDL
Entire excel file is displayed ,but the problem is I want to display the excel file in one shot i.e not <b>line by line</b>
Kindly suggest if there is any keyword or FM to display the contents in excel using internal table.
It should not take much time. Just by executing code , the contents of internal table should be displayed.
Helpful answers will be rewarded
Thanks,
SachinHi Kavitha,
maybe it's not sophisticated enough for your requirement, but I found function XXL_FULL_API easy to use. This will give same functionality as 'download' button in ALV-Grid display.
Regards,
Christian
Maybe you are looking for
-
Hello, I am working with BI 7.0 and business object XI 3.1 and crystal report 2008. The integration kit has been installed. When I make a new report in crystal report from query and press print preview I have the following error : "Failed to retriev
-
Hello, Since we upgraded our system to BI7, we are not getting any data for the info cube 0BWTC_C02. We tried to change the settings in the "Maintenance of statistics properties" but still we are not getting the data. I've read here in the forum that
-
Oracle Grid Infrastructure 11g Release 2 (11.2.0.3.0)
Hi, I want to download Oracle Grid Infrastructure 11g Release 2 (11.2.0.3.0) for installation on Oracle Solaris 11 as Oracle Grid Infrastructure 11g Release 2 (11.2.0.1.0) cannot be installed on Solaris 11, I know its available but cannot find the li
-
Cover Flow View messed up with latest update
I was wondering if with the latest update anyone has had any problems with the cover flow view? It will not show anything when in that view (other 2 work fine). I have the apple software updater that updated to the latest version 7.1.1 and thats when
-
Hi, We have been using STMS for years now. It works 99% of the time but in some occasion it screws up and it always coincides with a period of the year that causes much damage!!!!! The symptom is that some transports seem to be out of sequence. But I