Help on Delete Internal table records
Hi,
I have a internal table with some records in it.
I need to delete the contents of this based on the condition as below.
if product_search-Resp_product_company is not initial.
SORT i_equi BY zzrefeng.
DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.
endif.
when i execute this all the records are getting deleted irrespective of the condition mentioned.
Can anyone help me on this.
Regards,
Ram
Hi,
Need to delete the records if <b>ZZREFENG</b> does not have the value of <b>product_search-Resp_product_company</b> .
Here I have product_search-Resp_product_company value as FI14. And also the internal table contains some records with ZZREFENG = FI14.
I need to delete the internal table records if ZZREFENG <> FI14. But when i execute the statement it is deletng all the records even ZZREFENG = FI14 records also.
Regards,
Ram
Similar Messages
-
Error when deletting internal table
Hi to all,
I have small requirement. Am getting runtime error , when am deleting internal table when that internal table will have only one record. how i can solve this problem. Give me some clues.Hi Geetha, you can do this
IF itab[] IS NOT INITIAL.
LOOP AT it_ekbe.
IF it_ekbe-bwart_i NE '101' AND it_ekbe-bwart_i NE '105' AND it_ekbe-bwart_i NE '201' OR it_ekbe-bwart_i NE '202' AND
it_ekbe-bwart_i NE '221' AND it_ekbe-bwart_i NE '222' AND it_ekbe-bwart_i NE '231' AND it_ekbe-bwart_i NE '232' AND
it_ekbe-bwart_i NE '241' AND it_ekbe-bwart_i NE '242' AND it_ekbe-bwart_i NE '251' AND it_ekbe-bwart_i NE '252' AND
it_ekbe-bwart_i NE '261' AND it_ekbe-bwart_i NE '262' AND it_ekbe-bwart_i NE '281' AND it_ekbe-bwart_i NE '282' AND
it_ekbe-bwart_i NE '291' AND it_ekbe-bwart_i NE '292'.
DELETE itab WHERE mblnr = it_ekbe-lfbnr_i
AND matnr_i = it_ekbe-matnr_i
AND ebeln_i = it_ekbe-ebeln_i
AND ebelp_i = it_ekbe-ebelp_i
AND werks_i = it_ekbe-werks_i.
ENDIF.
ENDLOOP.
ENDIF.
This routine does the same but with better performance, I hope this help you.
Regards
David Carballido -
Refresh internal table records in web dynpro
Hi Guru's
I am facing an issue in web dynpro abap.
in my application there is a button called OPEN.
when i click on open button internal table records should be refreshed.
so i have written code like this
DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .
lo_COMPONENTCONTROLLER = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->clear_info_refresh_visible( ).
but iam getting an error message Method "CLEAR_INFO_REFRESH_VISIBLE" is unknown or PROTECTED or PRIVATE
Could you please help me to how do i activate and refresh the things.
Thanks
Rajuewd.rajue wrote:
Hi Guru's
>
> I am facing an issue in web dynpro abap.
> in my application there is a button called OPEN.
> when i click on open button internal table records should be refreshed.
> so i have written code like this
>
> DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .
>
> lo_COMPONENTCONTROLLER = wd_this->get_componentcontroller_ctr( ).
>
> lo_componentcontroller->clear_info_refresh_visible( ).
>
>
>
> but iam getting an error message Method "CLEAR_INFO_REFRESH_VISIBLE" is unknown or PROTECTED or PRIVATE
>
>
> Could you please help me to how do i activate and refresh the things.
>
> Thanks
> Rajue
Raju,
Please clarify this.
Do you have a method clear_info_refresh_visible in your component controller. I think not.
I am not able to relate your request and coding.
You can simply clear the internal table like this
clear lt_intern_tab[].
If it is a context node then you can bind a empty table to the node to make it empty.
lo_nd_data->bind_table(
new_items = lt_intern_tab
set_initial_elements = abap_true ). -
Search Help values to Internal table
Dear Friends,
Is it possible to export Search Help values to Internal table?
On screen, when user click on Search button, the SAP standard search help will call (Customer Search). After entering values, some result get displayed and this result need to export to the internal table.
Thanks in stack
NileshHi:
try this:
DATA : wa_shlp TYPE shlp_descr,
it_records LIKE ddshretval OCCURS 0 WITH HEADER LINE.
wa_shlp-SHLPNAME = 'MAT0M'. "one of elementary search help name from mara-matnr.
wa_shlp-SHLPTYPE = 'SH'.
CALL FUNCTION 'F4IF_SELECT_VALUES'
EXPORTING
shlp = wa_shlp
MAXROWS = 0
SORT = ' '
CALL_SHLP_EXIT = ' '
IMPORTING
MAXROWS_EXCEEDED =
TABLES
RECORD_TAB =
RECDESCR_TAB =
return_tab = it_records
LOOP AT it_records.
WRITE:/ it_records.
ENDLOOP.
Follows is how to get the search help name:
CALL FUNCTION 'DD_SHLP_GET_HELPMETHOD'
EXPORTING
tabname = 'MARA'
fieldname = 'MATNR'
langu = sy-langu
NO_CHKTAB_MAPPING =
GET_ENTITYTAB = ' '
CHANGING
shlp = wa_shlp
callcontrol = callcontrol
EXCEPTIONS
field_not_found = 1
no_help_for_field = 2
OTHERS = 3
CALL FUNCTION 'F4IF_EXPAND_SEARCHHELP'
EXPORTING
shlp_top = wa_shlp
IMPORTING
shlp_tab = shlps.
好运,
启明星 -
How to display the Internal table records in table format?
Hi Gurus,
I want to display my print prg internal table records in d appropriate form in a table format, give some solution
with regards
ThambeThere are lot many options to do that
one way is create template in the maikn window and define the line types according to your data cretae text and put your data in the text and go to output options and give the line type to be used . You can also select details option to have lines in your output.
similarly YOU CAN CREATE TABLE IN THE MAIN WINDOW FOR THIS YOU DONT NEED TO DEFINE THE LINE TYPES .
WHEN YOU ARE IN MAIN WINDOW RIGHT CLICK ON TABLE AND GO TO PATH
CREATE -> TABLE
-> TEMPLATE
REWARD IF USEFUL
Regards,
Nageswar -
Function module for move internal table records into MSexcel file
Hi all,
Tell me the function module which is used to
move internal table records in to MSexcel file.
Give the sample program...Please search the forum for FM "GUI_DOWNLOAD" You will get tons of threads with sample code.
Also take a look into SAP_CONVERT_TO_XLS_FORMAT
Thanks -
Procedure to delete mutiple table records with 1000 rows at a time
Hello Champs,
I am having requirement to create procedure to achive the deletes from 5 big tables. 1 master table and 4 child tables. Each table has 28 millions records. Now I have to schedule a procedure to run it on daily basis to delete approximately 500k records from each tables. But the condition is: Seperate procedures for each tables and delete only 1000 rows at a time. The plan is below. Since I am new for writing complicate procedure, I don't have much idea how to code the procedures, can some one help me to design the procedure queries. Many Thanks
1. Fetch 1000 rows from master table with where clause condition.
2. Match them with each child tables and delete the records.
3. Atlast delete those 1000 rows from master table.
4. over all commit for all 5 X 1000 records.
5. Repeat the steps 1 to 4 till no rows to fetch from master table.
Below are detailed procedure plan:----
----- Main procedure to fetch 1000 rows at a time and providing them as input to 5 different procedures to delete records, repeating same steps till no rows to fetch i.e. (i=0)-----
Create procedure fetch_record_from_master_table:
loop
i = Select column1 from mastertable where <somecondition> and rowcount <= 1000;
call procedure 1 and i rows as input;
call procedure 2 and i rows as input;
call procedure 3 and i rows as input;
call procedure 4 and i rows as input;
call procedure 5 and i rows as input;
commit;
exit when i=0
end loop;
----- Sepereate procedure's to delete records from each child tables------
Create procedure 1 with input:
delete from child_table1 where column1=input rows of master table;
Create procedure 2 with input:
delete from child_table2 where column1=input rows of master table;
Create procedure 3 with input:
delete from child_table3 where column1=input rows of master table;
Create procedure 4 with input:
delete from child_table4 where column1=input rows of master table;
--- procedure to delete records from master table atlast----
Create procedure 5 with input:
delete from Master_table where column1=input rows of master table;Oops, but this will work, won't it?
begin
execute immediate 'truncate table child_table1';
execute immediate ' truncate table child_table2';
execute immediate ' truncate table child_table3';
execute immediate ' truncate table child_table4';
for r_fk in ( select table_name, constraint_name
from user_constraints
where table_name = 'MASTER_TABLE'
and constraint_type = 'R'
loop
execute immediate 'ALTER TABLE ' || r_fk.table_name || ' MODIFY CONSTRAINT ' || r_fk.constraint_name || ' DISABLE';
end loop;
execute immediate ' truncate table master_table';
for r_fk in ( select table_name, constraint_name
from user_constraints
where table_name = 'MASTER_TABLE'
and constraint_type = 'R'
loop
execute immediate 'ALTER TABLE ' || r_fk.table_name || ' MODIFY CONSTRAINT ' || r_fk.constraint_name || ' ENABLE';
end loop;
end;
/ Or
truncate table child_table1;
truncate table child_table2;
truncate table child_table3;
truncate table child_table4;
begin
for r_fk in ( select table_name, constraint_name
from user_constraints
where table_name = 'MASTER_TABLE'
and constraint_type = 'R'
loop
execute immediate 'ALTER TABLE ' || r_fk.table_name || ' MODIFY CONSTRAINT ' || r_fk.constraint_name || ' DISABLE';
end loop;
end;
truncate table master_table;
begin
for r_fk in ( select table_name, constraint_name
from user_constraints
where table_name = 'MASTER_TABLE'
and constraint_type = 'R'
loop
execute immediate 'ALTER TABLE ' || r_fk.table_name || ' MODIFY CONSTRAINT ' || r_fk.constraint_name || ' ENABLE';
end loop;
end;
/ -
Problem in Internal table Record Splitting
Hi All,
Plz look into my below requirement and me know your Suggestions.
My Internal tables :
1.*Internal table for Infotype 2002 (Attendances)
DATA : BEGIN OF T_PA2002 OCCURS 0,
PERNR LIKE PA2002-PERNR,
BEGDA LIKE PA2002-BEGDA,
ENDDA LIKE PA2002-ENDDA,
BEGUZ LIKE PA2002-BEGUZ,
ENDUZ LIKE PA2002-ENDUZ,
SUBTY LIKE PA2002-SUBTY,
END OF T_PA2002.
1.*Internal table for Infotype 9003 (Custom Attendances)
DATA : BEGIN OF T_PA9003HRABS OCCURS 0,
PERNR LIKE PA9003-PERNR,
BEGDA LIKE PA9003-BEGDA,
ENDDA LIKE PA9003-ENDDA,
SHIFT LIKE PA9003-SHIFT,
OTHOURS LIKE PA9003-OTHOURS,
BEGUZ LIKE PA2002-BEGUZ,
ENDUZ LIKE PA2002-ENDUZ,
NSA LIKE PA9003-NSA,
MA LIKE PA9003-MA,
CA LIKE PA9003-CA,
END OF T_PA9003HRABS.
Requirement :
1. Internal table T_PA2002
PERNR BEGDA ENDDA BEGUZ ENDUZ
5 27.12.2006 27.12.2006 10:00:00 14:30:00
2. Internal table T_PA9003HRABS
PERNR BEGDA ENDDA BEGUZ ENDUZ HRABS OTHOURS MA CA WA
5 27.12.2006 27.12.2006 08:00:00 14:30:00 2 2
Iam doing comparision between T_PA2002 and T_PA9003HRABS.
Iam doing some caluculation to get Hourly absence,OT Hours and else ( Fields)
So my Hourly absence on 27.12.2006 was 2Hours.
So i need to split my Final table as below how to do that....( It is like In infotypes COPY option i.e 1 record to 3 Record )
I need the Output like this...
3. Final Internal table T_PA9003HRABS
PERNR BEGDA ENDDA BEGUZ ENDUZ HRABS OTHOURS MA CA WA
5 25.12.2006 26.12.2006 08:00:00 14:30:00 0 0
5 27.12.2006 27.12.2006 08:00:00 14:30:00 2 2
5 25.12.2006 26.12.2006 08:00:00 14:30:00 0 0
Points will be rewarded.
Thanks,
Suresh.Uyou could:
sort T_PA2002 by pernr.
sort T_PA9003HRABS by pernr.
loop at T_PA2002
read table T_PA9003HRABS with key
pernr = T_PA2002-pernr
begda = T_PA2002-begda
binary search.
***here you can specify how you calculate
***your absences and apply them to your
***final internal table.
endloop.
hope this helps.
Warren -
Internal table record checking (Urgent)
Hi Experts,
I have an internal table having records. I want to check each record of the table with every other record to find out if there exist same record for more then one key field.
Can anybody help me to place the logic for how i can check the records with each record? Like
lifnr banks
1 12
2 34
3 12
4 12
5 76
I want to find out 1,3 and 4.
Thanks a ton in advanceHi Moni,
IF in my First Reply the Second technique was working then this should solve your Problem:
DATA:
w_index TYPE i,
w_lines TYPE i,
w_duplicate(10) TYPE c.
DESCRIBE itab LINES w_lines.
LOOP AT itab INTO wa.
w_index = sy-tabix + 1.
DO.
READ TABLE itab INTO wa1 INDEX w_index.
IF w_index <= w_lines.
IF wa-banks EQ wa1-banks.
CONCATENATE w_duplicate wa1-lifnr INTO w_duplicate SEPARATED BY SPACE.
wa-duplicate = w_duplicate.
MODIFY itab FROM wa.
ENDIF.
ELSE.
EXIT.
ENDIF.
ADD 1 TO w_index.
ENDDO.
ENDLOOP.
LOOP AT itab INTO wa.
write:
/ wa-lifnr,
wa-banks,
wa-duplicates.
ENDLOOP.
ELSE try the below code it is same as above except one more Internal Table is used:
DATA:
w_index TYPE i,
w_lines TYPE i,
jtab LIKE itab,
w_duplicate(10) TYPE c.
DESCRIBE itab LINES w_lines.
LOOP AT itab INTO wa.
w_index = sy-tabix + 1.
DO.
READ TABLE jtab INTO wa1 INDEX w_index.
IF w_index <= w_lines.
IF wa-banks EQ wa1-banks.
CONCATENATE w_duplicate wa1-lifnr INTO w_duplicate SEPARATED BY SPACE.
wa-duplicate = w_duplicate.
MODIFY itab FROM wa.
ENDIF.
ELSE.
EXIT.
ENDIF.
ADD 1 TO w_index.
ENDDO.
ENDLOOP.
LOOP AT itab INTO wa.
write:
/ wa-lifnr,
wa-banks,
wa-duplicates.
ENDLOOP.
Regards,
Sunil. -
Delete internal table rows without using loop statement
i have an internal table which consists of 100 records.
i need to keep only first 5 records.
without using the loop statement i need to delete the rest of the records. how can we achieve this result.
i.e. delete itab1 where "recordno" > 5.
regards.
ZGHi,
Delete itab [FROM idx1] [TO idx2] {Where (log_exp)]
To delete several lines at once, you have to specify at least one of the additions FROM, TO, or WHERE. You can only use the additions FROM and TO with standard tables and sorted tables.
Delete itab [FROM idx1]
If you specify FROM, all the table rows from the table index idx1 onwards are included.
Delete itab [TO idx2]
If you specify TO, all the table rows from the table index idx2 onwards are included.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid.
DATA: BEGIN OF seats,
fldate TYPE sflight-fldate,
seatsocc TYPE sflight-seatsocc,
seatsmax TYPE sflight-seatsmax,
seatsfree TYPE sflight-seatsocc,
END OF seats.
DATA seats_tab LIKE STANDARD TABLE OF seats.
SELECT fldate seatsocc seatsmax
FROM sflight
INTO TABLE seats_tab
WHERE carrid = p_carrid AND
connid = p_connid.
LOOP AT seats_tab INTO seats.
seats-seatsfree = seats-seatsmax - seats-seatsocc.
MODIFY seats_tab INDEX sy-tabix FROM seats.
ENDLOOP.
ENDLOOP.
SORT seats_tab BY seatsfree DESCENDING.
DELETE seats_tab FROM 5.
Thanks & Regards,
ShreeMohan
Edited by: ShreeMohan Pugalia on Jul 21, 2009 4:28 PM -
Hi all,
Can anyone tell, after deletion the records from one internal table itab1 using specific condition , that how will insert the single record from another itab2
into itab1 on the same index.
Regards
Alokok , please find whole code as shown below for assigning role in su01.
Code:
FORM add_roles_user.
Data: int_agr like bapiagr occurs 0 with header line,
int_agr1 like bapiagr occurs 0 with header line,
user_activitygroups like usagr occurs 0 with header line.
loop at int_role where uname = bname or uname = ''.
int_agr-agr_name = int_role-agr_name.
int_agr-from_dat = int_role-begda.
int_agr-to_dat = int_role-endda.
append int_agr.
endloop.
if not int_agr[] is initial.
CALL FUNCTION 'SUSR_USER_AGR_ACTIVITYGR_GET'
EXPORTING
USER_NAME = bname
TABLES
USER_ACTIVITYGROUPS = user_activitygroups
EXCEPTIONS
USER_NAME_NOT_EXIST = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at user_activitygroups.
Message 371365
read table int_agr with key agr_name =
user_activitygroups-agr_name from_dat =
user_activitygroups-from_dat to_dat =
user_activitygroups-to_dat org_flag =
user_activitygroups-ORG_FLAG.
if sy-subrc <> 0.
int_agr-agr_name = user_activitygroups-agr_name.
int_agr-from_dat = user_activitygroups-from_dat.
int_agr-to_dat = user_activitygroups-to_dat.
int_agr-ORG_FLAG = user_activitygroups-ORG_FLAG.
append int_agr.
endif.
Message 371365
Start of changes by P4TK900204
sort int_agr by agr_name." FROM_DAT to_dat descending.
delete adjacent duplicates from int_agr comparing agr_name.
End of changes by P4TK900204
endloop.
endif.
int_agr1[] = int_agr[].
loop at int_agr1.
delete int_role where agr_name = int_agr1-agr_name.
endif.
endloop.
append lines of int_role to int_agr1.
sort int_agr1 by agr_name." FROM_DAT to_dat descending.
CALL FUNCTION 'SUSR_BAPI_USER_ACTGROUPS_ASSIG'
EXPORTING
USERNAME = bname
INCL_HR_ASSIGN = 'X'
TABLES
ACTIVITYGROUPS = int_agr1
RETURN = return_int2.
loop at return_int2.
case return_int2-number.
when '048'.
when others.
message-msgty = return_int2-type.
message-msgid = return_int2-id.
message-msgno = return_int2-number.
message-msgv1 = return_int2-message_v1.
message-msgv2 = return_int2-message_v2.
message-msgv3 = return_int2-message_v3.
message-msgv4 = return_int2-message_v4.
perform set_return_message using message changing return_int.
endcase.
endloop.
ENDFORM. " add_roles_user -
Problem to upload the data into internal table record length more than 6000
Hi all
I stuck with this problem from past 3 days. I have to upload the data from excel sheet. iam making it tab delimited and trying to upload from gui_upload. but in the structure of file, we have, one field of 4000 characters, and other fields of 255 characters.
how can i upload this into internal table . From excel sheet or from tab delimeted or any other format? or any special function module is there? while iam doing this its truncating the datat 255 characters and not uploading the other fields also...
can any one of you help me out. ASAP
thnks in advancefrom one of the forum iam just pasting code which it is used in lsmw, try the same logic in ur code hope it can work.
you have to create multiple lines with do...enddo loop., like this:
(assuming excel_long_text-text is 924 characters long, 7 lines X 132 char)
__GLOBAL_DATA__
data: offset type i,
text_132(132) type c.
__BEGIN_OF_RECORD__ Before Using Conversion Rules
Rule : Default Settings Modified
Code: /sapdmc/ltxtl = init_/sapdmc/ltxtl.
CLEAR offset.
DO 7 TIMES.
text_132 = excel_long_text-text+offset(132).
offset = offset + 132.
__END_OF_RECORD__ After Using Conversion Rules
Rule : Default Settings Modified
Code: transfer_record.
ENDDO.
also check this
COMMIT_TEXT
To load long text into SAP
READ_TEXT
To load long text into SAP -
Reg : Joining the all internal table records into a single internal table
Hi all
I am having 5 internal tables and i want to put all these entries in a single intrnal table and my requirement is for each and every record it has to go through all the internal tables and if an entry is missing meand.it has to go through the other internal tables and for missing entries i should leave it as blank and rest of the contents i have to display can any please gimme some logic how to do this??
Thanks in advanceDon't have time or will to deliver turnkey solutions, but here is a frame:
LOOP AT itab1...
READ TABLE itab2 WITH TABLE KEY... (fields linking itab1 and itab2)
READ TABLE itab3 WITH TABLE KEY... (fields linking itab1 and itab3)
LOOP AT itab4 WHERE... (fields linking itab1 and itab4)
READ TABLE itab5 WITH TABLE KEY... (fields linking itab4 and itab5)
MOVE-CORRESPONDING... (all five work areas to target work area)
APPEND itabtarget...
ENDLOOP.
ENDLOOP.
so use READ when there is a 1:1 relationship (e.g. check table entry), and LOOP when there is a 1:N relationship (e.g. items for a header)
Thomas -
How to send Internal table records to Idoc Inbound posting FM to create Ido
Hello Experts,
I have all the data necessary to create shipments in one internal table inside my ABAP program.
I can use BAPI_SHIPMENT_CREATE to create shipments. But associated with this BAPi there is one ALE message type SHIPMENT_CREATEFROMDATA. Now my requirement is to use this message type to cretae my shipments via idocs for one scenario for some of the records in the internal table.
For this message type, I got the inbound function module IDOC_INPUT_SHIPMENT_CREATEFROM from TBDBE table.
Can anybody please let me know how to send the data from the internal table to this inbound function module?
Becasue it has mandatory parameters INPUT_METHOD, MASS_PROCESSING. What values should be passed to these parameters if the data has to be sent to this function module?
Regards.Hi Ravikanth,
Thankyou very much for your quick reply.
So If I split my internal table data and populate IDOC_DATA and IDOC_CONTROL and pass to the inbound function module directly in my ABAP program, will that be going to create idocs and post shipments?
I mean is it enough to call the Inbound posting function module directly in my ABAP program or any other FMs to be called to take care of ALE settings and shipment creation?
Please confirm.
REgards. -
Doubt in internal table record count
Hi,
i have an internal table with 5 fields. Last field is flag. In my internal table lot many records are there. i want to count only the records with flag 'E'. How to count the total records with 'E'.
MohanaTry like this,
Data: c type i.
Loop at itab into wa.
if wa-flag = 'E'.
c = c + 1.
endif.
Endloop.
Write:/ 'Total records', c.
OR
LOOP AT itab WHERE flag = 'E'.
c = c + 1.
ENDLOOP.
Edited by: Sap Fan on Apr 3, 2009 5:21 PM
Maybe you are looking for
-
My apple tv is unresponsive even after resetting it. Any ideas?
My apple tv doesn't show up on the TV channel. I followed Apple's instructions to reset it by holding down the Menu button and the Down button until rapid blinking light. Then unplugged it and waited. After replugging it you see the Apple symbol on t
-
Custom Attribute not available in Available Fields section of Configuration
Hi Experts, My requirement is to add a custom search field in contact search screen. For that i tried various options Option1 Added a model attribute in component/view BP_CONT SEARCH/Search. The attribute got successfully added. But when i opened th
-
I cant get my ipad2 out of recovery mode
I have hooked up to itunes countless times and keep getting the same error codes 11 or 12. It started when I got the notification to update and so I clicked to update and let it run its course, it rebooted and gave me the connect to itunes screen. I
-
Can someone tell me what is the meaning of these validation modes? NONVALIDATING PARTIAL_VALIDATION DTD_VALIDATION SCHEMA_VALIDATION thanks. null
-
Objective C, working with C++ API
How to include and use a C++ API in an Objective C app? Any idea, tutorial ... ?