Working with table type any with mapping according to keys
Hi All ,
I have table type any with data and I need to fill structure type any according to respective key and verify that the field is have mapping .
i.e. I have a table <lt_itab> and I need to find the specific entry on it according to the key and the mapping .
I guess that the best way is to give example.
<lt_itab> - Is type any and can have lot of entries
lt_key - Is specified table with field_name and value
lt_map - Table with field_name which have mapping (have unique field name in every entry of the table )from f1..fn -
I need to fill fields in <ls_output> just if they appear in lt_map
<ls_output> - Is structure type any that in the end should have all the data from <ls_itab> according to the mapping and the keys of the table
<lt_itab> - table
f1 f2 f3 f4 f5 f6
1 2 3 4 5 6
5 5 4 3 8 4
6 9 2 5 3 5
1 3 3 4 2 1
lt_key - table
field_name value
f1 1
f2 3
lt_map - table
field_name
f1
f2
f5
f6
<ls_output> - structure
field value
f1 - 1
f2 - 2
f3 "Not in mapping so it's empty
f4 "Not in mapping so it's empty
f5 - 2
f6 - 1
<ls_output> have the field values of the last entry of <lt_itab> according to the key of f1 and f2 and according to the mapping f3 and f4 are empty
since they are not appaer in lt_map
Regards
Joy
Hi
You have to loop fully your main table in order to get the records in according to they keys:
LOOP AT <LT_ITAB> ASSIGNING <WT_ITAB>.
L_KO = SPACE.
LOOP AT LT_KEY.
ASSIGN COMPONENT LT_KEY-FIELDNAME OF STRUCTURE <WT_ITAB> TO <FS_KEY>.
IF <FS_KEY> NE LT_KEY-VALUE.
L_KO = 'X'.
EXIT.
ENDIF.
ENDLOOP.
CHECK L_KO IS INITIAL.
LOOP AT LT_MAP.
ASSIGN COMPONENT LT_MAP-FIELDNAME OF STRUCTURE <WT_ITAB> TO <FS_FROM>.
ASSIGN COMPONENT LT_MAP-FIELDNAME OF STRUCTURE <WT_OUTPUT> TO <FS_TO>.
<FS_TO> = <FS_FROM>.
ENDLOOP.
APPEND <WT_OUTPUT> TO <LT_OUTPUT>.
ENDLOOP.
Max
Similar Messages
-
Dont work 'REUSE_ALV_FIELDCATALOG_MERGE' with table type
Hi Experts ;
My problem about 'REUSE_ALV_FIELDCATALOG_MERGE' .
I use intarnal table with Table Type ( with header line ). And 'REUSE_ALV_FIELDCATALOG_MERGE' is not working . Field catalog is employ. I dont use 'REUSE_ALV_FIELDCATALOG_MERGE' have any problem.'REUSE_ALV_FIELDCATALOG_MERGE' expects a flat structure.
Give the reference of the line type of the table type if you wish to have fieldcatalog as per that..
Even if you dont use 'REUSE_ALV_FIELDCATALOG_MERGE' you can create your own Fieldcatalog.. -
Hi,
is it possible to give an FM a table with the type ANY? The table type is dynamic.
Regards,
SinanTABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as internal standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to such a formal parameter, an empty header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. In the case of formal parameters defined with TABLES, no value transmission is possible.
Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created in the function module for the internal table using the addition LIKE LINE OF itab of the DATA statement in the function module.
So you cant use the Tables type any option.....
Message was edited by:
Muthurajan Ramkumar -
Can EJB 3.0 beans be used with tables that do not have a primary key?
Can a EJB 3.0 persistence bean be used with tables that do not have a primary key defined? I am building a test application based on the HowTo - Building EJB 3.0 Faces App paper posted after Openworld (schalk). The issue I am running into when trying to run the application is: Exception Description: Entity class [class com.persistence.Rpthead] has no primary key specified. Note: I get a simular error when using toplink directly.
The tables I am binding to do not have primary keys defined. They use unique constraints to manage the table integrity.
Is it possible to use EJB 3.0 on tables without a primary key? If not, are there plans to support this in the future?The spec requires a primary key Id annotation. I will take your suggestion to EJB 3.0 expert group.
Can you also send an email to [email protected] with your requirement?
-Debu -
Hello,
i have table type any and i want to know in the loop for every field which type he have ,for instance for field type Date8.
what i the best way to do so , i guess that I need to use for instance cl_abap_elemdescr=>get_data_type_kind( <lv_field> ) but i dont know
how to use it and check every field in the loop ...
E.g.
loop at <lt_fields> assigning <ls_fields>
* check for every field in <ls_fields> which type he have and if the field is type date8
* handle it diffrently
endloop.
Regards
JoyYou can use Absolute Name to get the absolute type from the type descriptor.
DATA: lt_vbak TYPE STANDARD TABLE OF vbak.
DATA: lo_struct TYPE REF TO cl_abap_structdescr,
lt_comp TYPE cl_abap_structdescr=>component_table,
la_comp LIKE LINE OF lt_comp.
lo_struct ?= cl_abap_typedescr=>describe_by_name( 'VBAK' ).
lt_comp = lo_struct->get_components( ).
WRITE: /(30) 'Field' , (40) 'Absolute Type'.
DATA: lv_abs_name TYPE string.
LOOP AT lt_comp INTO la_comp.
WRITE: /(30) la_comp-name, (40) la_comp-type->absolute_name.
ENDLOOP.
Regards,
Naimesh Patel -
Loop at table with unspecified type but with where-condition
Hi,
Doing a loop over an internal table with unspecified type and in addition using a condtion may be done as follows: Thereby the
condition would be "... WHERE parentid EQ i_nodeid" if the type of <it_htab> would be static. However dynamic specification of a component through bracketed character-type data objects is not possible.
FIELD-SYMBOLS: <it_htab> TYPE STANDARD TABLE,
<wa_htab> TYPE ANY,
<parentid> TYPE rsparent.
ASSIGN me->ref_htab->* TO <it_htab>.
LOOP AT <it_htab> ASSIGNING <wa_htab>.
ASSIGN COMPONENT 'PARENTID' OF STRUCTURE <wa_htab> TO <parentid>.
CHECK <parentid> EQ i_nodeid.
ENDLOOP.
Since you have to loop over the whole table and to check within the loop whether the condition is fullfilled, this is rather bad for performance.
Questions: Are there any tricks to do this better?
Best Regards and Thank you,
Ingo>
Lalit Mohan Gupta wrote:
> you can put the condition in the where clause....
only if you have the upcoming 7.0 EhP2 (Kernel 7.02 or 7.20) the following dynamic where works:
DATA cond_syntax TYPE string.
cond_syntax = `parentid = i_nodeid`.
LOOP AT <it_htab> ASSIGNING <wa_htab>
WHERE (cond_syntax).
in older releases you would have to use program generation to achieve a dynamic where... .
Kind regards,
Hermann -
Calling Stored Procedure with table type as In parameter from Java
Hi Everyone,
Can anyone help me with the sample code to call a stored procedure having input parameter of Table type (consisting of multiple fields) from Java. This job is currently being done by a BPEL process.
We want to implement the same using Java.
Any sample code will be really helpful.
Thanks & Regards,
VikasTo start using a blob you have to insert it into the database and then get it back. Sounds weird but that is how it is. Here is a very simple program to do this:
#include<occi.h>
#include <iostream>
using namespace oracle::occi;
using namespace std;
int main()
try
Environment *env = Environment::createEnvironment(Environment::OBJECT);
Connection *conn = env->createConnection("hr","hr","");
string stmt1 = "insert into blob_tab values (:1) ";
string stmt2 = "select col1 from blob_tab";
Blob blob(conn);
blob.setEmpty(conn);
Statement *stmtObj = conn->createStatement(stmt1);
stmtObj->setBlob(1,blob);
stmtObj->executeUpdate();
conn->commit();
Blob blob1(conn);
Statement *stmtObj2 = conn->createStatement(stmt2);
ResultSet *rs = stmtObj2->executeQuery();
while(rs->next())
blob1 = rs->getBlob(1);
string stmt3 = "begin my_proc(:1) ;end;";
Statement *stmtObj3 = conn->createStatement(stmt3);
stmtObj3->setBlob(1,blob1);
stmtObj3->executeUpdate();
catch (SQLException e)
cout << e.getMessage();
/* The tables and procedure are primitive but ok for demo
create table blob_tab(col1 blob);
create or replace procedure my_proc(arg in blob)
as
begin
-- just a putline here. you can do other more meaningful operations with the blob here
dbms_output.put_line('hello');
end;
}Hope this helps.
Thanks,
Sumit -
Hi all!
I'm using a a structure (created in se11) that contains a field that is a table types.
I use this structure in a Function Module as exportation parameter. I have no problem filling this parameter in the Function Module but I have some problems when i call this function module in other abap report.
How I can read the data stored in the "subtables" of the exported parameter??
I tryed with a "LOOP AT parameter-subtable" but there's the problem that the "subtable" has no headerline.
Someone can help me please?
thanks in advance!
RHi,
Say you have created the table type(TT) as 'ZTABLETYPE' then at the report where you call the FM with TT declare a table as
data : itab type ztabletype.
itab = parameter-subtable.
loop at itab.
endloop.
now you would have the values in itab. Hope this solves your problem.
Regards,
Bharathy. -
ALV Grid with table type structure
I created a structure with a table type in it. I want to display an ALV Grid report with that structure. Is it even possible. If yes, can someone please provide some reference. Thanks.
Edited by: Sreekanth Nadella on Sep 4, 2010 2:29 AMHi Clemens,
The output should like a normal ALV Grid report. Just like a deep structure, one of the cell will have multiple row/value just like table. So you are looking at something like this.
A B C 1 2 3 D E
4 5 6
7 8 9
F G H 1 2 3 I J
4 5 6
7 8 9
Thanks. -
Define structure with table type fields using keyword "TYPES"
Hi Gurus,
Using keyword "TYPES", I want to define a structure in which there is a field must be table type. It seems not allowed. For example:
TYPES tt_items TYPE TABLE OF sflight.
TYPES: BEGIN OF str,
field1 TYPE i,
field_tabl TYPE tt_items.
TYPES: END OF str.
Then I got a syntax error:
"TT_ITEMS" is a generic type. Use of this type is only possible for typing field symbols and formal parameters. -
What should I do if I want to have a table type field in it?
Thanks a lot.include type EKKO includes the whole strucutre of EKKO.
if you see the structure in debug mode, it_ekko contains the fields of EKKO as well as the field CHK of type C.
In your case you can do this
TYPES: BEGIN OF str.
INCLUDE TYPE sflight. " includes whole structure of SFLIGHT
TYPES : field1 TYPE i. " include the field1 of type I
TYPES: END OF str.
DATA : it_str TYPE TABLE OF str, " internal table
is_str TYPE str. " work area
Regards
Gopi -
Joint 2 datatable with column type double with a seperater
Can anyone please tell me how to merge 2 datatable of column type double with a seperator (|). one with datetime header and 2nd table with integer headers, like this
table 1
01/02/2015 01/03/2015
12346 47894
table 2
1 2
7899 45678
to become
01/02/2015 01/03/2015
12346 | 7899 47894 | 45678
thanksHi Sysaide,
According to your description, you'd like to migration the two dataTable to one.
What is the corresponding relationship of these two DataTables? Or when you migrating, the 01/02/2015 column and 1 column are fixed to one column. what is the relationship between these two columns?
Or, Does the first column of table1 correspond to the first column of table2? the second correspont to the second? ...
If the column index is corresponding each other. you could use the following way.
Getting out the value of each cell, then rebuild a new table to get this new value.
In your example, your column type is DataTime, but the value in the column is still string type. The below sample is used two different column type, string and int. And I show the result in a dataGridView.
DataTable dt1 = new DataTable();
dt1.Columns.Add("01/02/2015", typeof(string));
dt1.Columns.Add("01/03/2015", typeof(string));
DataRow dr = dt1.NewRow();
dr["01/02/2015"] = "11";
dr["01/03/2015"] = "12";
dt1.Rows.Add(dr);
dr = dt1.NewRow();
dr["01/02/2015"] = "21";
dr["01/03/2015"] = "22";
dt1.Rows.Add(dr);
DataTable dt2 = new DataTable();
dt2.Columns.Add("1", typeof(int));
dt2.Columns.Add("2", typeof(int));
DataRow dr2 = dt2.NewRow();
dr2["1"] = 1111;
dr2["2"] = 1122;
dt2.Rows.Add(dr2);
dr2 = dt2.NewRow();
dr2["1"] = 2211;
dr2["2"] = 2222;
dt2.Rows.Add(dr2);
DataTable dt = new DataTable();
dt = dt1.Clone();
for (int i = 0; i < dt1.Rows.Count; i++)
dt.Rows.Add();
for (int j = 0; j < dt1.Columns.Count; j++)
dt.Rows[i][j] = dt1.Rows[i][j].ToString() + " | " + dt2.Rows[i][j].ToString();
this.dataGridView1.DataSource = dt;
Result:
If you have any other concern regarding this issue, please feel free to let me know.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
IDoc generation with Message Type HRMD_A with filter on Personnel Area
Hello All,
We are facing an issue in generating IDoc using the standard message type HRMD_A.
When we have no filters on the Distribution Model, the IDoc is generated through RBDMIDOC. When we use the filter on BUKRS, it generates the IDoc but gives an error status "Cross-system company code XXXX does not exist". I know to how resolve this issue. But, we tried to filter the changes with Personnel Area this time. So I have used the field PERS_AREA in BD59 with segment type E1PLOGI. When I run the standard report RBDMIDOC it gives the message "No data selected for distribution".
I have checked the field name PERS_AREA from table TBD10, and it is mapped to T500P-PERSA. Change pointers are triggered and stored in BDCP2. Request experts to suggest what could be wrong with this.
Thanks,
AnilHello Michele,
If you have added BUKRS in BD59 for the message type, you will see Company Code (not filter1) in your filter criterion in BD64.
Have you included the following code in FILTER_VALUES_SET method of the BADI implementation.
CHECK OTYPE = 'P '.
SELECT * FROM PA0001
INTO PA0001 WHERE PERNR = OBJID
AND BEGDA <= SY-DATUM
AND ENDDA >= SY-DATUM.
record is valid today, no authorization check
EXIT.
ENDSELECT.
IF SY-SUBRC = 0.
FILTER1 = PA0001-BUKRS. ELSE.
CLEAR FILTER1.
ENDIF.
Lastly, just make sure the record you are testing for has your desired company code PGPB.
Regards,
Anil -
Procedure with table type out parameter
Hi,
I need to create a procedure which gives back a content of a table as an out parameter.
i have tried something like below code
it might not be correct since i am writing from home and cannot access any oracle db right now
create or replace procedure test (
table_out test_table%rowtype
) as
type table_out test_table%rowtype
begin
select * into table_out
from test_table
where country = 'HUN';
end;
compile doesnt gives error, but when running it i get error
declare
table_out test_table%rowtype
begin
test( table_out );
dbms_output.put_line( table_out );
end;
but it fails, could you help how to solve the above problem and call the proc correctly?
thanks in advanceWell you said you want the content of a table but your example says you just want a record. So for a record:
CREATE OR REPLACE PROCEDURE sp_test (EMP_REC OUT EMP%ROWTYPE) IS
BEGIN
select * into emp_rec from emp where empno = 7369;
END;The anonymous block to run it might be:
declare
tab_out emp%rowtype;
begin
sp_test(tab_out);
dbms_output.put_line(tab_out.ename);
end;As damorgan said the dbms_output can't be used with the record type. Notice I used it for the ENAME value of the record.
If you really want the entire table then do it the way damorgan suggests. A pipeline function can give you the table but not as an OUT parameter. -
How to define a function with table type parameter
Hello All,
Here is the requirement ..
cursor c is select first_name, last_name , ssn from employee ;
TYPE employee_type IS TABLE OF c%rowtype;
tbl_employee_type employee_type;
I want to pass the parameter to a function the ssn -: tbl_employee_type(1).ssn
how the formal parameter should be declared
===========================
function chk_notnull_blank ( ? ) return boolean is
BEGIN
if ( colname is NOT NULL and colname in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
RETURN TRUE ;
else
RETURN FALSE ;
end if;
END chk_notnull_blank;
======================
pls advice
thanks/kumarYou cannot define a generic argument in a function,
but you can overload several funtions with the same name and different types of arguments in a package,
in this way (not tested):
create table employees as
select employee_id ssn, first_name, last_name from hr.employees;
create or replace
PACKAGE chk
IS
cursor c is select first_name, last_name , ssn from employees ;
TYPE employee_type IS TABLE OF c%rowtype;
TYPE employee_ssn_type IS TABLE OF employees.ssn%TYPE;
TYPE employee_num_type IS TABLE OF number;
FUNCTION chk_notnull_blank ( colname employees.ssn%TYPE) RETURN boolean;
FUNCTION chk_notnull_blank ( colnames employee_type) RETURN boolean;
FUNCTION chk_notnull_blank ( colnames employee_ssn_type) RETURN boolean;
FUNCTION chk_notnull_blank ( colnames employee_num_type) RETURN boolean;
END chk;
create or replace
PACKAGE BODY chk
IS
FUNCTION chk_notnull_blank ( colname employees.ssn%TYPE) RETURN boolean IS
BEGIN
if ( colname is NOT NULL and colname in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
RETURN TRUE ;
else
RETURN FALSE ;
END IF;
END chk_notnull_blank;
FUNCTION chk_notnull_blank ( colnames employee_type) RETURN boolean IS
BEGIN
FOR i IN colnames.FIRST .. colnames.LAST LOOP
IF NOT chk_notnull_blank( colnames( i ).ssn )
THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN true;
END chk_notnull_blank;
FUNCTION chk_notnull_blank ( colnames employee_ssn_type) RETURN boolean
IS
BEGIN
FOR i IN colnames.FIRST .. colnames.LAST LOOP
IF NOT chk_notnull_blank( colnames( i ) )
THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN TRUE;
END chk_notnull_blank;
FUNCTION chk_notnull_blank ( colnames employee_num_type) RETURN boolean
IS
BEGIN
FOR i IN colnames.FIRST .. colnames.LAST LOOP
IF NOT chk_notnull_blank( colnames( i ) )
THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN TRUE;
END chk_notnull_blank;
END chk;I assumed in this example that if the argument of the function chk_notnull_blank is of the table (collection) type,
then the function returns true if all table elements pass the check, otherwise it returns false. -
DatabaseProcedure with return type prefixed with schema name
Hi (Paco)
I have a question about the DatabaseProcedure class. We are using Oracle proxy users for our database connections.
Everything is accessed via a database role that are granted to the logged on user. All our database objects, tables etc are protected with this database role.
When I want to call a database function/procedure I need to add the schema name as a prefix to the custom database object that we uses for parameters/return types.
So far so good. I can also define a parameter prefixed with schema name via the DatabaseProcedure.registerArrayType ...
But when I try to define a function call that uses this parameter I get an error saying "Declaration is not valid".
The problem is located to the PROCEDURE_DEFINITION regular pattern:
private static final Pattern PROCEDURE_DEFINITION = Pattern.compile("\\s* (FUNCTION|PROCEDURE) \\s+ ([\\w.$]+) \\s* (?:\\((.*?)\\))? \\s* (?:RETURN\\s+(\\w+))? \\s* ;? \\s*", CASE_INSENSITIVE | COMMENTS | DOTALL); The return type cannot be prefixed with the schema name.
Any good suggestions or workarounds?!
I actually did change the pattern runtime via reflection to make it work - but I really don't like this solution in the long run!
/Torben
Edited by: Zonic on 2013-05-07 10:52Hi Torben,
I think I have a workaround for the issue that might work for you. If you look at the source of <font face="courier">DatabaseProcedure.registerArrayType</font> you find that it actually calls <font face="courier">DatabaseProcedure.registerCustomParamType</font>.
public static void registerArrayType(String name)
registerCustomParamType(name, Types.ARRAY, Array.getORADataFactory(), name);
}As a workaround you could replace your calls to <font face="courier">DatabaseProcedure.registerArrayType</font> with calls to <font face="courier">DatabaseProcedure.registerCustomParamType</font> as follows.
// Instead of DatabaseProcedure.registerArrayType("NAME.WITH.DOTS") call:
DatabaseProcedure.registerCustomParamType("anyNameWithoutDots", Types.ARRAY, Array.getORADataFactory(), "NAME.WITH.DOTS"); // Don't forget to use uppercase here.
DatabaseProcedure dp = DatabaseProcedure.define("procedure my.procedure(param1 in out anyNameWithoutDots)");
DatabaseProcedure.ParamType type = dp.getParamDef(0).getType();
System.out.println(type.getName() + " is " + type.getTypeName()); // ANYNAMEWITHOUTDOTS is NAME.WITH.DOTSThis way you don't have to use the "illegal" name in the DatabaseProcedure definition.
Regards,
Paco van der Linden
Maybe you are looking for
-
I tunes wont open after download says improperly installed
i tunes wont open after install
-
I backed up my phone and now all of my lock box info and music is gone
I backed up my phone and now all of my lock box info and music is gone
-
Hi, I have made a PDF with an Flashfield (camera.swf). I can't save the camera-settings of the flash. I have to accept the access right every time. What can I do to set the settings permanent.
-
Looking for a business environment ringtone
For crying out loud Apple!!! My ringtone software I paid $20 for and used to send a normal cellphone ringtone to my iPhone stopped working after 1.1.1. You know, it would be so nice and thoughtful of Apple to simply give us one (1) ringtone that soun
-
Problem saving FrameMaker files
I have recently installed FrameMaker 11 (v11.0.0.380) and have created a book with several files and a TOC. I am working on a network (I've tried both wired and wireless connections) and have the same problem: When I try to save a file, most of the t