Lines in an internal table?
How to get the number of lines in an internal table?
Hi
Check this
DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.
DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY col1
INITIAL SIZE 10.
DATA: lin TYPE i,
ini TYPE i,
knd(1) TYPE c.
DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.
WRITE: / lin, ini, knd.
DO 100 TIMES.
line-col1 = sy-index.
line-col2 = sy-index ** 2.
INSERT line INTO TABLE itab.
ENDDO.
DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.
WRITE: / lin, ini, knd.
Hope it clarifies.
Praveen
Similar Messages
-
Inserting a line in a internal table
Hello guys , I want to insert in the forst line of my internal table son titles in order to move the entire table to txt file , But I dont kno how I can put the titles in the first line, any suggestion ? DO I have to use a index?
Where are you writing the text file??
If you are using GUI_download, then you can pass the header text( in a different internal table) to the FM.
If you are using open dataset you can write the header first and then the internal table.
I dont think inserting text in the data table is a good idea. -
How can I search the last line in an internal table?
How can I search the last line in an internal table?
With a describe?? If it is , how can I do that?
Thanks!!Hi shilpa,
it seems to be you are NEW to SDN. welcome. if you want to get solutions to your Questions, you have to post a NEW thread.dont use the existing thread to post your question.
any way i am giving you the solution for your question
LOOP AT ITAB WHERE F1 = <SOME VALUE>
F2 = <SOME VALUE>.
ENDLOOP.
IF SY-SUBRC = 0.
ITAB WILL HAVE THE LAST RECORD which satisfying the given criteria in WHERE clause of LOOP.
write itab <--this ITAB will have the last record.
ENDIF.
regards,
Srikanth.
Message was edited by: Srikanth Kidambi -
To delete the last line of the internal table
How to delete the last line of the internal table.???????
The list which gets displayed from the internal table adds a dummy line at the last which shows zeros and zeros.all the otheer selections are perfect.i just want to delete the last line which comes as zero zero.is there any way to do it...Quite Easy......Use Describe command to Count the Total Number of Table Lines, and then Delete the Last Line using Index.
Data L like sy-tabix.
Describe Table Itab Lines L.
Delete itab index L. -
Difference between line type and internal table?
Hi..
I wanted to know, what is the difference between Line type and Internal Table?Hi,
Before the 4.7 release in SAP if we want to define an internal table we have to write the defination using the occurs statement and we need to define all the fields using INCLUDE STRUCTURE or indidually all the fields ine by one.
From 4.7 release of R/3 SAP introduced the Line type concept and it's part of the ABAP OOPS concept. for internal table defination we don't need to use the occur statements. Instead INCLUDE structure we need to create a Line type for that structure in Se11 and then we can define the internal table like :
DATA : ITAB TYPE TABLE OF <LINE_TYPE>.
Only thing is this table will be a table without header. So for internal table processing we need to define a work area structure of type line of line type . EX:
DATA: WA_ITAB TYPE LINE OF <LINE_TYPE>.
Hope this helps.
Thanks,
Greetson -
Modify a line in an internal table
Hi Friends,
I have an internal table . I need to set a flag in the internal table and modify only that line of the internal table .Please advise .
ex :
Loop at itab.
If sys-subrc <> 0 .
itab-flag = 'X' .
Modify ?
endloop.
Thanks,
Teresadata l_index type i.
Loop at itab.
l_index = sy-tabix
If sys-subrc <> 0 .
itab-flag = 'X' .
Modify itab INDEX l_index
endloop.
Regards,
Atish -
How to count no of line present in internal table depending on condtion.
Hi,
I want to count no of line present in one internal table.
For example: I have an internal table with output tax line item
lwa_gt_alv-ty_auste_ep consider this internal table having 100 lines
depending on the condition copany code(BUKRS), Year(GJAHR), and Document number(BELNR).
I want to count the number of line present for above mentioned condition in internal table lwa_gt_alv-ty_auste_ep.
Kindly help as soon as possible.
Thanks and best regards,
Niteesh RaiHello
So, count into exist loop/endloop:
data: counter type i.
loop at itab.
* do anything here ...
if BUKRS = " condition for bukrs here
and GJAHR = " condition for gjahr here
and BELNR = " condition for belnr here
counter = counter + 1.
endif.
* do anything here ...
endloop.
write counter.
Also you may to try other way:
data: counter type i.
data: itab1 like itab occurs 0.
itab1[] = itab[].
delete itab1 where BUKRS NE " condition for bukrs here
and GJAHR NE " condition for gjahr here
and BELNR NE " condition for belnr here
describe table itab1 lines counter.
write counter. -
Insert specific line in an internal table at a specific place
Hi
i have an internal table (itab) let's say
Name1 Name2 NUM1 NUM2 NUM3
Which already populater with data.
i have to do a subtotal for every NAME1 and insert a line just after the NAME1 in the internal table
and another subtotal by every NAME1 NAME2 and insert a line just after every NAME1 and NAME2 in the internal table
then another Grand total at the end of the table
My psudeo code is a bit like that but the insert is done in the wrong row
Index=1
LOOP at itab index
if itab-name1 NE old
insert structure in itab index
elseif itab-name1 NE old and itab-name2 NE old
insert structure in itab index
elseif itab EQ last line
insert structure in itab index
else
structure-num1 = structure-num1 + itab-num1
structure-num2 = structure-num2 + itab-num2
endif
index = index + 1
endloop
Do you think i need to use a temporary table here. can u guide me in code plz..sort internal table by name1 and name2. <b>Have name1 and name2 as the first two variables in the internal table</b>
declare a work area and an internal table with the same structure as internal table.
declare num1 as type itab-num1.
num2 and i_num2 type itab-num2.
sort itab by name1 and name2.
loop the internal itab1.
append itab1 to itab2.
wa-num1 = structure-num1 + itab-num1
wa-num2 = structure-num2 + itab-num2.
i_num2 = i_num2 + itab-num2.
num1 = num1 + itab-num1.
num2 = num2 + itab-num2.
at end of name2.
append wa to itab2.
clear wa_name2.
endat.
at end of name1.
wa-num2 = i_num2.
append wa to itab2.
clear: i_num2, wa.
endat.
at last.
wa-num1 = num1.
wa-num2 = num2.
append wa_itab2.
endat.
endloop.
Thanks. -
How to find number of lines in an internal table
Dear all,
how to find number of records present in an internal table.DESCRIBE TABLE
Syntax
DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].
Extras:
1. ... KIND knd
2. ... LINES lin
3. ... OCCURS n
Effect
This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.
In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.
Notes
For detailed information about an internal table, you should use the methods of RTTS of the DESCRIBE TABLE statement.
Without the specification of an addition, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
Addition 1
... KIND knd
Effect
The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.
Addition 2
... LINES lin
Effect
The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.
Note
As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.
Addition 3
... OCCURS n
Effect
The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.
Example
Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.
TYPE-POOLS sydes.
FORM sort_descending CHANGING itab TYPE ANY TABLE.
DATA tabkind(1) TYPE c.
DESCRIBE TABLE itab KIND tabkind.
IF tabkind = sydes_kind-standard OR
tabkind = sydes_kind-hashed.
SORT itab DESCENDING.
ELSEIF tabkind = sydes_kind-sorted.
MESSAGE '...' TYPE 'E'.
ELSE.
MESSAGE '...' TYPE 'E'.
ENDIF.
ENDFORM.
DESCRIBE FIELD INTO
Note
This statement is for internal use only.
It cannot be used in application programs.
Syntax
DESCRIBE FIELD dobj INTO td.
Effect
All characteristics of the field f, its components , sub-components etc. are displayed in the field td (type description). td has to be of the type SYDES_DESC, defined in Type Group SYDES. Because of this, the type group SYDES must be integrated into the ABAP-program with a TYPE-POOLS statement .
The structure SYDES_DESC has two table-type components TYPES and NAMES:
In TYPES, the tree structure of the type belonging to f is displayed. The components of a node are stored in the table TYPES in a continuous manner. Beginning and end of the line area that represents the components are stored in TYPES-FROM and TYPES-TO. The reference to the superior node can be found in TYPES-BACK. If no superior resp. subordinate node exists, then this is marked by the value 0 (For the relevance of further components, refer to the following sections).
The names of components, types etc. are not stored directly in TYPES. Instead, the components TYPES-IDX_... hold an index in the name table NAMES. The value 0 indicates that there is no reference to the name table.
NAMES contains the possibly fragmented names in the component NAMES-NAME. If a name continues in the following line, this is indicated by an asterisk ('*') in the component NAMES-CONTINUE.
The type description table (TYPES) not only stores information about the tree structure but also further information about the type of f resp. its components. This includes especially all information that can be determined using the usual additions to DESCRIBE FIELD. In detail, TYPES contains the following columns:
IDX_NAME
Component Name
IDX_USER_TYPE
Name of a user-defined type, i.e., a type that was defined through its TYPES-statement. Derived types (... TYPE A-B) and structures from the ABAP-Dictionary are not considered to be user-defined types.
CONTEXT
For user-defined types only: The context, in which the type is defined. Possible values are defined in the constant SYDES_CONTEXT of the type group SYDES. Please only use these constants to carry out a comparison. In detail, we distinguish between the following type contexts:
SYDES_CONTEXT-PROGRAM: Program-global type
SYDES_CONTEXT-FORM : FORM-local type
SYDES_CONTEXT-FUNCTION: FUNCTION-local type
SYDES_CONTEXT-METHOD : METHOD-local type
IDX_CONTEXT_NAME
For user-defined types only:
With a local context: The name of the FORM or FUNCTION, whose type was defined. The name of the associated program is then the first entry in the name table.
With a global context: The name of the program in which the type was defined.
IDX_EDIT_MASK
Conversion routine from the ABAP-Dictionary, is in accordance with the addition EDIT MASK at simple DESCRIBE.
IDX_HELP_ID
Help-Id when referencing to fields from the ABAP-Dictionary
LENGTH
Internal length, corresponds to the addition LENGTH at simple DESCRIBE
OUTPUT_LENGTH
Output length, corresponds to the addition OUTPUT-LENGTH at simple DESCRIBE
DECIMALS
Number of decimal digits, corresponds to the addition DECIMALS at simple DESCRIBE
TYPE
ABAP-Type, corresponds to the addition TYPE at simple DESCRIBE
TABLE_KIND
A table type is stored here for the components which represent an internal table. The same values are returned as with the variant DESCRIBE TABLE itab KIND k. Components which do not represent a table get the return value set to SYDES_KIND-UNDEFINED (see type group SYDES).
Example
Example definition of the complex data type EMPLOYEE_STRUC:
PROGRAM DESCTEST.
TYPES: BEGIN OF name_struc,
first TYPE c LENGTH 20,
last TYPE c LENGTH 20,
END OF name_struc,
BEGIN OF absence_time_struc,
day TYPE d,
from TYPE t,
to TYPE t,
END OF absence_time_struc,
phone_number TYPE n LENGTH 20,
BEGIN OF employee_struc,
id LIKE sbook-customid,
name TYPE name_struc,
BEGIN OF address,
street TYPE c LENGTH 30,
zipcode TYPE n LENGTH 4,
place TYPE c LENGTH 30,
END OF address,
salary_per_month TYPE p LENGTH 10 DECIMALS 3,
absent TYPE STANDARD TABLE OF absence_time_struc
WITH NON-UNIQUE DEFAULT KEY,
phone TYPE STANDARD TABLE OF phone_number
WITH NON-UNIQUE DEFAULT KEY,
END OF employee_struc.
You can determine the structure of the type EMPLOYEE_STRUC by collecting the type group SYDES as follows:
TYPE-POOLS: sydes.
DATA: employee TYPE employee_struc,
td TYPE sydes_desc.
DESCRIBE FIELD employee INTO td.
The following table shows a few selected columns of the type description table TD-TYPES. For a better overview, the names of the columns IDX_NAME, IDX_UERR_TYPE and IDX_EDIT_MASK have been shortened:
|FROM| TO |BACK|NAME|UTYP|EMSK|TYPE
|--||||||--
1 | 2 | 7 | 0 | 0 | 2 | 0 | v
2 | 0 | 0 | 1 | 6 | 0 | 4 | N
3 | 8 | 9 | 1 | 7 | 5 | 0 | u
4 | 10 | 12 | 1 | 8 | 0 | 0 | u
5 | 0 | 0 | 1 | 9 | 0 | 0 | P
6 | 13 | 13 | 1 | 11 | 0 | 0 | h
7 | 17 | 17 | 1 | 12 | 0 | 0 | h
8 | 0 | 0 | 3 | 13 | 0 | 0 | C
9 | 0 | 0 | 3 | 14 | 0 | 0 | C
10 | 0 | 0 | 4 | 15 | 0 | 0 | C
11 | 0 | 0 | 4 | 16 | 0 | 0 | N
12 | 0 | 0 | 4 | 17 | 0 | 0 | C
13 | 14 | 16 | 6 | 0 | 18 | 0 | u
14 | 0 | 0 | 13 | 20 | 0 | 0 | D
15 | 0 | 0 | 13 | 21 | 0 | 0 | T
16 | 0 | 0 | 13 | 22 | 0 | 0 | T
17 | 0 | 0 | 7 | 0 | 0 | 0 | N
Please note that the entries in rows 6 and 7 represent internal tables (ABAP-Type h). There is always an entry for the corresponding row type (rows 13 and 17) to an internal table.
The indices in the rows 5 to 7 refer to entries in the name table TD-NAMES. If you look, e.g., at row 3, you find the corresponding component name in TD-NAMES from row 7 (NAME) onward and the corresponding user type from row 5 (NAME_STRUC) onward.
In the name table TD-NAMES you find the following entries. Note that the names SALARY_PER_MONTH and ABSENCE_TIME_STRUC are stored in two parts:
|CONTINUE|NAME |CONTINUE|NAME
|--| -||--
1 | |DESCTEST 12 | |PHONE
2 | |EMPLOYEE_STRUC 13 | |FIRST
3 | |SBOOK-CUSTOMID 14 | |LAST
4 | |==ALPHA 15 | |STREET
5 | |NAME_STRUC 16 | |ZIPCODE
6 | |ID 17 | |PLACE
7 | |NAME 18 | * |ABSENCE_TIME_ST
8 | |ADDRESS 19 | |RUC
9 | * |SALARY_PER_MONT 20 | |DAY
10 | |H 21 | |FROM
11 | |ABSENT 22 | |TO -
All line items related internal table or structure in f-44 Transaction
Hi All,
In F-44 Transaction once i will give Vendor number then i press enter then all related documents will come. I need that related internal table before display of documents. I have to change some values in those documents. I found one internal table i.e. POSTAB. And I made changes. But is not effected and not helpful for my requirement.Please tell me exact internal table before those values come .
If there is any Enhancement Spot or User Exit of that related Line items Values.
Regards
NageswarDear Kavana,
In almost all situations the reason to your this issue can be found in
notes 136754 or 152813.
Mostly, the documents are included in a payment proposal and will
therefore not show up in F-44.
You can check which items are blocked by payment proposal in two
ways:
In table REGUP (Processed items from payment program), you can check
which items are blocked by payment proposals (display via SE16 or SE17,
selection on vendor (LIFNR), company code (ZBUKR) and document number
(BELNR).
I hope this can help You.
mauri -
Displaying multiples lines of an Internal table to Textedit.
Hi,
I have an internal table. I wish to display them in an TextEdit as multiple lines. ie, each record of an internal table (which has only one string element) should be displayed as an individual line inside the TextEdit. How do i achive that ? I tried concatenating seperated by '/', but not working. Please suggest.
Thanks,
Gaurav.Thomas is right, but supposedly (haven't tried myself yet) you could also bound the value property to a STRING_TABLE typed attribute (plain i.e. not structured string table).
If you follow the concatenation approach, the separator to be used is NEWLINE.
Here's the relevant help excerpt:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/06/45ee412e5e6324e10000000a1550b0/content.htm
value
Text to be displayed. The text can be edited.
The attribute to be bound can be of type STRING or STRING_TABLE. With STRING_TABLE rows from TextEdit are stored as table rows. A line break is always stored as a line feed in a STRING (CL_ABAP_CHAR_UTILITIES=>NEWLINE, ASCII decimal 10). The Web Dynpro framework carries out the conversion for the client platform.
Note that a string to be displayed in TextEdit, must only use a line feed as a line break.
Regards -
How to fetch the perticular line of a internal Table
Hi Friends,
I am using Function Module VC_I_GET_CONFIGURATION and I am passing the instance Number.
Now i am getting 18 records in my ITAB.Here from this ITAB i need only ATBEZ = RELAY TYPES & ATBEZ = CASE Records.Only for the mentioned conditions i require the records.
How Can i Proceed.Plz suggest.As CASE is the reserved word and Types also reserved Word.
Plz suggest.Hi,
Thanks for ur Reply and Can i Use Read statement for the same. My requirement is ATBEZ = 'RELAY TYPES' AND 'CASE'.
While Printing in smart form for one item there will be only one Relay type.How can i proceed.
If i write LOOP AT ITAB WHERE ATBEZ = 'RELAY TYPES' or ATBEZ = ' CASE'.
2 records r coming and only the secong recored is appending.First Record will not append.
How can i do.
Plz suggest. -
The ABAP program lines are wider than the internal table.
Hello;
i use FM REUSE_ALV_FIELDCATALOG_MERGE to fill in fieldcat from an internal table but i receive dump message READ_REPORT_LINE_TOO_LONG. Is there smt. like a type mismatch or waht can that be?
detail explanation of the dump is
The internal table "\FUNCTION=K_KKB_FIELDCAT_MERGE\DATA=L_ABAP_SOURCE[]" is 72 characters wide. The program line is
81 characters wide.
source of the call is like:
DATA: ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
ALV_HEADER TYPE SLIS_T_LISTHEADER WITH HEADER LINE,
ALV_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,
ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
ALV_PRINT TYPE SLIS_PRINT_ALV,
ALV_REPID LIKE SY-REPID, " program name
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = alv_repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = alv_repid
CHANGING
CT_FIELDCAT = alv_fieldcat[]
EXCEPTIONS
OTHERS = 3.
thx in advance
AliHi,
At least one line of the source text is longer than the lines of the internal table itab then,
READ_REPORT_LINE_TOO_LONG. error occurs.
Cause: At least one line of the source text is longer than the lines of the internal table itab.
Runtime Error: READ_REPORT_LINE_TOO_LONG
check the link below for further info
http://www.s001.org/ABAP-Hlp/abapread_report.htm
one more thing, whether u have given report name
ALV_REPID = 'ZXYZ'.
if ZXYZ is u r program name -
MODIFY ALL LINES IN INTERNAL TABLE
Hi,
How to modify more than one line in an internal table? I tried using update, failed as update is not for internal tables. Your help is appriciated .
thank you,
surya.To change one or more lines using a condition, use the following statement:
<b>MODIFY itab FROM wa TRANSPORTING f1 f2 ... WHERE cond.</b>
This processes all of the lines that meet the logical condition cond. The logical expression cond can consist of more than one comparison. In each comparison, the first operand must be a component of the line structure. If the table lines are not structured, the first operand can also be the expression TABLE_LINE. The comparison then applies to the entire line. If the line type of the internal table contains object reference variables as component comp or if the entire line type is a reference variable, the attributes of the attr object to which the respective line reference points can be specified as comparison values using comp->attr or table_line->attr.
The work area wa, which must be compatible with the line type of the internal table, contains the new contents, which in turn will be assigned to the relevant table line using the TRANSPORTING addition. Unlike the above MODIFYstatement, the TRANSPORTING addition is not optional here. Furthermore, you can only modify the key fields of the internal table if it is a standard table. If at least one line is changed, the system sets sy-subrc to 0, otherwise to 4.
REPORT demo_int_tables_modify .
DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.
DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY col1.
DO 4 TIMES.
line-col1 = sy-index.
line-col2 = sy-index ** 2.
INSERT line INTO TABLE itab.
ENDDO.
line-col1 = 2.
line-col2 = 100.
MODIFY TABLE itab FROM line.
LOOP AT itab INTO line.
WRITE: / line-col1, line-col2.
ENDLOOP.
The list output is:
1 1
2 100
3 9
4 16
The program fills a hashed table with a list of square numbers. The MODIFY statement changes the line of the table in which the key field col1 has the value 2.
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers -
Inserting blank line in internal table
Hi
I am inserting a report from a internal table for eg the content of my internal table is
data : abc
event initialization.
perform read_data.
Now I want 1 blank line after every line in the internal table for eg
data:abc
event initialization
perform read_data.
How to insert a blank line in an internal table?
Edited by: priya singh on Feb 4, 2009 9:37 AMhi,
DATA: BEGIN OF i_pernr OCCURS 1 ,
pernr TYPE pa0002-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
END OF i_pernr.
TYPES : BEGIN OF string1 ,
a TYPE char100,
END OF string1.
DATA : wa_string TYPE string1,
it_stirng TYPE TABLE OF string1.
START-OF-SELECTION.
SELECT pernr vorna nachn FROM pa0002 INTO TABLE i_pernr UP TO 20 ROWS.
LOOP AT i_pernr.
CONCATENATE i_pernr-pernr i_pernr-vorna i_pernr-nachn INTO wa_string-a SEPARATED BY '|'.
APPEND wa_string TO it_stirng.
APPEND INITIAL LINE TO it_stirng.
ENDLOOP.
BREAK-POINT.
Thanks
Maybe you are looking for
-
My Photoshop cs2 won't install
I used photoshop cs2 on my last computer, and now i've got a mac. But photoshop won't get installed. When I press finish it just fail every time. What should I do?
-
Is 2D Barcode possible in SAP SCRIPTS
Hi folks , Is 2D barcode possible in Sap scripts? Thnaks pabi
-
ORA-04091: table POSTAL_ADDRESS is mutating, trigger/function may not see it
First off, there are NO TRIGGERS defined on the table in question in our database. The process we need to accomplish is as follows: 1. Load addresses from the table. 2. Send the addresses through a standardization routine. 3. Multi-Insert any addr
-
RC Components Hosted Demo doesn't work
Hi, Question to Oracle people - why ADF Faces Rich Client Components Hosted Demo doesn't work ? Kuba
-
IPhone not sending copy and paste text messages
II'm have a problem sending messages. When I want to copy and paste a piece of text and send it as a message, it's not getting through. However when I send a short message to the same number that seems to work fine.