Appending empty rows in internal table
Hi,
i am using table control, where there is a condition, some row may left empty. end if i press enter button the empty row is filled by the next available record. My need is to pick the records in the table control to the internal table including the empty rows as it is.
Hi Karthikeyan,
By default with user pressinng enter, empty rows will get deleted.
How are you populating your table control? Is it from standard transaction or your internal table?
If it is from your internal table, you can add anothe flag field for empty row.
Whenever row is empty in your internal table, mark flag field as 'X', so in the table control you these entries will not get vanished with pressing of enter.
This is one idea and you can build on this. You can make this flag column as non editable so that no one can change these.
hope this helps,
ags.
Similar Messages
-
Excel attachment contains only 1st row of Internal Table.
Hello,
I have designed a Vendor Ledger report and want to send the same as an excel attachment. I have made use of function module SO_NEW_DOCUMENT_ATT_SEND_API1 wherein I pass the parameters.
The program works perfectly fine as I am receiving email along with the excel attachment. Also, the excel attachment opens without any errors. Also, the alignment of columns and data is perfect.
But the problem is if my internal table is having 10 rows, I get only the first row of the internal table in the excel sheet.
I also put a break point just before calling the function module to send email, I could see that the internal table which contains the attachment is having all 10 rows.
I really don't know what's going wrong in this.
Request you to please help.
Regards,
Danish.Hi,
Hi this is my code. Also, one thing I found that if i remove the Report Name i.e. "Vendor Ledger" , I get more than 1 row in my excel sheet. I feel there is some problem with the document size attributes.
* Header for exception report
CONCATENATE 'CC' 'Vendor' 'Stat' 'Name' 'Doc.No' 'FY' 'DDate' 'PDate'
'AssNo.' 'Doc.Tp' 'G/L' 'LAmt' 'LCurr' 'DAmt'
'D/C' 'Cl.Doc' 'TaxCd' 'TaxAmt'
INTO it_attachment SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO it_attachment.
APPEND it_attachment.
* Split Internal table data using horizontal tab.
CLEAR it_main.
LOOP AT it_main.
CLEAR: lc_amt, dc_amt, tax_amt.
lc_amt = it_main-lc_amount.
dc_amt = it_main-amt_doccur.
tax_amt = it_main-w_tax_base.
CONCATENATE it_main-comp_code
it_main-vendor
it_main-status
it_main-name1
it_main-doc_no
it_main-fisc_year
it_main-doc_date
it_main-pstng_date
it_main-alloc_nmbr
it_main-doc_type
it_main-sp_gl_ind
lc_amt
it_main-loc_currcy
dc_amt
it_main-db_cr_ind
it_main-clr_doc_no
it_main-w_tax_code
tax_amt
INTO it_attachment SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO it_attachment.
APPEND it_attachment.
ENDLOOP.
* Create Mail Body and Attachment.
psubject = 'Vendor Ledger'.
lv_message = 'Dear Sir/Madam,'.
APPEND lv_message TO it_message.
lv_message = ' '.
APPEND lv_message TO it_message.
lv_message = 'Attachment contain Vendor Ledger for Testing.'.
APPEND lv_message TO it_message.
lv_message = ' '.
APPEND lv_message TO it_message.
lv_message = ' '.
APPEND lv_message TO it_message.
lv_message = 'This is a System Generated Mail. Please do not reply.'.
APPEND lv_message TO it_message.
**Perform for populating mail characteristic info
CLEAR gd_doc_data.
* Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
READ TABLE it_attachment INDEX w_cnt.
gd_doc_data-doc_size = 1.
gd_doc_data-obj_name = 'Danish'. "'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
* Describe the body of the message
CLEAR it_packing_list.
REFRESH it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES it_packing_list-body_num.
it_packing_list-doc_size = it_packing_list-body_num * 255.
it_packing_list-doc_type = 'RAW'.
APPEND it_packing_list.
**Describe the attachment info
CLEAR it_packing_list.
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_attachment LINES it_packing_list-body_num.
it_packing_list-doc_type = 'XLS'.
it_packing_list-obj_name = 'File'.
it_packing_list-obj_descr = 'File'.
it_packing_list-doc_size = it_packing_list-body_num * 255.
APPEND it_packing_list.
REFRESH it_receivers.
CLEAR it_receivers.
it_receivers-receiver = 'Email Address'.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
APPEND it_receivers.
**Function Module to send mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_packing_list
contents_bin = it_attachment
contents_txt = it_message
receivers = it_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.
Regards,
Danish. -
Determine Number of rows in Internal Table
Hi,
I have defined my internal table as follows:
TYPES : BEGIN OF ABC_KEY,
FIELD1(2) TYPE C,
FIELD2(1) TYPE C,
FIELD3(8) TYPE N,
END OF ABC_KEY.
DATA: itab1 TYPE TABLE OF ABC_KEY
WITH KEY FIELD1,
wa_lines_1 LIKE LINE OF itab1.
How can I retrieve the number of rows in Internal Table?
Thanks.
Regards,
bw_newbieYou can define the number of rows of the internal table using the DESCRIBE itab command .
As the rest have already stated a sample code snippet .
For more info type in DESCRIBE in your prgram and click on (F1) by placing the cursor on DESCRIBE .
You will find more options as to how you can use the DESCRIBE command according to your requirement .
Thanks ,
Hari -
Count of non-empty rows of a table
How to I get the number of non-empty rows of a table ?
ThanksYou can loops through the rows and check whether any cell is empty or not? Use a counter variable to increment the same.
Thanks,
Bibhu -
How to append new rows in a table with Javascript ?
Hi ,
I'd like to append new rows in a table dynamically using javascript?
Do some of you have already done this before ?Rui's answer will create copies of the entire table. There may be times where thsi is what you want, but you asked about creating new rows. If your new row is a copy of one of your existing rows, then you could use
_RowName.addInstance(1);
(the underscore at the beginning invokes the instance manager). Is this what you're looking for? -
How to append row in internal table for perticular condition
Hi,
I have 4 records in my internal table and i want to append row
after second row when condition will match.
please guide me.
thanks in advancs
regards
SNDhi,
using key word INDEX u can insert a record in aspecified position as
if internal table is with header line.
INSERT <internaltable> index SY_INDEX [or index no if u know where to insert]
with out header line.
INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u know where to insert]
if condition is true.
insert itab index 2.
endif.
if helpful reward some points.
with regards,
Suresh.A -
Append screen inserted row to internal table
Hi Experts,
I have created a program using table control. But after filling a row when i press enter the entire row getting blank.
So i need to append the last inserted row from table control to internal table so that when i press enter that row remains on screen.
Thanks & Regards
Ashutosh KataraHi,
try this code in PAI,
IF sy-ucomm = 'ENTER'.
if tabc-col1 is NOT INITIAL and
tabc-col2 is NOT INITIAL and
tabc-col3 is NOT INITIAL and
tabc-col4 is NOT INITIAL.
w_tab-field1 = tabc-col1.
w_tab-field2 = tabc-col2.
w_tab-field3 = tabc-col3.
w_tab-field3 = tabc-col4.
modify <itab> FROM <workarea> INDEX sy-tabix.
ENDIF.
ENDIF -
How to convert rows of internal table to columns of another internal table?
Hi,
Experts,
test_data.xls:
one two three four five
one two three four
one two three
one two
one
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = 'c:/test_data.xls'
I_BEGIN_COL = '1'
I_BEGIN_ROW = '1'
I_END_COL = '10'
I_END_ROW = '10'
TABLES
INTERN = it_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
output:
0001 0001 one
0001 0002 two
0001 0003 three
0001 0004 four
0001 0005 five
0002 0001 one
0002 0002 two
0002 0003 three
0002 0004 four
0003 0001 one
0003 0002 two
0003 0003 three
0004 0001 one
0004 0002 two
0005 0001 one
but i want this format:
one two three four five
one two three four
one two three
one two
one
i don't want this type of output display i want to display in ABAP report as in file format how can i achieve this post some ideas on it.
Thank U,
Shabeer ahmed.Hi,
Use this piece of code :
parameters: p_flname type rlgrap-filename.
data:
li_filecontent type standard table of alsmex_tabline ,
lwa_filecontent type alsmex_tabline ,
lv_begin_col type i value 1,
lv_begin_row type i value 1,
lv_end_col type i value 17,
lv_end_row type i value 65000,
li_fieldlist type lvc_t_fcat,
li_data type ref to data,
dy_line type ref to data.
field-symbols:<dyntable> type standard table,
<fs_data> type ref to data,
<fs_1>,
<dyn_wa>,
<dyn_field>.
*Transfer excel file contents to internal table
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_flname
i_begin_col = lv_begin_col
i_begin_row = lv_begin_row
i_end_col = lv_end_col
i_end_row = lv_end_row
tables
intern = li_filecontent
exceptions
inconsistent_parameters = 1
upload_ole = 2
error_message = 3
others = 4.
if sy-subrc = 0.
*Creating the list of fields in the table
perform f_create_tab_field tables li_fieldlist using 'BUKRS' 4 .
perform f_create_tab_field tables li_fieldlist using 'ZPOC_KUNNR' 10 .
perform f_create_tab_field tables li_fieldlist using 'RANL' 13.
perform f_create_tab_field tables li_fieldlist using 'ZPEDAT' 10 .
perform f_create_tab_field tables li_fieldlist using 'KWERT' 15 .
perform f_create_tab_field tables li_fieldlist using 'BONUS' 2 .
perform f_create_tab_field tables li_fieldlist using 'WAERS' 5 .
perform f_create_tab_field tables li_fieldlist using 'ZVAL' 15 .
perform f_create_tab_field tables li_fieldlist using 'ZQTY' 15 .
perform f_create_tab_field tables li_fieldlist using 'KMEIN' 3 .
assign li_data to <fs_data>.
*CREATING INTERNAL TABLE TO store data
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = li_fieldlist
importing
ep_table = <fs_data>
exceptions
generate_subpool_dir_full = 1
others = 2.
if sy-subrc = 0.
assign <fs_data>->* to <fs_1>.
assign <fs_1> to <dyntable>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyntable>. " creating a line type of the table just created above
assign dy_line->* to <dyn_wa>. " creating the work area with reference to the line type
loop at li_filecontent into lwa_filecontent.
assign component lwa_filecontent-col "accessing corresponding field in the field catalog
of structure <dyn_wa> to <dyn_field>. "and assigning this field to a field symbol
if sy-subrc = 0.
<dyn_field> = lwa_filecontent-value. " filling value for this field
endif.
at end of row.
append <dyn_wa> to <dyntable>.
clear <dyn_wa>.
endat.
clear lwa_filecontent.
endloop.
i_input_file[] = <dyntable>.
endif.
elseif sy-subrc <> 0.
message s027 display like c_error with text-001.
stop.
endif.
form f_create_tab_field tables p_li_fieldlist structure lvc_s_fcat
using p_fname
p_lenght.
data:lwa_fieldlist type lvc_s_fcat.
lwa_fieldlist-fieldname = p_fname.
lwa_fieldlist-intlen = p_lenght.
append lwa_fieldlist to p_li_fieldlist.
clear lwa_fieldlist.
endform. " F_CREATE_TAB_FIELD
Regards,
Dev. -
Grouping of two rows of internal table
Hi all,
I am having a requirement in which I want to group two rows of an internal table and assign a pointer to the two rows.
This pointer variable will then be passed to ALV.
Help reqd.
regards.Hi Gaurav,
Hope the below code helps:
TYPES :BEGIN OF TY_ITAB2,
DATA(400),
END OF TY_ITAB2.
DATA: ITAB3 TYPE TY_ITAB2 OCCURS 0 WITH HEADER LINE
Loop at itab1.
ITAB3-DATA = ITAB1-LABEL.
APPEND ITAB3.
ITAB3-DATA = ITAB1-MATNR.
APPEND ITAB3.
endloop.
or
You can create a deep internal table. You can declare one Column as an internal table and store the NOTES in that Internal table for each row.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
you can check the example in the link
Kindly Reward Points If You Find The Reply Helpful.
Cheers,
Chaitanya. -
Append 3 workarea into internal table
Hi,
I have 3 workarea and i want to append into one internal table.so how to append.
Thanks,
DeesanthHIII
then you need to use MODIFY statement like below code..
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
wa_output-lgort = wa_mard-lgort.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0
here you need to use READ statement to get workarea data from different tables and use MODIFY statement to append that data in the same row.
reagrds
twinkal -
How to add a row in internal table at first row
Hi All,
I need to add a row in an internal table which already has some contents.I want to add this row in the first row.
Please advice.
Thanks in advance.You mean - you want to replace the 1st record in the internal table. or you want to sum the new values to the existed record.
If you want to replace - then you can use as
read table itab index 1.
if sy-subrc = 0.
itab-f1 = 'new value'.
modify itab index sy-tabix.
endif.
Regards,
Satya -
How to add a group of rows in internal table
Hi champs,
I have some requirement.
I have one internal table which contain 4 columns .out of which 3 has some numeric value and first has some letters e.g A ,B,C etc.
Now suppose i have 20 rows in itab in which 10 are A 5 are B and 5 are C .Now as column 3 has numeric values i need to get the total of column 3 for all A ,B and C .
How to solve this problem.Please guid me.
thanks in advance
JhonHi,
Check the following code:
DATA: BEGIN OF LINE,
COL1 TYPE C,
COL2 TYPE I,
COL3 TYPE I,
END OF LINE.
DATA ITAB LIKE HASHED TABLE OF LINE
WITH UNIQUE KEY COL1 COL2.
LINE-COL1 = 'A'.
DO 3 TIMES.
LINE-COL2 = SY-INDEX.
LINE-COL3 = SY-INDEX ** 2.
INSERT LINE INTO TABLE ITAB.
ENDDO.
LINE-COL1 = 'B'.
DO 3 TIMES.
LINE-COL2 = 2 * SY-INDEX.
LINE-COL3 = ( 2 * SY-INDEX ) ** 2.
INSERT LINE INTO TABLE ITAB.
ENDDO.
SORT ITAB.
LOOP AT ITAB INTO LINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
AT END OF COL1.
SUM.
ULINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
SKIP.
ENDAT.
AT LAST.
SUM.
ULINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
ENDAT.
ENDLOOP.
Regards,
Bhaskar -
Grouping of rows of internal table.
Hi all,
I am having a requirement in which I want to group two rows of an internal table and assign a pointer to the two rows.
This pointer variable will then be passed to ALV.
Help reqd.
regards.hi,
AT - itab:
push F1 to look at the documentation for grouping
then assign the value to a field-symbol. -
Get Multiple Rows into internal Table using Webdynpro Alv Display ..
Hi guys ,
I need to find out the logic for getting all the selected rows into the internal table.
When i display the ALV Output on webdypro screen .
USer Selects multiple rows for further processing ..
Ineed to get all the rows selected by user into an internal table .
Please let me know how to achive this ...
Thanks in advance for quick reply
Regards
Saurabh GoelHi,
You need to use the method GET_SELECTED of IF_WD_CONTEXT_NODE to get the rows selected. Also ccheck for the paramters of that method, this retruns the element set.
This meets your requirement.
Regards,
Lekha. -
DELETED rows from internal table
Hi Experts,
If I delete row/s from an internal table
using the command DELETE ADJACENT DUPLICATES,
is there a way to get these deleted rows.
Thanks in advance.
RoseHi roselie,
1. ofcourse not.
2.hence, before that,
u can declare another internal table,
similar to original,
and use like this.
3. ITAB1[] = ORIGINALITAB[].
regards,
amit m.
Maybe you are looking for
-
Referencing templates with Parameters
Hi All, I need to access templates based on the language type. For example, If I have the parameter selected as Japanese then I need to select the template which is a template in Japanese. Is there any way that we have a parameter list with all the l
-
Hi experts, In one of my clients, the Price from the Last P.O for all combination of Vendor/Material/Plant is not picking up. This has happened 15 days ago. I couldnt find any changes. I checked the InfoRecord, the info update tick in PO, the User pr
-
Decoupling of customer infotypes; additional update mechanism
Hi I am currently working in a project, were we are trying to decouple a number of own / customer infotypes (9xxx-infotypes), according to SAP's New Infotype Framework. In this connection we want to use the recommendations by SAP, stated in the paper
-
Can I restrict a restricted key figure on another Key Figure ?
Hi Experts, I tried to acheive this but was not able to do it. Can I restrict a restricted key figure on another Key Figure ? I have a restricted key figure named " No of Orders Completed" and I have a key figure " No of Repair Days". I want to only
-
i was installing windows 8 on mac by boot camp and after i put the windows code and choose the partition i formatted the boot camp sector it said windows can not install on this sector because it is gpt