Selecting values into same internal table from 2 differrnt select statement
Hi Friends,
code :
types :
begin of ty_bsad,
augbl type bsad-augbl,
end of ty_bsad.
begin of ty_bsad1,
augbl type bsad-augbl,
belnr type bsad-belnr,
end of ty_bsad1.
select augbl
from bsad
into table it_bsad
where belnr = l_vbeln and
bukrs = l_bukrs and
kunnr = l_kunrg.
if sy-subrc = 0 .
select belnr
into table lt_bsad1
from bsad
for all entries in lt_bsad
where augbl = lt_bsad-augbl and
kunnr = l_kunnr and
burks = l_bukrs and
blart = 'xy'.
now my requiremnt is i need to get both the augbl and belnr in single internal table but not in differnrnt internal table.
how can i get it.
Regards,
Priyanka.
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:53 AM
HI.
No Need to create two internal table because your feyching values from same table BSAD with diffrent where condition.try this code.it s work.
select augbl
from bsad
into table it_bsad
where belnr = l_vbeln and
bukrs = l_bukrs and
kunnr = l_kunrg and
blart = 'xy'.
else Refer this code.
LOOP AT it_bill_data INTO wa_bill_data.
MOVE-CORRESPONDING wa_bill_data TO wa_final_data.
READ TABLE it_material_data INTO wa_material_data
WITH KEY matnr = wa_bill_data-matnr.
IF sy-subrc = 0.
wa_final_data-meins_mara = wa_material_data-meins.
ENDIF.
APPEND wa_final_data TO it_final_data.
ENDLOOP.
Regards.
Jay
Edited by: Jay on Jan 8, 2009 2:53 PM
Edited by: Jay on Jan 8, 2009 2:57 PM
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:56 AM
Similar Messages
-
Select data into deep internal table
Dear Experts.
I created a dynamiv deep internal table.
while selecting data , into the internal table it is giving a dump. saying that deep structure.
SELECT OBJTY OBJID ARBPL WERKS from crhd
INTO CORRESPONDING FIELDS OF TABLE <f_tab>
where WERKS = pr_werks.
I used the field catalog also.even same error is comming.
how to get data into deep internal table by select statement.
Please help me,
Regards,
RahulHI,
Try creating dynamic internal table like:
Field-symbols: <dyn_table> type standard table,
<dyn_wa> ,
<dyn_field>.
Data: dy_table type ref to data,
ifc type lvc_t_fcat ,
xfc type lvc_s_fcat ,
Count type i ,
Count1 type i ,
Index type i ,
dy_line type ref to data.
Data counter type i.
Data: line type string ,
List like table of line.
Data: idetails type abap_compdescr_tab,
xdetails type abap_compdescr .
Data: ref_table_des type ref to cl_abap_structdescr.
*Looping at field cat internal table to populate another field cat to be passed
* In method used below for creating final dynamic internal table
Loop at fieldcat into fieldcat1.
Clear xfc.
Xfc-fieldname = fieldcat1-fieldname.
Xfc-datatype = fieldcat1-datatype.
Xfc-intlen = fieldcat1-intlen.
Append xfc to ifc.
endloop.
Clear fieldcat1.
*Method called to create dynamic internal table on the basis of field catalog created above
Call method cl_alv_table_create=>create_dynamic_table
Exporting
it_fieldcatalog = ifc u201Cfield catalog appended above
Importing
ep_table = dy_table. u201CDynamic internal table which will be created
Assign dy_table->* to <dyn_table>.
*Create dynamic work area and assign to FS
Create data dy_line like line of <dyn_table>.
Assign dy_line->* to <dyn_wa>.
Then use this dynamic internal table created from above method
in the Select Query.
Hope it helps
Regards
Mansi -
To add the multiline data into an internal table from TextEdit
Hello Experts,
I have one requirement that I have to use the TextEdit field. and put the values into an internal table.
can you help me. with some sample code.
Thanks in Advance
KuldeepThe problem is solved by using the following code
DATA: data TYPE REF TO CL_HTMLB_TEXTEDIT.
Data itab1 type itab.
data ?= CL_HTMLB_MANAGER=>GET_DATA(
request = runtime->server->request
name = 'textEdit'
id = 'txt1'
data text type string.
IF data IS NOT INITIAL.
text = data->text.
ENDIF.
SPLIT text AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO
TABLE itab1.
Kuldeep -
Header data and item data into same internal table
Hi Experts,
I WANT TO KNOW THE LOGIC TO POPULATE HEADER DATA AND ITEM DATA INTO SAME INTERNAL TABLE AND AGAIN DOWNLOAD THE SAME TO EXCEL FILE .Output file should be displayed like this format
Header1 rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
Item1 : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Item2 : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Header2: rectyp ,hdnum ,sbank ,bankl ,accnr , paytp , crda ,iso.
Item1 : rectyp ,valut ,cknum ,amount,bankl,accnr,pdate,bnktc.
Thanks
Moderator message: Please do not use all upper case in the future.
Edited by: Thomas Zloch on May 12, 2010 3:10 PMHi,
for example we have 3 internal tables
1> it_header 2>it_items 3>it_final (which contains all the header and item fields)
once it_header it_items are filled
loop at it_items.
read table it_header with key xyz = it_item-xyz.
if sy-subrc = 0.
here move all the header fields to it_final like below.
it_final -xfield = it_header-xfield.
endif.
here move all the item fields to it_final like below.
it_final -yfield = it_item-yfield.
append it_final.
clear it_final.
endloop.
now header and item fileds will be fillled in it_item -
How to get records into two internal tables from 1 internal table?
VERME LGPLA
252.000 EA 300 0149A 410 0149
276.000 EA 300 0149A 410 0107
516.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
I have above records in my one internal table ITAB.
I want to divide these records in to two internal tables ITAB1 and ITAB2. and this is based on LGPLA and VERME.
If there is same LGPLA (last column) and different VERME (1st column) available, then it should append ITAB1
Otherwise it should append ITAB2.
ITAB1 should contain ,
516.000 EA 300 0149A 400 3013
ITAB2 should contain ,
252.000 EA 300 0149A 410 0149
276.000 EA 300 0149A 410 0107
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
528.000 EA 300 0149A 400 3013
I have tried with this code
Loop at itab .
IF lv_prev_lgpla = wa-lgpla and lv_prev_verme <> wa-verme.
APPEND wa TO itab1.
else.
APPEND wa TO itab2.
endif.
lv_prev_lgpla = wa-vlpla.
lv_prev_verme = wa-anfme.
Endloop.
But it contains,
516.000 EA 300 0149A 400 3013
in table ITAB2 which I dont want.
Points rewarded soon.
Regards,
RonnDear Ronny,
i am gining the solution below.But would request you to change your ITAB STRUCTURE LIKE THIS BEFORE USING THE CODE
VERME LGPLA
252.000 EA 300 0149A 0149 410
276.000 EA 300 0149A 0107 410
516.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
528.000 EA 300 0149A 3013 400
then do as follows.
SORT ITAB BY LGPLA VERME.
LOOP AT ITAB INTO WITAB.
W_INDEX = SY-TABIX.
here take all the abOve fields in temp fieds.
LW_VERME = WITAB-VERME..AND SO ON.
AT END OF LGPLA.
MOVE: all LW fields to work area of ITAB1
APPEND work area of ITAB1 TO ITAB1.
DELETE ITAB INDEX W_INDEX
ENDAT.
ENDLOOP.
Basically what u r doing here is thet u r using processing event.
So whenerv VERME changes this event will be triggered.
Just try this out...something like this only will be he logic.
Please let me know further -
Field-Symbols: How to retrieve data into an internal table from FS
Hello All,
I am working on field symbols.I have declared the field symbols as shown.
FIELD-SYMBOLS: <gt_pos_data> TYPE table,
<wa_pos_data> like <gt_pos_data>.
Data: Begin of itab occurs 0,
field1(5) type c,
field2(10)_type c,
end of itab.
The FS <gt_pos_data> has 100 fields but I need to move only two fields from this FS to my internal table itab.I am doing the following.
loop at <gt_pos_data> assigning <wa_pos_data>.
itab-field1 = <wa_pos_data>-field1.
itab-field2 = <wa_pos_data>-field2.
append itab.
clear itab.
endloop.
But it is giving me an error saying "<wa_pos_data> is a table without header line and therefore has no componet FIELD1".How to achieve this requirement?
Thanks in advance
Sandeep<wa_pos_data> should be defined LIKE LINE OF <gt_pos_data>, but it will still have no structure, so you need to assign a field symbol to the component as well.
FIELD-SYMBOLS: <gt_pos_data> TYPE table,
<wa_pos_data> like LINE OF <gt_pos_data>,
<field> type any.
Data: Begin of itab occurs 0,
field1(5) type c,
field2(10)_type c,
end of itab.
loop at <gt_pos_data> assigning <wa_pos_data>.
assign componet 'FIELD1' of structure <wa_pos_data> to <field>.
if sy-subrc = 0.
itab-field1 = <field>.
endif.
assign componet 'FIELD2' of structure <wa_pos_data> to <field>.
if sy-subrc = 0.
itab-field2 = <field>.
endif.
append itab.
clear itab.
endloop.
Regards,
Rich Heilman -
Get multiple selection data of Table into an internal table
Hi Guys,
I have a Table in my view layout and selected 'SelectionMode' as 'Multi' in the table properties.How to get the selected data into an internal table when rows selected on the table output.For example,I have a 10 rows in the table and selected only 5 rows,need to get these 5 rows into an internal table?
Regards
NandanaHi,
Here is some sample code. Please try this and let me know if you are still getting any errors.
DATA lo_nd_table_node TYPE REF TO if_wd_context_node.
DATA lo_el_table_node TYPE REF TO if_wd_context_element.
DATA ls_table_node TYPE wd_this->element_table_node.
DATA lt_table_node TYPE wd_this->elements_table_node.
DATA lt_table TYPE wdr_context_element_set.
lo_nd_table_node = wd_context->get_child_node( name = wd_this->wdctx_table_node ).
lt_table = lo_nd_table_node->get_selected_elements( including_lead_selection = abap_true ).
LOOP AT lt_table INTO lo_el_table_node.
lo_el_table_node->get_static_attributes(
IMPORTING
static_attributes = ls_table_node ).
APPEND ls_table_node TO lt_table_node.
CLEAR ls_table_node.
ENDLOOP.
lt_table_node contains the selected rows. -
How to fetch data from bseg based on 2 internal tables in 1 select query?
hi,
i have bukrs and belnr in one internal table and bukrs and vbeln in another internal table..now if i select from bseg twice using for all entries for fields bukrs vbeln and bukrs belnr twice in 2 select statements its fine..but since bseg is a huge table i want to use select only once..but the problem is that none of the belnrs in the one internal table will have vbeln in another internal table....ie if vbeln is selected from bseg based on belnr in 1 internal table non eof those vbeln will be equal to vbeln on another internal tables..in this scenario even if i take all data from two internal tables into 1 single internal table and then use for all entries on vbeln and belnr of that table ..but i think this will not work because and AND operator will not work because no record will satisfy both vbeln and belnr conditions..even if i use OR operator if the 1st condition satisfies the select clause will not enter into the second clause and all the records will not be fetched...Please help how should i tackle this..Hi vijaya,
no simple select statement solution so far.
As BSEG is a huge table you should try to get the full key values into another internal table first.
SAP avoids direct selections from BSEG.
Pleas consider the use of one of the secondary index tables first:
BSAD : Accounting: Secondary Index for Customers (Cleared Items)
BSAK : Accounting: Secondary Index for Vendors (Cleared Items)
BSAS : Accounting: Secondary Index for G/L Accounts (Cleared Item
BSEC : One-Time Account Data Document Segment
BSEG : Accounting Document Segment
BSID : Accounting: Secondary Index for Customers
BSIK : Accounting: Secondary Index for Vendors
BSIS : Accounting: Secondary Index for G/L Accounts
you may include
BKPF : Accounting Document Header
for restrictions about time and document type.
The last step is a FOR ALL ENTRIES selection from BSEG providing the full key values.
Although you may have even more selects, the overall performance will be much better.
Regards,
Clemens -
Best way to read a CSV file into an internal table
Hi,
I have a comma seprated file, which I need to read into an internal table, and be able to look at particular values - basically looping round and populating BDC fields. Whats the easiest way of doing this?The easiest way would be to define a flat interal table.
Data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
Then call the function module GUI_UPLOAD to get the data into your internal table from the file on the frontend. I assume that you know how to use this function module. You could also use the method GUI_UPLOAD of the class CL_GUI_FRONTEND_SERVICES.
For example, say you have a comman delimited file with materail number, plant, quantity in it.
4000001,0004,1.00
4000002,0006,2.00
Define another internal table to hold the data.
Data: begin of itab2 occurs 0,
matnr type mara-matnr
werks type marc-werks
quant(10) type c.
end of itab2.
Then loop at the internal table(ITAB) and use the split statement to split it up into the appropriate fields of the other interal table(ITAB2).
Loop at itab.
clear itab2.
split itab-rec at ',' into itab2-matnr
itab2-werks
itab2-quant.
append itab2.
endloop.
That's it.
Regards,
Rich Heilman
Message was edited by: Rich Heilman -
How to check a field value within an Internal table
Hi Friends,
My requirement is:
I have a line item of PO records, in that each line item of Plant field should not diffe with other line items. If it differs or say the records have different plant values line items, then I have to throw an error message.
Below example for better understanding.
lineitem Plant
010 ABC
020 ABC
030 XYZ
040 LKG
So, my report will throw an error like "All line items must be identical'.
How to do proceed it.Please advise.
Thanks & Regards
Sankar.Hi Sankar
first you need to fetch all the values in one internal table from your PO.
After that create an internal table with only plant field and move all the plan values in this table.
let assume ITAB is a table with all the values. and ITAB1 with plant only.
wa_itab is the work area for ITAB and wa_itab1 is WA for ITAB1.
ITAB has all the values and ITAB1 has all the values only for plant.
delete adjacent duplicate from itab1 compairing plant.
loop at itab1 into wa_itab1. " this will fetch all the plant values in workarea.
read table itab into wa_itab where wa_itab-plant = wa_itab1-plant. " this will fetch only the values matching to the table itab1
if su-subrc <> 0.
message 'plants are not similar' TYPE 'E'.
elseif sy-subrc = 0.
write your code*.
endif.
endloop.
hope this will help you.
Thanks
Lalit Gupta -
How to select the data from a Maintainance View into an internal table
Hi All,
Can anybody tell me how to select the data from a Maintainance View into an internal table.
Thanks,
srinivas.HI,
You can not retrieve data from A mentenance view.
For detail check this link,
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
Regards,
Anirban -
How to do a SELECT from different tables into an internal table?
How to do a SELECT from different tables into an internal table?
I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
REPORT zinternal_table.
TABLES:
mara,
marc,
zperson.
TYPES:
BEGIN OF str_table1,
v_name LIKE zperson-zname,
v_matnr LIKE marc-matnr,
v_emarc LIKE marc-emarc,
v_werks_d LIKE marc-werks_d,
v_dstat LIKE marc-dstat,
END OF str_table,
i_table1 TYPE STANDARD TABLE OF str_table1.
DATA:
BEGIN OF str_table2,
v_mandt LIKE mara-mandt,
v_ernam LIKE mara-ernam,
v_laeda LIKE mara-laeda,
END OF str_table2,
itab_final LIKE STANDARD TABLE OF str_table2.first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
then for all the entries in that internal table retrieve data from zperson into another internal table.
then loop at one internal table
read another internal table where key equals in both the tables.
finally assign fileds if sy-subrc = 0.
gs_finaltable-matnr = gs_table-matnr
etc...
and finally append gs_finaltable to gt_finaltable.
there u go ur final table has all the data u want.
regards
Edited by: BrightSide on Apr 2, 2009 3:49 PM -
Selecting from multiple tables, into one internal table
Hi,
What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
Thanks,
John
Points will be rewarded and all responses will be highly appreciated.I have simple example :
First one - Join 5 tables
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 4 or 5 tables join.
get run time field f2.
f3 = f2 - f1 ( Total time).
Second one - joins 3 table and use for all entries
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 3 tables join and use for all entries
get run time field f2.
f3 = f2 - f1. ( Total time )
Finally you can have time diffrence between the both sql statement. -
Copy a certain row of data into the next row in a same internal table ??
HI, guys.
May i know how to copy a certain row of data into the next row in a same internal table ?? Bcz I plan to update a certain colum of data in the row just now into another value..
For example:-
*at first...
ebeln1 ebelp1 xblnr1
ebeln2 ebelp2 xblnr2
ebeln3 ebelp3 xblnr3
*after that, become...
ebeln1 ebelp1 xblnr1
ebeln2 ebelp2 xblnr2
ebeln2 ebelp2 xblnr4
ebeln2 ebelp2 xblnr5
ebeln3 ebelp3 xblnr3
Thanks in advance.hi,
If you have this kind of requirement then you must be having 2 internal tables ,one existing data and 2nd from which you have to insert the records into 1st table.
so in this case,
loop at itab1.
v_index = sy-tabix.
loop at itab2 into wa where pri_key = itab1-pri_key.
v_index = v_index + 1.
insert wa into itab index v_index.
endloop.
endloop.
Using this code ,your data records similar to your 1st tables primary key records will get inserted into table. -
How to read data in correct format from EXCEL file into an internal table??
Hi Experts,
My requirement is to upload data from an excel file on presentation server into an internal table on <b>SRM</b> server.
I used 'GUI_UPLOAD' function module to achieve the same but all the the data is getting uploaded in # only.I had set in the 'HAS_FIELD_SEPARATOR' to 'X' to overcome this problem.
But all the efforts are in vain. The function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' doesn't exist on SRM Server and I am not getting any other function module having similar functionality available on SRM server.
I have written the following code:-
TYPES: BEGIN OF ty_addr_loc,
userid TYPE xubname, "User Id
addr_code TYPE char4, "3 Digit Site Location Code/4 Digit
"Alternate Address
loc_id TYPE bbp_location, "Indicator: Address is standard address
END OF ty_addr_loc.
*Retrieving file name
parameters: p_file type rlgrap-filename.
DATA:
Local variable holding file name
l_file TYPE string,
Local Variable holding the file type,
l_type TYPE filetype VALUE 'ASC',
Local Variable holding the field separator
l_sep TYPE char01,
i_tab type standard table of ty_addr_loc.
Clearing local variables
CLEAR:
l_file,
l_sep.
Initializing the local variables
MOVE p_file TO l_file.
l_sep = 'X'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
filetype = l_type
has_field_separator = l_sep
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = i_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
Throwing an information message
MESSAGE i003. "Data Upload Failed
LEAVE LIST-PROCESSING.
ENDIF.
Please tell me a way out. I have to make a delivery urgently.
Thanks in advance,
Swati GuptaHi
Try the FM <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b>
Sample:
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
exporting
filename = i_filename
i_begin_col = l_begin_col
i_begin_row = l_begin_row
i_end_col = l_end_col
i_end_row = l_end_row
tables
intern = xt_intern
exceptions
INCONSISTENT_PARAMETERS = 201
UPLOAD_OLE = 201.
if sy-subrc <> 0.
e_subrc = sy-subrc.
exit.
endif.
<b>reward if Helpful.</b>
Maybe you are looking for
-
AR Aging Open Items Issue in BW
Hi Experts, We have activated 0FI_GL_4 data source and using the DSO ZFIGL_O2 (Copy of 0FIGL_O2) for data staging then load the data into custom cube ZFIAR_C01. The issue is when the AR document open in the ECC sometimes it is cleared right away or s
-
How to get the link in the body of the email
Hi, I have a requirement to send a link (which is of 3 lines) in the text of an email. I use the FM "SO_OBJECT_SEND" to send the email. I have maintained the text of the email in a standard text through SO10. the url comes as part of the text in stan
-
Print Service: Apple vs. MyPublisher
Anyone has experience with both services? With MyPublisher, you can download a plugin that forces iPhoto to send the completed book order to MyPublisher.com. Any experiences with quality differences. What about prices? Etc.? Thanks! - GD
-
Fails to load Quicktime plug in 7.41.
I keep getting the below error when trying to look at various movie clips. My mac will sometimes go to windows player but it will not play anything using quicktime. Any ideas ? The page "Apple - MacBook Air - Guided Tour - Small" attempted to load an
-
Where can i download the IOS for apple TV
I need to download the latest IOS for my apple TV, I have 3rd generation device