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 advance
Hi 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.
Similar Messages
-
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 ). -
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 -
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,
RamHi,
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 -
How to add the records of 2 internal table records into one file
hello experts,
My scenario is...
I am retrieving the data for the for the credit, debit and trailer records of the customer into 3 different internal tables and finally i have to append all those records into one file first debit records then credit records finally the trailer record.... how to do that can anyone give some idea plzzzzzzzzz..
Plz its bit urgent..
Thanks a lot for your anticipation
SRIHello,
Do like this.
" Assume u have three itab.
"Itab1 - debit
"Itab2 - credit
"Itab3 - Credit.
REPORT ZV_TEST_SERVER .
*PARAMETERS: P_FILE TYPE STRING."RLGRAP-FILENAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
* FILETYPE = 'ASC'
APPEND = 'X' " Check here
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = ITAB1
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
* FILETYPE = 'ASC'
APPEND = 'X' " Check here
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = ITAB2 " Check here
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = P_FILE
* FILETYPE = 'ASC'
APPEND = 'X' " Check here
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = ITAB3 " Check here
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
If useful reward.
Vasanth -
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 -
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 -
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. -
Internal table Issue ( very urgent)
Hi,
There are two internal tables A and B.
Product is one of the fields of both A and B and is the key.
A has say say 10 products and B has 4 products.
I want to delete those products from A which are not there in B.
( It is somewhat like using 'FOR ALL ENTERIES IN ' with Select Statement)
Is this possible in internal tables without 'Loop at'. The actual table would have over 1 million records and and looping is a major concern.
I am new to abap and any help from you guys would be appreciated.....Advait,
I think you will need atleast one loop. This loop can be on the table B.
If product is the <b>left most field</b> of table B try this:
The last field for table A must be a flag for don't delete
SORT IT_B by product.
LOOP AT IT_B INTO WA_B.
AT NEW product.
WA_A-dont_delete = 'X'.
MODIFY IT_A FROM WA_A TRANSPORTING dont_delete WHERE product = wa_b-product.
ENDAT.
ENDLOOP.
DELETE IT_A WHERE dont_delete <> 'X'. -
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 -
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 -
Doubt in internal table records
Hi all,
I have a one problem, in my internal table have 5 records. i did some correction in my progm after i execute the loop i need the correction in the records. In debug mode it showing in the header level. but it not changing the body records. give some soln.
Thanks,
gowrihi,
chk the code below:
loop at itab.
modify itab index sy-tabix.
endloop.
regards,
Navneeth K. -
Internal table value checking in custom table using SQL...
I have a table which has following fields:
X1 TABLE (ZCONfig custom table)
LIFNR land1
123 br
234 br
456 br
567 Gr
and
X2 TABLE: (Internal table)
LIFNR:
234
567
123
Now I want to see if all the field values of LIFNR in internal table X2 (X2-LIFNR) are present in X1 or not.
Raise error if it is not.
How do I do this using SQL ? I guess I have to use read statement.
Please help. Points will be awarded.
Thanks.
RegardsHi Tushar,
1 Ya u are right , we need to use READ statement.
2. Populate X1 (all records)
in an internal table.
3. Then Loop at X2
and compare with X1.
( u can also keep an extra field in X2
of type c, so that if a record is found,
mark it as X )
4. try this code (just copy paste)
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
present TYPE c,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = 'X000'.
APPEND itab.
SELECT * FROM t001 INTO TABLE t001.
LOOP AT itab.
READ TABLE t001 with key bukrs = itab-bukrs.
IF sy-subrc = 0.
itab-present = 'X'.
MODIFY itab.
ENDIF.
ENDLOOP.
BREAK-POINT.
regards,
amit m.
Message was edited by: Amit Mittal -
Division of internal table records
Dear all
How can I observe that how many record my internal table got record and how can I divide into by lines
for ex.
SELECT SINGLE pvprs FROM ckmlcr INTO sum_pvprs-pvprs
WHERE poper EQ s_poper AND
kalnr = itab2-kalnr AND
bdatj = itab2-bdatj AND
curtp = itab2-curtp.
IF sy-subrc = 0.
APPEND sum_pvprs.
I want to get arithmetic range of this sum_pvprs-pvprs
Actually I want to get number of lines and their summations
pvprs1= 10 pvprs=20 pvprs=30 and then
after I got this results 102030 = 60 /3 =20 I need this operation.
All the best
Message was edited by: yusuf tunay çilesizI am not sure what do you mean by arithmetic range...if you mean min and max numbers you can use the below logic.
SELECT SINGLE pvprs FROM ckmlcr INTO sum_pvprs-pvprs
WHERE poper EQ s_poper AND
kalnr = itab2-kalnr AND
bdatj = itab2-bdatj AND
curtp = itab2-curtp.
IF sy-subrc = 0.
APPEND sum_pvprs.
1. you can simply sort the sum_pvprs internal table...on pvprs first ascending and than descending to get the min and max numbers by reading the first record of the internal table.
REad table sum_pvprs index 1.
2. you can have two variables lmin and lmax and initialise the same before you append statement.
if sum_pvprs-pvprs > lmax.
lmax = sum_pvprs-pvprs.
endif.
if sum_pvprs-pvprs < lmin.
lmin = sum_pvprs-pvprs.
endif.
<u><b>Sum and Average.</b></u>
SELECT SINGLE pvprs FROM ckmlcr INTO sum_pvprs-pvprs
WHERE poper EQ s_poper AND
kalnr = itab2-kalnr AND
bdatj = itab2-bdatj AND
curtp = itab2-curtp.
IF sy-subrc = 0.
<b>l_sum = sum_pvprs-pvprs + l_sum.</b>
APPEND sum_pvprs.
ENDSELECT.
<b>DESCRIBE TABLE sum_pvprs LINES lrec.
lavg = l_sum / lrec.</b>
Message was edited by: Anurag Bankley
Maybe you are looking for
-
i get a prompt to update firefox and i do then when i try to start firefox i am unable to. i have back-up my computer to previous date and the uninstall and re-install firefox to find the same prompt for updates from firefox and i cant ignore it so i
-
My macbook doesnt open some pages?
Hey there! I have a really big problem with my macbook pro 13 inch 2012. It is really new, it just came three days before, My wi-fi connection is fine and others PCs work normaly with this wifi network, but my macbook doesnt open some pages, specialy
-
Help need in drag drop operation in AIR application
I would like to know if there is a way to drag and drop an attachment file from an desktop mail client application(similar to MSoutlook) into an AIR application and make it accessible to the AIR application. I did experiments with this the drag oper
-
X220 - Thinkvantage button (restore original hard drive)
Hello -- If I boot using the ThinkVantage button, there is an the option to restore the original hard drive. Will this also restore the preinstalled software (specifically, Norton antivirus)? Thanks.
-
Insufficient sockets BBC R3 on iTunes
I don't know whether it is that the BBC does not allocate enough sockets to iTunes for Radio 3 but I can now get a connection on less than 50% of my attempts to get the BBC R3 "High" service, advertised as 320K but outside the UK, in reality only a d