Subroutine that can accept different types of internal tables
Hey guys!
I'm creating a subroutine that takes input and sends it off to be converted but I am getting a syntax error: <tab> is not a STANDARD TABLE. I'm designating it with TYPE ANY TABLE, so I don't quite understand what is wrong.
Here is the relevant subroutine:
FORM conv_and_down USING name TYPE string tab TYPE ANY TABLE.
CONCATENATE cfd_name name INTO temp_str.
CLEAR tb_converted.
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = fid_char
TABLES
i_tab_sap_data = tab
CHANGING
i_tab_converted_data = tb_converted
EXCEPTIONS
CONVERSION_FAILED = 0
OTHERS = 0.
ENDFORM.
Any help is appreciated, as I am still fairly new to ABAP.
Edited by: gilthan3 on Feb 9, 2012 4:31 PM
Nevermind, I figured it out
Similar Messages
-
One Example program required on All types of internal tables
Hi All
Good Morning and Good day to you. I know that there are three types of internal tables like standard, sorted and hashed. I would request you to please send me one small example program on each type, so that i can understand better about the usage of different types.
Hoping for positive reply.
Thanks in advance.
Regards
Nagarajuhi,
data: begin of struct,
v_id type i,
v_name(10) type c,
v_phn type i,
end of struct.
"STANDARD TABLE.
data itab like standard table of struct with default key .
write 'standard table'.
struct-v_id = 1.
struct-v_name = 'subash'.
struct-v_phn = 234567.
"INSERT struct into ITAB.
append struct to itab.
struct-v_id = 3.
struct-v_name = 'sanchana'.
struct-v_phn = 2378499.
INSERT struct into ITAB index 1.
"append struct to itab.
struct-v_id = 2.
struct-v_name = 'sanchith'.
struct-v_phn = 2455667.
INSERT struct into ITAB index 2 .
loop at itab into struct.
write: / struct-v_id , struct-v_name,struct-v_phn.
endloop.
skip.
uline.
"sorted table.
data itab1 like sorted table of struct with non-unique key v_id.
write 'sorted table'.
struct-v_id = 3.
struct-v_name = 'subash'.
struct-v_phn = 234567.
INSERT struct into TABLE ITAB1.
"append struct to itab.
struct-v_id = 2.
struct-v_name = 'sanchana'.
struct-v_phn = 2378499.
INSERT struct into table ITAB1.
"append struct to itab.
struct-v_id = 1.
struct-v_name = 'sanchith'.
struct-v_phn = 2455667.
INSERT struct into ITAB1 index 1.
"append struct to itab.
loop at itab1 into struct.
write: / struct-v_id , struct-v_name, struct-v_phn.
endloop.
skip.
uline.
"hashed table
data itab2 like hashed table of struct with unique key v_id.
write 'hashed table'.
struct-v_id = 1.
struct-v_name = 'subash'.
struct-v_phn = 234567.
INSERT struct into TABLE ITAB2.
struct-v_id = 3.
struct-v_name = 'sanchana'.
struct-v_phn = 2378499.
INSERT struct into TABLE ITAB2.
struct-v_id = 2.
struct-v_name = 'sanchith'.
struct-v_phn = 2455667.
INSERT struct into TABLE ITAB2.
&--SORTED USING SORT STATEMENT--
loop at itab2 into struct.
write:'non-sorted table' , / struct-v_id , struct-v_name, struct-v_phn.
endloop.
sort itab2 by v_id.
SKIP.
loop at itab2 into struct.
write: 'sorted hash table', / struct-v_id , struct-v_name, struct-v_phn.
endloop.
SKIP.
ULINE.
<b>Reward Useful Points</b>
Siva -
How meny types of internal tables?
how meny types of internal tables? can any one explain brifly what r their use?
INTERNAL TABLES:
Internal tables are holds the data which is having the same structure and storing it in working memory in ABAP. The data is stored line by line in the memory. The main purpose of internal table is for storing and formatting data from a database table within a program. It is used to minimize the DB access time in report programs.
Internal table are dynamic data objects, since they can contain any number of lines of a particular type. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes.
Types of Internal Tables :
1. Standard Internal Tables :
Standard tables have an internal linear index. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries. WE can fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command).
2. Sorted tables :
Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. Entries are inserted according to the sort sequence defined through the table key.
3. Hashed tables :
Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. we cannot access a hashed table using its index. -
Types of internal tables with regard to EFFICIENCY
Will any one tell me syntax to define each type of internal table (standard, sorted , hashed , database) . how to compare their efficincy ( access time which is more effficent) is there any documantation or programme of such type exist then please tell . i want to declare each type of above table and also to compare them w.r.t to efficeny thanks want urgent reply
Hi,
There are 3 types of Internal tables.
Standard Internal Tables:
Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to the number of table entries.
Sorted Internal Tables:
Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
Hashed Internal Tables:
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
using internal tables that are similar to database tables.
http://help.sap.com/saphelp_470/helpdata/EN/fc/eb35de358411d1829f0000e829fbfe/frameset.htm
Regards,
Kiran Sure -
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 -
Hi I want to know the difference between the type of internal tables.
I know the types of internal table but i dont know the difference between them can any one explain me in simple sentence.
Hi,
<b>Standard Internal Tables</b>
Standard tables have a linear index. You can access them using either the index or the key. If you use the key, the response time is in linear relationship to the number of table entries. The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition.
This table type is particularly appropriate if you want to address individual table entries using the index. This is the quickest way to access table entries. To fill a standard table, append lines using the (APPEND) statement. You should read, modify and delete lines by referring to the index (INDEX option with the relevant ABAP command). The response time for accessing a standard table is in linear relation to the number of table entries. If you need to use key access, standard tables are appropriate if you can fill and process the table in separate steps. For example, you can fill a standard table by appending records and then sort it. If you then use key access with the binary search option (BINARY), the response time is in logarithmic relation to
the number of table entries.
<b>Sorted Internal Tables</b>
Sorted tables are always saved correctly sorted by key. They also have a linear key, and, like standard tables, you can access them using either the table index or the key. When you use the key, the response time is in logarithmic relationship to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique, or non-unique, and you must specify either UNIQUE or NON-UNIQUE in the table definition. Standard tables and sorted tables both belong to the generic group index tables.
This table type is particularly suitable if you want the table to be sorted while you are still adding entries to it. You fill the table using the (INSERT) statement, according to the sort sequence defined in the table key. Table entries that do not fit are recognised before they are inserted. The response time for access using the key is in logarithmic relation to the number of
table entries, since the system automatically uses a binary search. Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key.
<b>Hashed Internal Tables</b>
Hashes tables have no internal linear index. You can only access hashed tables by specifying the key. The response time is constant, regardless of the number of table entries, since the search uses a hash algorithm. The key of a hashed table must be unique, and you must specify UNIQUE in the table definition.
This table type is particularly suitable if you want mainly to use key access for table entries. You cannot access hashed tables using the index. When you use key access, the response time remains constant, regardless of the number of table entries. As with database tables, the key of a hashed table is always unique. Hashed tables are therefore a useful way of constructing and
using internal tables that are similar to database tables. -
Data types in internal tables.
Examples for LINE & KEY.
Mithun,
Internal Tables as Data Types
Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.
Line type
The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
Key
The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.
The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.
Pls. reward if useful -
Diference between DATA: and TYPES: on internal tables
Hi people,
Can somebody help me. I wanna know whats the diference between DATA: and TYPES: on internal tables
and whitch has the best performance, here is a eg:
DATA: BEGIN OF ti_sbook occurs 0,
carrid LIKE sbook-carrid,
fldate LIKE sbook-fldate,
customid LIKE sbook-customid,
loccuram LIKE sbook-loccuram,
END OF ti_sbook.
AND
TYPES: BEGIN OF ti_sbook ,
carrid LIKE sbook-carrid,
fldate LIKE sbook-fldate,
customid LIKE sbook-customid,
loccuram LIKE sbook-loccuram,
END OF ti_sbook.
DATA: gw_sbook TYPE TABLE OF ti_sbook,
gs_sbook TYPE ti_sbook.
witch of both types is better?
thanks.Hi Marcelo,
For compatibility matters is better to create internal tables with a work area separately. So yes it's better to use types. When you work with Object Oriented coding you will need to use internal tables defined with types. Also when defining tables with types is the new way of coding, the another coding is getting obsolete defined by SAP. That's why when working in ABAP with OO (Object Oriented) code you'll have to define tables with types and not the other way.
Hope it helps.
Regards,
Gilberto Li -
Can i send back an internal table by using Changing clause?
i'm using a Perform statement in SAP Script and i have written corresponding subroutine in an Zprogram.
In that subroutine i want to create one internal table and send back it to script.
can i send back an internal table by using Changing clause?
if it is possible, pls give me the idea................Hi,
While calling the formroutine,just u can pass the individual values using the ITCSY.In form,you are decalring the internal table with structure itcsy-input.
Then,you need to place the loop on the table and print in script.
But, passing the internal table in script,is not recomnded..
Regards,
Shiva Kumar -
What is the maximal line length of type any internal table
Dear all,
who can tell me what is the maximal line length of type any internal table.
Thanks!There is no limit to the record length of an internal table.
There is overall memory limit for every program (as setup by your basis). So, depending on the width of the ITAB, the number of records in ITAB is limited by the assigned memory. -
Types of internal tables - More explanation(urgent)
hi friends,
I wanted to explore diiferent types of internal table. when i went through the SAP.Help.Com for this , i wasnot able to get a clear idea of those 4 types of tables
Mainly i wanted to know
what is 1.standard table
2.Hashed Table
3.Sorted Table
4. Index tables..
what are the advantages of these table and please explain me a scenario for when under what circumstances we would use these?
please reply me soon as i need to submit my documents reagarding this.
Thanks in advance
Thanks&Regards
Prasanna.Standard tables
This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option with key access, the response time is logarithmically proportional to the number of table entries.
Sorted tables
This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
Hashed tables
This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data. -
Is there a preferred format of XML that can be laoded into an Oracle table?
XML files vary quite a bit. From mere fragments to file carrying schema, etc. What is the preferred format of an XML file that can be loaded into an Oracle table assuming that the Schema agrees with the table structure.
It does not seem to load an XML file even with W3C namespace and all.
Krishnaswamy JayaramWith XE there is XML support in the database but no XQuery, JNDI, or Servlet support.
If you give a specific example it could be helpful, here are simple write and read tests on XE;
HR on 20/03/2006 10:28:22 at XE > CREATE TABLE xml_tab (xmlval XMLTYPE);
Table created.
HR on 20/03/2006 10:28:31 at XE > INSERT INTO xml_tab VALUES (
2 XMLTYPE.CREATEXML(’
3
4 221
5 John
6 ‘));
1 row created.
HR on 20/03/2006 10:28:41 at XE > INSERT INTO xml_tab VALUES (
2 XMLTYPE.CREATEXML(’
3
4 331
5 PO_1
6 ‘));
1 row created.
HR on 20/03/2006 10:28:49 at XE > select x.xmlval.getstringval() from xml_tab x;
X.XMLVAL.GETSTRINGVAL()
221
John
331
PO_1 -
Maximum number of tables that can be outer joined with one table in a query
Hi All,
Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
Thanks,
Srinisrinu2 wrote:
Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
There is no limit to the number of tables you can outer join as long as you join them correctly.
SQL> with a as
2 (
3 select 1 id, 2 b_key, 3 c_key from dual union all
4 select 2 id, 1 b_key, 4 c_key from dual union all
5 select 3 id, 3 b_key, 1 c_key from dual union all
6 select 4 id, 4 b_key, 2 c_key from dual
7 ),
8 b as
9 (
10 select 1 id, 1 c_key2 from dual union all
11 select 2 id, 5 c_key2 from dual union all
12 select 3 id, 3 c_key2 from dual union all
13 select 4 id, 2 c_key2 from dual
14 ),
15 c as
16 (
17 select 1 key1, 1 key2, '1-1' dta from dual union all
18 select 1 key1, 2 key2, '1-2' dta from dual union all
19 select 1 key1, 3 key2, '1-3' dta from dual union all
20 select 1 key1, 4 key2, '1-4' dta from dual union all
21 select 2 key1, 1 key2, '2-1' dta from dual union all
22 select 2 key1, 2 key2, '2-2' dta from dual union all
23 select 2 key1, 3 key2, '2-3' dta from dual union all
24 select 2 key1, 4 key2, '2-4' dta from dual union all
25 select 3 key1, 1 key2, '3-1' dta from dual union all
26 select 3 key1, 2 key2, '3-2' dta from dual union all
27 select 3 key1, 3 key2, '3-3' dta from dual union all
28 select 3 key1, 4 key2, '3-4' dta from dual union all
29 select 4 key1, 1 key2, '4-1' dta from dual union all
30 select 4 key1, 2 key2, '4-2' dta from dual union all
31 select 4 key1, 3 key2, '4-3' dta from dual union all
32 select 4 key1, 4 key2, '4-4' dta from dual
33 )
34 select d.a_id, d.b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
35 from
36 c,
37 (
38 select
39 a.id as a_id, b.id as b_id, a.c_key, b.c_key2
40 from a, b
41 where a.b_key = b.id
42 ) d
43 where d.c_key = c.key1 (+)
44 and d.c_key2 = c.key2 (+);
A_ID B_ID C_KEY1 C_KEY3 DTA
3 3 1 3 1-3
4 4 2 2 2-2
2 1 4 1 4-1
1 2
SQL> -
With in the internal table can I READ the same internal table for a record?
With in the internal table can I READ the same internal table?
For Suppose
LOOP AT itab.
can I do as below
READ TABLE itab with key bukrs = itab-bukrs
belnr = itab-belnr.
*and I have to compare
IF itab-shkzg = itab-shkzg_ia.
ENDIF.
ENDLOOP.Hi,
Yes..But use work area to differentiate..
EX.
DATA: WA LIKE ITAB.
DATA: WA_READ LIKE ITAB.
LOOP AT itab <b>INTO WA</b>.
can I do as below
READ TABLE itab <b>INTO WA_READ</b>
with key bukrs = itab-bukrs
belnr = itab-belnr.
*and I have to compare
IF <b>WA</b>-shkzg = <b>WA_READ</b>-shkzg_ia.
ENDIF.
ENDLOOP.
Please reward for helpful answers.
Thanks,
Naren -
Assigning value to Field - Symbol ( which is type of internal table field )
Hi All,
I am facing problem to assign the value to a field symbol. My requirement is creating a dynamic internal table and populate values into that internal table, so that i can display the values .
I am having a structure with fields like status , Plant1 name , Plant2 name.....Plant n .
So i declared an internal table it_tab with this structure.
I am having one more table which having number of records for Plant1 ,Plant 2 ,....Plant n based on some condition.
I need to count the number of records for Plant1 and i need to put in the internal table it_tab.
For this i created field-symbol .
Here, t_deployment table will have the plants 1,2,3...and
t_devobject will have some records for these plants.
LOOP AT T_DEPLOYMENT.
clear w_count.
LOOP AT T_DEVOBJECT WHERE ZDEPLOYMENT = T_DEPLOYMENT-DOMVALUE_L AND
ZADSTATUS = '10'.
w_count = w_count + 1.
ENDLOOP.
concatenate 'it_tab-' t_deployment-domvalue_l into var_bet_name.
assign var_bet_name to <bet_var_name>.
now my internal table field i.e. it_tab-plant1 came into <bet_var_name> . But i want to assign a value for it.
at last what i need is it_tab-plant1 = w_count.
whaterver the w_count has value that needs to assign to it_tab-plant1. But i don't want to assign directly it it_tab-plant1. I want to assign dynamically. Because tommorrow some more plants added to t_deployments , i don't want to make changes to my program. It should take care....w/o changing the program.
I tried the following statement.
(<bet_var_name>) = w_count. But its not working.
Please let me know how i can get this.
Thanks in Advance.
Pavan.Hi pavan,
As ur requirement is creating a dynamic internal table,
try the following way,
remember the fieldcat should be of type LVC not SLIS.
BUILD LT_LVCFIELDCAT in a way that, the value from the internal table becomes the fieldname
ex:-
loop at it_models INTO WA_MODELS.
LS_LVCFIELDCAT-FIELDNAME = WA_models-MODEL.
LS_LVCFIELDCAT-SELTEXT = WA_models-MODEL.
append ls_lvcfieldcat to lt_lvcfieldcat.
endloop.
DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = LT_LVCFIELDCAT
IMPORTING
EP_TABLE = DREF.
ASSIGN dref->* TO <TEMP_TAB>.
now basing on the fieldcatalog <temp_tab> is build.
NOW FILL <TEMP_TAB>.
WHILE FILLING, ASSIGN COMPONENT IDX/NAME.....
this statement will be very usefull.
i hope this will be help full.
pls reward the points if it helps u.
regards
Hyma
Maybe you are looking for
-
My video is a finalist in a big contest! Please give me advice on winning!
Here is a link to my video I edited in FCP. It is the bottom row, third one in (white guy with black polo) and i was wondering what you guys think of it! Also, since you all have made video before, what techniques have you used to spread around a vid
-
Widget looping music that won't go away!
I was using my dashboard today, and clicked on the movie widget to see a movie trailer. Ever since the soundtrack has been looping and looping! I've taken everything off my dashboard, restarted my computer. I checked out the activity monitor and I
-
MB_DOCUMENT_BADI badi is not poping up the error message
hi friend, i m using the badi MB_DOCUMENT_BADI for MIGO transaction code to check batch condition for that i m using the method MB_DOCUMENT_BEFORE_UPDATE. in this method i have given the condition like if wa_XMSEG-charg <> wa_mseg-charg. messa
-
Copy contorl from F2 to credit memo Request
Hi All, I have a scenario where in when I create a credit memo request with reference to the original billing document , I want to copy only one condition type from F2 as far as pricing conditions are concerned without disturbing any
-
Hello, i have a problem with the needed library from SAP that should be in the OWB_HOME/owb/bin/admin folder. I am using OWB 10.1 on a linux machine, so i put the librfccm.so in this folder and set it to the LD_LIBRARY_PATH When i want to create a sa