Select entries present in an internal table using a range of key values
Hi guys,
I have an internal table tb_bseg.
It contains the vendor code (lifnr), document number (belnr) and other fields.
How can I select values so that it may follow my (lifnr) range values in the selection screen?
SELECT belnr lifnr gsber mwskz hwbas wrbtr anln1 aufnr prctr projk nplnr kostl FROM bseg INTO TABLE tb_bseg
WHERE bukrs = pa_bukrs
AND belnr = tb_bkpf-belnr
AND gjahr = tb_bkpf-gjahr.
AND lifnr IN cd_lifnr. ??? can I use something like this?
Please guide me regarding this.
Best regards,
Reymar
Hi Reymar,
You are right . You can use that way. So your select query will be
SELECT belnr lifnr gsber mwskz hwbas wrbtr anln1 aufnr prctr projk nplnr kostl FROM bseg INTO TABLE tb_bseg
WHERE bukrs = pa_bukrs
AND belnr = tb_bkpf-belnr
AND gjahr = tb_bkpf-gjahr
AND lifnr IN cd_lifnr.
where cd_lifnr is the selection screen field.
declare it as
SELECT-OPTIONS :
CD_LIFNR FOR BSEG-LIFNR.
Regards,
Swapna.
Edited by: NagaSwapna Thota on Sep 4, 2008 5:19 PM
Similar Messages
-
Filtering internal table using select-option values
Hi,
I got an internal table with select-option values. for eg. it_perno with the values I BT 000160 000170.
Now i got another second internal table which is have the person number. Now i need to filter this second internal table based on the values from the select option table. my question is
i can collect all the values from 160 to 170 in a separate table by looping over the select option table. and then based on the values filter the second internal table person number.
But what would be the case if the select option contains both intervals and multiple options. For eg.
I BT 000160 000170.
I EQ 000185.
So can you suggest any good solution, that based on this select option table i need to filter the second internal table Person number.
Thanks in advance.
Regards,
anbu.Hi,
Can you not use the select-options in the Select query while populating the internal table.
SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.
If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:
LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.
Regards,
Aparna Alashe. -
How to join THREE different tables into internal table using one select statement .
How to join THREE different tables into internal table using one select statement .
Hi experts,
I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
Scenario:
Database tables:
SPFLI
SFLIGHT
SBOOK.
Table Fields:
SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
SEATSOCC_C SEATSMAX_F SEATSOCC_F
SBOOK - CARRID CONNID CLASS
MY INTERNAL TABLE IS IT_XX.
Your help much appreciated.
Thanks in advance.
Pawan.Hi Pawan,
please check below codes. hope it can help you.
TYPES: BEGIN OF ty_xx,
carrid TYPE spfli-carrid ,
connid TYPE spfli-connid ,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom ,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto ,
fldate TYPE sflight-fldate ,
seatsmax TYPE sflight-seatsmax ,
seatsocc TYPE sflight-seatsocc ,
seatsmax_b TYPE sflight-seatsmax_b,
seatsocc_b TYPE sflight-seatsocc_b,
seatsmax_f TYPE sflight-seatsmax_f,
seatsocc_f TYPE sflight-seatsocc_f,
class TYPE sbook-class,
END OF ty_xx,
t_xx TYPE STANDARD TABLE OF ty_xx.
DATA: it_xx TYPE t_xx.
SELECT spfli~carrid
spfli~connid
spfli~countryfr
spfli~cityfrom
spfli~countryto
spfli~cityto
sflight~fldate
sflight~seatsmax
sflight~seatsocc
sflight~seatsmax_b
sflight~seatsocc_b
sflight~seatsmax_f
sflight~seatsocc_f
sbook~class
INTO TABLE it_xx
FROM spfli INNER JOIN sflight
ON spfli~carrid = sflight~carrid
AND spfli~connid = sflight~connid
INNER JOIN sbook
ON spfli~carrid = sbook~carrid
AND spfli~connid = sbook~connid.
Thanks,
Yawa -
Get Multiple Rows into internal Table using Webdynpro Alv Display ..
Hi guys ,
I need to find out the logic for getting all the selected rows into the internal table.
When i display the ALV Output on webdypro screen .
USer Selects multiple rows for further processing ..
Ineed to get all the rows selected by user into an internal table .
Please let me know how to achive this ...
Thanks in advance for quick reply
Regards
Saurabh GoelHi,
You need to use the method GET_SELECTED of IF_WD_CONTEXT_NODE to get the rows selected. Also ccheck for the paramters of that method, this retruns the element set.
This meets your requirement.
Regards,
Lekha. -
How to Upload Excel sheet in DB or internal table using SAP NetWeaver ABAP
Dear All experts,
Pls provide guidance to Upload Excel sheet in DB or internal table using ABAP in ( SAP NetWeaver stack )
Regards
Machindra
Edited by: Machindra Patade on Apr 8, 2010 3:07 PMPlease search before posting.
Thread locked.
Thomas -
How to extract data from info cube into an internal table using ABAP code
HI
Can Anyone plz suggest me
How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
Thankx in advance
regds
AJAYHI Dinesh,
Thankq for ur reply
but i ahve already tried to use the function module.
When I try to Use the function module RSDRI_INFOPOV_READ
I get an information message "ERROR GENERATION TEST FRAME".
can U plz tell me what could be the problem
Bye
AJAY -
Delete row from internal table using field symbol.
Hi friends,
I created dynamic internal table using field symbol. I want to delete some data using where clause.
for example. i want to use like,
DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
Like the above statment it won't work. How i can use delete with where clause in field symbols.
Hope any one can help me.
Thanks and regards
Srikanth. Shi Srikanth,
I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
LOOP at <itab> INTO <wa>.
ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
CHECK <field> IS ASSIGNED.
IF <field> EQ WA_KNA1-KUNNR.
DELETE ...
ENDIF.
UNASSIGN <field>.
ENDLOOP.
hope this helps
ec -
Internal table used by sap in a program
Hi,
I want to know the list of internal tables used in a program (including sap program).
while debugging i want to view the data stored in it.
I know the internal tables used by me. Before loading the program sap will load some information into internal table. How to know that.
Advance Thanks.Internal tables, not transparent ones.
In the old debugger, goto->system areas->internal information and look ITAB_HEADS. This will show you the name of the tables in the system. SYMBDATANM will show you all variables in memory.
In the new debugger, it's even easier. There's a global tab in the variables area, that tells you all variables in memory. And you can see the variable type - i.e. if it is a table.
matt -
Final Internal Table used in MIGO Transaction
Hi Experts,
I need to know the final internal table used in the MIGO transaction. Why I want to know this is, I need all the records which are there in the table control (GODYNPRO) of the MIGO transaction. I have used the BADI BADI MB_MIGO_BADI to read the values. But since it is a table control the values are getting changed when the user scrolls down the table control. How can I get all the values shown in this table control. Is there any global internal table in the SAPLMIGO program?
BR.Hi ABAP,
Check the BADI MB_MIGO_BADI the example class CL_EXM_IM_MB_MIGO_BADI
In attributes tab variable GT_EXTDATA contains all migo positions.
Read the internal table to check items.
in this method the internal table is filled.
Therefore define your internal table in the class attributes.
I hope you help. -
Filtering records from one internal table based on ranges in another itab
Hi guys,
I have 1 internal table with set of GL accounts. I have 2nd internal table where lower interval and upper interval of GL accounts
How to filter out records from 1 internal table by comparing with the GL account ranges present in 2nd internal table.
Please reply.Hi
Create a RANGE for GL Accounts.
LOOP the second Internal Table.
And assign HIGH & LOW to ranges from second ITAB.
And Delete the accounts which are not there in the range.
Use the below code as reference.
DATA: itab TYPE TABLE OF mara WITH HEADER LINE.
DATA: r_matnr TYPE RANGE OF matnr WITH HEADER LINE.
SELECT * FROM mara INTO TABLE itab UP TO 10 ROWS.
r_matnr-sign = 'I'.
r_matnr-option = 'BT'.
r_matnr-low = '000000000016900036'.
r_matnr-high = '000000000016900040'.
APPEND r_matnr.
DELETE itab WHERE matnr NOT IN r_matnr. -
Populating Empty Fields for Existing Internal Table Using For All Entries
I have an internal table called itab_extract that populates without any issues in SELECT A and SELECT B below. Trying to avoid looping, I am using select DB table 'for all entries' in itab_extract. I want the empty fields in itab_extract to populate from the values in the database. However, about 200,000 entries are being appended to the table, and, the values that existed for the already populated fields in itab_extract are gone, and the new fields are populated.
I've played with the syntax and cannot seem to get it to work. My next option is a time consuming loop.
How should the for all entries syntax look to accomplish filling the empty fields in the itab? Thank-You
*read ekko
select ebeln lifnr aedat bsart from ekko *SELECT A*
into CORRESPONDING FIELDS OF TABLE me->itab_extract
where aedat in r_aedat.
select ebeln lifnr aedat BSART from ekko *SELECT B*
appending CORRESPONDING FIELDS OF TABLE me->itab_extract
where aedat in S_DATE2 AND
BSART IN S_BSART.
select ebelp werks matnr *SELECT C*
into CORRESPONDING FIELDS OF TABLE itab_extract
from ekpo
FOR ALL ENTRIES IN itab_extract
where ebeln = itab_extract-ebeln.Hi Tom,
This SQL statement will be time consuming, Do not use a loop.
There are two options.
1. Select EKKO and EKPO details based on standard SAP view. (You can type EKKO in se11 view to find the correct view).
also use one range table populate r_aedat and s_date2 in the same. So you where condition will have r_newrange and
s_bsart. Also do not use into corresponding fields, it is not a good idea. It will increase your performance. Maintain the proper
sequence (Based on database structure of EKKO and EKPO)
2. If you are keen to use for all entries, then first select ekko then after your sy-subrc check get the data from EKPO.
Should be like this.
select ebeln bsart aedat lifnr from ekko into table gt_ekko where aedat in r_newrange and bsart in s_bsart.
if sy-subrc eq 0.
sort gt_ekko by ebeln ascending.
select ebeln ebelp werks matnr into table gt_ekpo for all entries in gt_ekko where ebeln eq gt_ekko-ebeln.
endif.
Hope it helps,
Best Regards,
Tapodipta Khan. -
How to select columns from internal table using 'GUI_DOWNLOAD' ?
Hi,
i am running a report & the fields for output is saved in an internal table which has as many as 10 fields. But I want to select only a few fields for output. There is a option COL_SELECT in function 'GUI_DOWNLOAD'. How to use it. If possible with example.Hai VijayKumar
Try with the following code
tables : mara.
data : begin of it_mara occurs 0,
matnr like mara-matnr,
mbrsh like mara-mbrsh,
mtart like mara-mtart,
meins like mara-meins,
end of it_mara.
parameters : P_mtart like mara-mtart default 'ROH'.
start-of-selection.
perform select_data.
perform download_data.
*& Form select_data
text
--> p1 text
<-- p2 text
FORM select_data .
select
matnr
mbrsh
mtart
meins
from mara into table it_mara
where mtart = p_mtart.
ENDFORM. " select_data
*& Form download_data
text
--> p1 text
<-- p2 text
FORM download_data .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'c:\down.txt'
FILETYPE = 'ASC'
COL_SELECT = 'X'
COL_SELECT_MASK = 'X XX'
TABLES
DATA_TAB = it_mara.
IF SY-SUBRC = 0.
SORT IT_MARA BY MATNR.
ENDIF.
ENDFORM. " download_data
Thanks & Regards
Sreenivasulu P -
Performance Problems with "For all Entries" and a big internal table
We have big Performance Problems with following Statement:
SELECT * FROM zeedmt_zmon INTO TABLE gt_zmon_help
FOR ALL ENTRIES IN gt_zmon_help
WHERE
status = 'IAI200' AND
logdat IN gs_dat AND
ztrack = gt_zmon_help-ztrack.
In the internal table gt_zmon_help are over 1000000 entries.
Anyone an Idea how to improve the Performance?
Thank you!>
Matthias Weisensel wrote:
> We have big Performance Problems with following Statement:
>
>
SELECT * FROM zeedmt_zmon INTO TABLE gt_zmon_help
> FOR ALL ENTRIES IN gt_zmon_help
> WHERE
> status = 'IAI200' AND
> logdat IN gs_dat AND
> ztrack = gt_zmon_help-ztrack.
>
> In the internal table gt_zmon_help are over 1000000 entries.
> Anyone an Idea how to improve the Performance?
>
> Thank you!
You can't expect miracles. With over a million entries in your itab any select is going to take a bit of time. Do you really need all these records in the itab? How many records is the select bringing back? I'm assuming that you have got and are using indexes on your ZEEDMT_ZMON table.
In this situation, I'd first of all try to think of another way of running the query and restricting the amount of data, but if this were not possible I'd just run it in the background and accept that it is going to take a long time. -
Saving .csv into internal table - using dataset (',' comes between data)
Hi experts,
I need to save .csv from application server to internal table.
i am using the below code.
gt_raw and gwa_raw are dxrawdata format.
OPEN DATASET gv_pfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
IF sy-subrc NE 0.
WRITE:/ 'FILE UPLOAD FAILED - ERROR NO. : ', sy-subrc.
EXIT.
ELSE.
DO.
READ DATASET gv_pfile INTO gwa_raw.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND gwa_raw TO gt_raw.
CLEAR gwa_raw.
ENDIF.
ENDDO.
*--Close the Application server file (Mandatory).
CLOSE DATASET gv_pfile.
ENDIF.
DELETE DATASET gv_pfile.
LOOP AT gt_raw into gwa_raw.
IF SY-TABIX > 1.
SPLIT gwa_raw at ',' into gwa_cust-cust_code
gwa_cust-cust_name
gwa_cust-grp_name
APPEND gwa_cust TO gt_cust.
CLEAR: gwa_cust, gwa_raw.
ENDIF.
ENDLOOP.
My program works fine.
But when the gwa_cust-grp_name contains the value for eg. -> panasonic co., ltd.
it takes till panasonic co., only
and leaves ltd. as i am using SPLIT command.
is there any other way to do this.
plz help me to solve this issue.
thanks.Hi,
I notice you have marked the message as answered, but I just wanted to let you know there is a solution. The trick is to parse into an internal table and then to find and reassemble fields that were split because they contgain a comma. The ABAP program below is a commented example.
Rgds,
Mark
REPORT zcsv_parse.
DATA:
tokens TYPE i.
TYPES: BEGIN OF ty_result,
company TYPE char20,
compnr TYPE i,
city TYPE char30,
country TYPE char30,
END OF ty_result.
DATA:
gt_rawtab TYPE TABLE OF string,
gw_rawtab LIKE LINE OF gt_rawtab,
gt_result TYPE TABLE OF ty_result,
gw_result LIKE LINE OF gt_result,
gt_parse TYPE TABLE OF string,
gw_parse LIKE LINE OF gt_parse.
DEFINE %csvline.
gw_rawtab = &1.
append gw_rawtab to gt_rawtab.
END-OF-DEFINITION.
START-OF-SELECTION.
* Create CSV lines, some with a comma inside a token
%csvline '"CompanyOne NV",500,"Antwerp","Belgium"'.
%csvline '"CompanyTwo,Inc",600,"New York,NY","USA"'.
%csvline '"CompanyThree,Ltd",700,"Sydney,NSW","Australia"'.
* Parse the raw CSV
LOOP AT gt_rawtab INTO gw_rawtab.
REFRESH gt_parse.
SPLIT gw_rawtab AT ',' INTO TABLE gt_parse.
DESCRIBE TABLE gt_parse LINES tokens.
* If extra commas: token count higher than field count
IF tokens > 4.
PERFORM reassemble.
ENDIF.
* At this point each entry in GT_PARSE contains exactly
* one result field => build the result table
LOOP AT gt_parse INTO gw_parse.
* Strip quotes from text fields
REPLACE ALL OCCURRENCES OF '"' IN gw_parse WITH ''.
CASE sy-tabix.
WHEN 1. gw_result-company = gw_parse.
WHEN 2. gw_result-compnr = gw_parse.
WHEN 3. gw_result-city = gw_parse.
WHEN 4. gw_result-country = gw_parse.
ENDCASE.
ENDLOOP.
APPEND gw_result TO gt_result.
ENDLOOP.
* Show the formatted result
LOOP AT gt_result INTO gw_result.
WRITE: / gw_result-company, gw_result-compnr,
gw_result-city, gw_result-country.
ENDLOOP.
*& Form reassemble
* Merges tokens that were split because they contain a comma
FORM reassemble.
DATA: lastpos TYPE i,
lastchar TYPE c,
currtoken LIKE sy-tabix,
nexttoken LIKE sy-tabix,
gw_next LIKE gw_parse.
LOOP AT gt_parse INTO gw_parse.
lastpos = STRLEN( gw_parse ) - 1.
lastchar = gw_parse+lastpos(1).
* Token starts with quote but does not end with one =>
* must merge with the next token
IF gw_parse+0(1) = '"' AND lastchar <> '"'.
currtoken = sy-tabix.
nexttoken = sy-tabix + 1.
READ TABLE gt_parse INTO gw_next INDEX nexttoken.
CONCATENATE gw_parse gw_next INTO gw_parse SEPARATED BY ','.
MODIFY gt_parse FROM gw_parse INDEX currtoken.
DELETE gt_parse INDEX nexttoken.
ENDIF.
ENDLOOP.
ENDFORM. "reassemble -
Select statement not populating the internal table
Hi,
I have a requirement where I have to upload a file from C drive, the fields in this file are VBELN, description & date of creation.
I am able to get this file into the internal table. After this i need to cross check the VBELN against VBRK-VBELN, if present then update a Z-table.... How do I do the cross check part ?...
if not tw_zvatcn[] is initial,
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
Internal table tw_vbrk is coming blank, which is not correct because I see the data in db tbl VBRKIs p_vkorg a parameter or select option.
If it is parameter and is blank you will not get data in the table.
In that case make a condition for that field also.
if not tw_zvatcn[] is initial.
if p_vkorg is not initial.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
else.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
endif.
Maybe you are looking for
-
Problem in GR/IR account at MIRO time
Hi all when we are doing MIRO for Non GR based PO in non local currency( foreign currency) The GR/IR account value is displaying correctly in Local currency but it is showing GR/IR account as Debit and with huge values. Because of this F.13 Clearing
-
How can I re-synchronize my photo collection on iPhoto FROM iPad TO iMac?
Due to a config problem I´ve lost all my pictures on my iMac. But I have them all - luckily - on my iPad. But how can I get the collection back onto my iMac? Synchronizing via iTunes doesn´t work.....
-
Transferring movies from dvd or high8 tapes
Here is what I want to do: I want to make a DVD with a slide show (from picures in iPhoto) and then also have some movie clips that I took years ago of my dog . The original movies are on high8 tapes but play in my sonydigital camcorder. I have succe
-
Our Document Control person catalogs documents in a form I've created. We are a spice manufacturer (ahhhh, but alas, I can't smell them anymore while here! ) In one text area on the form she lists associated items, for example PL-1234 is a pallet la
-
I need to find a way to duplicate zones. For example, I create a zone, harden it and make some other changes. After that, I want to duplicate this zone with different zone name and IP addresss. How I can do that?