Sql queries from internal tables based on context node
Hi experts,
I want to select from my inetrnal table which is based on the context node, the rows which do not appear in another internal table based on the context node.
I have this data:
data lt_item_level type table of wd_this->element_item_level INITIAL SIZE 0.
data lt_item_level_cp type table of wd_this->element_item_level INITIAL SIZE 0.
data lt_po_items TYPE table of wd_this->element_po_items INITIAL SIZE 0.
I want to do this:
select * into CORRESPONDING FIELDS OF TABLE lt_item_level_cp from lt_item_level WHERE lt_po_items-po_number NE lt_item_level-item_number.
But i get an error:
"LT_ITEM_LEVEL" is not defined in the ABAP Dictionary as a table,
Is there a way to do it with select or should i loop over my internal tables?
thank u very much!!
hi,
You cannot use Select queries on internal table. do like this :
loop at itab into wa where wa-F1 NE wa-F2.
append wa to itab1.
endloop.
Here itab1 will have all the records as per your requiement.
I hope it is clear.
Edited by: Saurav Mago on Oct 26, 2009 5:37 PM
Similar Messages
-
How to get a block of data from internal table based on a criteria
Hi all,
I have some records in the internal table t_int1. I want to retrieve some set records from that table and put them all in some other table, based on a single field which is not a key. Can i use READ statement to achieve this.
Could you please let me know any simple way of doin this.
Regards,
VishnuI have some records in the internal table t_int1. I want to retrieve some set records from that table and put them all in some other table, based on a single field which is not a key. Can i use READ statement to achieve this.
Could you please let me know any simple way of doin this.
Answer :
data:
itab2 like standard table of t_int1 with header line.
Loop at t_int1.
read table t_int1 with index 1.
check ur condition----
check each line and insert it ---work out the syntax for this
IF t_int1-xyz = data1
append line of t_int1 to itab2. or try insert
cnt = cnt + 1 -
u will get no. of records added to next itab.
else.
cnt1 = cnt1 + 1 -
u will get no. of records not added to next itab.
endif.
end loop. -
Efficiently deleting lines from internal table based on column comparison
Hi all,
let's assume, I have the following internal table MY_TAB:
COL_1 | COL_2 | COL_3
A 1 1
B 2 2
C 3 3
D 3 4
E 3 5
I'd like to delete all rows, where the values in COL_2 and COL_3 are equal. That is, in the above table, the rows for A, B and C.
What's the most performant / fastest and efficient way to do this?
Thanks for any hints in advance!
Best regards,
PhilippI do not understand other proposal.
The are two solutions possible
LOOP AT itab INTO wa.
IF ( wa-col2 = wa-col3).
DELETE itab INDEX sy-tabix.
ENDIF.
ENDLOOP.
If memory is not an issue and if many lines are to be deleted, then the APPEND in a new table is better.#
I would use that one in all cases where the conditions are complicated.
LOOP AT itab INTO wa.
IF ( wa-col2 <> wa-col3).
APPEND wa TO itab2.
ENDIF.
ENDLOOP.
refresh itab.
itab[] = itab2[].
Siegfried -
(ABAP) Internal table of type context node (Urgent)
Hi All,
I created a internal table in a view say ABC_VIEW using a context node say ABC_NODE. This is did using following statement:
it_abc type table of if_abc_view=>element_abc_node.
Now I would like to pass this as a exporting parameter to a method in component controller. Kindly suggest how i can achieve this. I tried the following:
it_abc exporting element_abc_node.
But this does not work.
Kindly reply soon.
Regards,
Anoop
Message was edited by: Anoop Singh SainiHi Anoop,
Web Dynpro generates an internal table (and structure) for each context node in a controller's context. Such a definition is local to the controller where the node is defined, since a different controller could have a node of the same name with different attributes. Nonetheless, it is possible to transfer the data of a node to another controller by:
(a) Using a DDIC structure for a context node. The generated structure and the DDIC structure are the same then. The generated internal table is a standard table. If you define one in DDIC or somewhere else, you can use it for typing the parameter.
(b) Transfer the pointer to the node! You can still access it from any other place.
Best regards,
Thomas -
To get recent timestamp records from internal table
hi all,
i have one requirment
i'm storing error messages in one table while creating a sales order basing on timestamp
which is of this format yyyy-mm-dd hh:mm:ss (random Number)
if i want to see the error messages left i'm getting all the error messages displayed
for example i have created a sales order
i got 10 errors displayed
i have rectified 5 errors ... if i again display error messages the 10 errors + the 5 errors is getting displayed
i want to display the 5 error messages only not the previous messages from internal table
basing on timestamp current one has to displayed remaining has to deleted from internal table.I thought we used Sales Order Incompletion process for this.... but, if you're recreating the errors list every time you save with a create or change transaction then, at save, delete all rows in your error table for this document. Then get your errors and update your db table from your current errors table. From this viewpoint, the timestamp is not relevant.
-
Deleting entry from internal table
Hi Experts,
i have the following internal table:
data : it_result1 TYPE crmt_object_guid_tab
and work area
data : wa_result1 type crmt_object_guid.
i have to delete a guid from internal table based on some condition.
loop at it_resul1 into wa_result1
if lv_priority eq priority.
delete this entry from internal table.
endif.
endloop..
i tried using delete table it_result with table key CRMT_OBJECT_GUID = wa_result. but this is giving syntax error.
what should be done to delete the entry?
Thanks and regards
ShilpiHi
Check Syntax for DELETE operator on pressing F1
1. DELETE itab.
2. DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
3. DELETE TABLE itab [FROM wa].
4. DELETE itab INDEX idx.
5. DELETE itab FROM idx1 TO idx2.
6. DELETE itab WHERE logexp.
7. DELETE ADJACENT DUPLICATES FROM itab.
delete table it_result with table key CRMT_OBJECT_GUID = wa_result
this is wrong
delete it_result where CRMT_OBJECT_GUID = wa_result
Edited by: Lavanya K on Apr 22, 2009 10:20 AM -
To delete duplicate records from internal table
hi friends,
i have to delete records from internal table based on following criterion.
total fields are 7.
out of which if 4 fields are same and 5th field is different,then both records must be deleted.
in case all five fields are same,the program should do nothing.
for example.
if there are 3 records as follows
a1 b1 c1 d1 e1 f g
a1 b1 c1 d1 e2 w r
a1 b1 c1 d1 e1 j l
then first two records should be deleted as four fields are same but fifth(e) field differs.
but third record should remain as it is evenif first five fields are same for first and third record.
values of last two fields need not to be consider for deleting the records.LOOP AT ITAB.
V_FILED5 = ITAB-F5. "to compare later
V_TABIX = SY-TABIX. "used to delete if condition not matches
READ TABLE ITAB WITH KEY F1 = ITAB-F1
F2 = ITAB-F2
F3 = ITAB-F3
F4 = ITAB-F4.
IF SY-SUBRC = 0.
IF ITAB-F5 <> V_FIELD5.
*--both the records to be deleted,as Field5 is different.
DELETE ITAB INDEX SY-TABIX. "deletes that record
DELETE ITAB INDEX V_TABIX. "deletes the current record
ENDIF.
ENDIF.
ENDLOOP.
Message was edited by: Srikanth Kidambi
added comments
Message was edited by: Srikanth Kidambi -
Can not insert or update [TABLE] from internal table in method
I've faced a problem with OO abap. I've tried to insert into [ TABLE ] from internal table, but i've got error msg after i compiled.
"An explicit work area is necessary in the OO context. Use "INSERT wa INTO [TABLE] itab""
After i changed to loop in work area and INSERT INTO [TABLE] VALUES gw_data., everything is fine, can compile and run.
This is error code.
METHOD set_data_to_table.
REFRESH gi_data.
CLEAR gi_data.
IF gi_file[] IS NOT INITIAL.
* Set data for modify table
LOOP AT gi_file INTO gw_file.
MOVE-CORRESPONDING gw_file TO gw_data.
me->conversion_input( EXPORTING im_vendor = gw_data-vendor
CHANGING ch_vendor = gw_data-vendor ).
APPEND gw_data TO gi_data.
ENDLOOP.
INSERT [TABLE] FROM TABLE gi_data.
* LOOP AT gi_data INTO gw_data.
* INSERT INTO [TABLE] VALUES gw_data.
* IF sy-subrc = 0.
* COMMIT WORK.
* ELSE.
* ROLLBACK WORK.
* ENDIF.
* ENDLOOP.
ELSE.
MESSAGE 'No data found' TYPE 'I'.
ENDIF.
ENDMETHOD. "set_data_to_tableHi Matthew,
I think there is no difference in database insert between OO and non-OO.
The correct syntax according to ECC600 online documentation is
[Inserting Several Lines|http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm]
To insert several lines into a database table, use the following:
INSERT target FROM TABLE itab \[ACCEPTING DUPLICATE KEYS].
This writes all lines of the internal table itabto the database table in one single operation. If one or more lines cannot be inserted because the database already contains a line with the same primary key, a runtime error occurs. You can prevent the runtime error occurring by using the addition ACCEPTING DUPLICATE KEYS.
Whenever you want to insert more than one line into a database table, it is more efficient to work with an internal table than to insert the lines one by one.
I think the syntax
INSERT my_dbtable FROM TABLE gi_data.
should work, your suggestion may lead to syntax error.
Regards,
Clemens -
Problem in deleting entries from internal table
i am selecting
vrgar
perio
paobjnr
belnr
gjahr
perde
budat
kndnr
artnr
frwae
kursf
rec_waers
kaufn
kdpos
bukrs
kokrs
werks
gsber
vkorg
vtweg
spart
rbeln
rposn
prctr
pprctr
kunnr
land1
regio
kunwe
kvgr1
wwpmg
zterm
wwcst
wwrst
mvgr3
wwseg
wwcls
wwesa
prdha
wwbun
wwexd
wwph1
wwph2
wwph3
wwph4
prat1
prat2
vrprs
vv510
vv508
vv509
vvqt2
vv515
INTO TABLE ct_ce11000 FROM ce11000
WHERE paledger EQ gv_ledbo AND
vrgar EQ lc_vrgar AND
belnr GT uv_belnr AND
gjahr EQ pa_gjahr AND
perde EQ pa_perd AND
bukrs EQ pa_bukrs.
now i awant to delete all those entries from my internal table ct_ce11000 where my plant (WEKRS) and company code (BUKRS)
i am writting
loop at ct_ce11000 into wa_ce11000.
if wa_ce11000-werks ne wa_ce11000-bukrs.
now how can i delete all the entries from nmy internal table (ct_ce11000) when plant and company code is not same
pls help me with logic.
thank you for helping meHello Guys,
It is not advisable to delete the entries from the internal table you are looping upon. See this thread: [Sy-tabix in loop : Doubt|Sy-tabix in loop : Doubt]
And to answer the OP's question select data into some local internal table & based on the condition populate your final table. Creating a local table of the same type as the final table will not create too much performance overhead
Cheers,
Suhas -
Generating a internal table based on the fieldcatalog
hi,
i want to generate an internal table based on field catalog which will be generated after the user has selected a particular layout.
For eg. Suppose there are at present 25 fields at the ALV output and out of which user selects 10 fields using layout option and i save the layout.
Now i want an internal table with these 10 fields in my internal table not all the 25 fields.
any ideas?
regards
jignesh.Hi,
Look at the sample code below.
FIELD-SYMBOLS: <outtab> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
DATA: it_fieldcat TYPE lvc_t_fcat.
DATA: wa_fieldcat TYPE lvc_s_fcat.
DATA: BEGIN OF itab OCCURS 0,
matnr TYPE matnr,
aenam TYPE aenam,
END OF itab.
"Fill the fieldcat here
"For example say it contains two fields MATNR AENAM
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <outtab>. "This is the required table
CREATE DATA new_line LIKE LINE OF <outtab>.
ASSIGN new_line->* TO <l_line> . "Work area forthe same
SELECT matnr aenam UP TO 5 ROWS
FROM mara
INTO TABLE itab.
LOOP AT itab.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = itab-matnr.
ASSIGN COMPONENT 'AENAM' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = itab-aenam.
INSERT <l_line> INTO TABLE <outtab>.
ENDLOOP.
LOOP AT <outtab> ASSIGNING <l_line>.
WRITE: / <l_line>.
ENDLOOP.
Regards,
Manoj Kumar P -
Update databse from internal table statement not using index
Hi Guys,
We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
Should not the update statement here be using the table index (for primary key)?
Regards,
Munish... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
Coming to the original question, what is you actually coding for the update?
What is the table, which fields are in the internal table and what are the indexes?
Siegfried -
How to prepare final internal table based on no. of records of individual t
Hi all,
I have to prepare final internal table based on the no. of records of individual table. i.e. I should append the data from the table which has large no of records first. Then I should modify the final table with other individual tables. I have reservation list table(RESB), purchase requisition table(EBAN), purchase order delivery schedules table(EKET) , GRs table (MESG) .I have prepared data for individual tables. We can't say particularly that this table'll have large no. of records always. So how can I append the first table into final internal table ? I have separate work areas for each table in my SMARTFORM.
Edited by: Jayasri P. on Aug 30, 2008 6:02 AMHI,
DESCRIBE TABLE statement with LINE addition will give you the no of record in an internal table.
For further detail check,
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
you can stire the LINE value of each and comare them to get the table with max record.
Regards,
Anirban -
Read contents of changing fields from internal table
Hi Folks,
Please help me in my query below:
Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
So how can I read the particular field from internal table as the field to be read is dynamic.
Note: using case is not feasible.
Thanks in advance.
Regards,
Shardul@Hartmut P
As Rob said i want to get the value of the field from internal table. the code is something like this.
I_KNA1 contains records for customers.
Suppose values of Z-table are in internal table I_TEMP_TABLE.
Entries in I_TEMP_TABLE are as follows
TABNAME FIELDNAME
KNA1 NAME1
The value of FIELNAME in Z-table can be changed
Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
IF SY-SUBRC EQ 0.
CASE WA_TEMP_TABLE-FIELDNAME.
WHEN 'NAME1'.
V_VAR = WA_KNA1-NAME1.
WHEN 'PSTLZ'
V_VAR = WA_KNA1-PSTLZ.
ENDIF.
But using case is not appropriate as KNA1 contains 176 fields. -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
How to send data from internal table to the shared folder in ABAP
Hi experts,
My requirement is to transfer data from a file to shared folder. i just did reading data from a file to a internal table. Now i want to send this internal table data into a shared folder which is "
xxx\y\z....".
I do not have any idea on how to send data from internal table to the shared folder path.
can anybody please help me out how to do this?
Thanks & Regards
Sireesha.Where that folder is located, its on presentation server i.e. desktop or application server.
If its on presentation server, use FM GUI_UPLOAD.
If its on application server, then use DATASET functions. Have a look at below link.
[File Handling in ABAP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm]
I hope it helps.
Thanks,
Vibha
Please mark all the useful answers
Maybe you are looking for
-
Need Information Related to Finance
Hi Everyone, Can anyone explain me about WBS ,WIP, AP ,AR, GL & related things.. With Regards Pavan
-
Hello Experts, I need help to know if it possible to achieve below situation: I have build a universe in IDT , now the requirement is I have users from 2 different regions, i need to build a universe with 2 different databases, so when user logs in w
-
Droplet has strange icon and won't activate.
I've never had trouble creating droplets in CS3, but now every time I create one it shows up with a strange (rough-looking, jagged edged) type of icon. If I try to drop a file on it, it won't activate. I know the action works because if I open a fil
-
Limited access for printer sharing
I am currently sharing access to my printer so that my roommate can print from it without having to get up and plug it in to the usb port each time, and have been successful in trying to do so with one problem: I live in a dorm and therefore another
-
Making a separate clip from a master clip...
Hi, If I want to separate and rename clips from an original master clip and place them in separate folders, how do I do this without affecting the original master clip? Do I need to take the cllps into the timeline, or is there a more time effective