Select statment - fill internal table
Hi,
I have following situation:
TYPES: BEGIN OF q_data,
i_lqua LIKE lqua,
v_xxx(20) type c,
END OF q_data.
DATA: a_data TYPE STANDARD TABLE OF q_data.
Now I would write a select statment and fill the table a_data.
select lqua~matnr lqua~werks... from lqua inner join mch1 into (i_lqua-matnr, i_lqua-werks.....)...
Is it possible to write a statement without writing the whole structure (all the names of columns) of lqua in the SQL-statement (lquamatnr lquawerks lqua~........)?
Thanks
Michael
1. you can write that but i think you have to write that in SELECT ...ENDSELECT.
select lquamatnr lquawerks... from lqua inner join mch1 into (i_lqua-matnr, i_lqua-werks.....
append i_lqua.
endselect.
2. OR you can use INTO CORRESPONDING FIELDS OF TABLE
select lquamatnr lquawerks... from lqua inner join mch1 into corresponding fields of table i_lqua.
Similar Messages
-
How to fill internal table with selection screen field.
Hi all,
i am new to sap . pls tell me how to fill internal table with selection screen field.Hi,
Please see the example below:-
I have used both select-options and parameter on the selection-screen.
Understand the same.
* type declaration
TYPES: BEGIN OF t_matnr,
matnr TYPE matnr,
END OF t_matnr,
BEGIN OF t_vbeln,
vbeln TYPE vbeln,
END OF t_vbeln.
* internal table declaration
DATA : it_mara TYPE STANDARD TABLE OF t_matnr,
it_vbeln TYPE STANDARD TABLE OF t_vbeln.
* workarea declaration
DATA : wa_mara TYPE t_matnr,
wa_vbeln TYPE t_vbeln.
* selection-screen field
SELECTION-SCREEN: BEGIN OF BLOCK b1.
PARAMETERS : p_matnr TYPE matnr.
SELECT-OPTIONS : s_vbeln FOR wa_vbeln-vbeln.
SELECTION-SCREEN: END OF BLOCK b1.
START-OF-SELECTION.
* I am adding parameter value to my internal table
wa_mara-matnr = p_matnr.
APPEND wa_mara TO it_mara.
* I am adding select-options value to an internal table
LOOP AT s_vbeln.
wa_vbeln-vbeln = s_vbeln-low.
APPEND wa_vbeln TO it_vbeln.
ENDLOOP.
Regards,
Ankur Parab -
I realize that you can't do a select on an internal table but I need to do something identical to that. I need to replicate the following code:
SELECT * FROM it_detail INTO it_temp WHERE matnr = wa_detail-matnr.
it_detail is of type ty_detail which joins field from three different tables. Right now it_detail holds information about many different material numbers with all material numbers being repeated. I am attempting to fill it_temp with all entries from it_detail that has the same material type. I did a search but I couldn't find anything that seemed to work in this situation.
Regards,
Davis.You must READ it, or LOOP at it.
Loop at it_detail into wa_detail where matnr = p_matnr.
move-corresponding wa_detail to wa_temp.
append wa_temp t0 it_temp.
endloop.
Regards,
RIch Heilman -
Fill Internal Table for Table Header EQUI - Long Time
Good morning,
I have installed DMIS (2006_1_620) and DMIS_CNT (2006_1_620), both at the level of SP = 13.
I am running the subactivity "Fill Internal Table for Table Header EQUI" and have 1 day + 10 hours and continue working.
Also note that the table CNVTDMS_05_equi is increased million in millions and now has 6 million records.
It is normal to take a long time? (EQUI table has 240 million records and therefore will take many days).
Any suggestions?
Thanks,
HugoHello Hugo,
I know this is old , but did you ever find a solution to this. I am having the same problem. I considered adding an index to table QMIH, with Keys MANDT and BEQUI.
I also only have one bckgrd proc running in sender systems with this statement when I drill in using SM50:
SELECT
/*+
FIRST_ROWS (1)
FROM
"QMIH"
WHERE
"MANDT"=:A0 AND "BEQUI"=:A1 AND ROWNUM <=:A2 #
This has been running for over 8hrs now.
Any thoughts?
Thanks,
NICK -
Can we apply select statement on internal table.
can we apply select statement on internal table.if yes thrn let me know how to do.
Dear Sachin,
You cannot use SELECT statement on internal table.
If you want to select some rows from internal table you can LOOP the table or you can READ the table.
<u>Please check the following links for your kind reference:</u>
<b>http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
http://www.sap-img.com/ab009.htm
http://www.itsmarc.com/crs/Clas0302.htm
http://www.sapdevelopment.co.uk/tips/tips_itab.htm
http://searchsap.techtarget.com/search/1,293876,sid21,00.html?query=whatisinternaltable&bucket=ALL</b>
Cheers !
Moqeeth. -
Fill internal table with mutliple entries for nested structure
Dear ABAP Experts,
I have a question related to fill internal tables with nested structures.
I have a structure like this:
BEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
BEGIN OF kons,
kon TYPE YKONSEINHEIT,
END OF kons,
jahr TYPE CHAR04,
END OF proto.
Now I need to fill this structure with values (over an internal table), but how can I achieve that I save multiple datas für element "kon" für one single entry of structure "proto"?
An example could be:
sicht = '01'
version = '100'
kon = 1001 (first entry)
kon = 1002 (second entry)
usw... (n entry)
jahr = '2008'
Thanks in advance for every helpful answer.
Regards
ThomasBEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
kons TYPE STANDARD TABLE OF YKONSEINHEIT WITH NON-UNIQUE KEY TABLE_LINE,
jahr TYPE CHAR04,
END OF proto.
DATA: ls_proto TYPE proto,
lt_proto TYPE STANDARD TABLE OF proto,
ls_kon
ls_proto-sicht = '01'.
ls_proto-version = '100'
INSERT '1001' INTO TABLE ls_proto-kons.
INSERT '1002' INTO TABLE ls_proto-kons.
ls_proto-jahr = '2008'.
INSERT ls_proto INTO TABLE lt_proto
If you're going to use a more complicated inner table with several components, then you need to define a type for those components.
matt -
Passing SELECT-OPTIONS and Internal Tables to SUBROUTINES
Hi Guys
In the code below my colleague has created her own table types in order to pass a select option and internal tables to her subroutine. Is there an easier way of making them known to the subroutine.
data : v_vbeln type vbeln_vf,
it_bdoc type table of vbrp,
it_t006 type table of t006a,
wa_bdoc type vbrp,
wa_t006 type t006a,
it_bdoc2 type table of zsswathi_st_vbeln,
wa_bdoc2 type zsswathi_st_vbeln
select-options s_vbeln for v_vbeln matchcode object zswathi_vbeln obligatory.
start-of-selection.
perform bdoc using s_vbeln[]
changing it_bdoc
it_bdoc2
it_t006.
loop at it_bdoc2 into wa_bdoc2.
form bdoc using f_s_vbeln type ZSWATHI_ST_SELECT_OPTION_TA_TY " all these are table types. for select options, a structure is created and then a table type for it is created.
changing f_it_bdoc type zswathi_vbrp_ty_ta
f_it_bdoc2 type zswathi_vbeln_ty_ta
f_it_t006 type ZSWATHI_T006_TA_TY.
select * from vbrp into table f_it_bdoc where vbeln in f_s_vbeln.
if f_it_bdoc is not initial.
select vbeln sum( netwr ) prsdt from vbrp into table f_it_bdoc2 where vbeln in f_s_vbeln group by vbeln prsdt.
sort f_it_bdoc2 by vbeln.
"select * from t006a into table it_t006 for all entries in it_bdoc where msehi = it_bdoc-vrkme.
select * from t006a into table f_it_t006 for all entries in f_it_bdoc where msehi = f_it_bdoc-vrkme.
endif.
endform.Hi Brett,
1. you can use a select-options-range in a FORM subroutine also without passing it as a parameter because parameters and select-option range tables are global fields in their program.
2. If you need a parameter, declare it as type table or type standard table or type any table. You do not need any special table type.
Regards
Clemens -
How to fill internal table dynamically
Hi All,
how to fill internal table dynamically.
for example:
begin of itab occurs 0,
empid like pa0000-pernr,
empname like pa0001-ename,
grade(5),
end of itab.
now i want to append dynamically field itab-grade along with rest fields.
is this possible?? if yes kindly let me know how to do that.
Regards,
Kiran IHi kiran,
To fill and create and internal table dynamically you can use this code.
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
is_fieldcat-fieldname = 'FIELD1'.
is_fieldcat-ref_field = 'MATNR'.
is_fieldcat-ref_table = 'MARA'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD2'.
is_fieldcat-ref_field = 'SPRPS'.
is_fieldcat-ref_table = 'PA0001'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD3'.
is_fieldcat-ref_field = 'BEGDA'.
is_fieldcat-ref_table = 'PA0002'.
APPEND is_fieldcat TO it_fieldcat.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 40 times.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = 'X'.
ASSIGN COMPONENT 'FIELD3' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = '20030101'.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'field1' OF STRUCTURE <l_line> TO <l_field>.
WRITE / <l_line>.
ENDLOOP.
regards,
Aashish Garg -
How to Fill Internal Table with contents of Select-Option
Hi all:
There is a select-option s_matnr on the self-made screen. An internal table t_int is declared in the program. The requirement is that users makes selection with multiple material numbers. I want to put the values of s_matnr into internal table t_int directly. Would you please tell me how?
Thank you very much in advance.
Edited by: dongdong guo on Jun 13, 2008 3:40 AMHi,
Select option works like an internal table only.
For table selection you can use it directly using IN operator in where clause
eg : where matnr IN s_matnr.
Before that you may need to validate the content of the select-option. For that also you need to transfer the content to a new internal table.
u can loop at the select-option.
eq: loop at s_matnr.
if s_matnr-low = 'MAT1'.
condition.
endif.
endloop.
if you just want to check whether any single valid material number exist in your user screen, then u can use a select single option with s_matnr directly.
select single matnr from mara
where matnr in s_matnr.
select-option s_matnr behaves like an internal table with four fields.
sign, option, low, high. -
Select (join) into internal table with nested structures
Hello Experts,
i wonder about the correct notation of a select statement.
I have an internal table it_zoll including two structures as defined below.
The select is a join on the two tables zollp and zolls. As coded below the select is syntactically correct, but the fields
in the nested structures are not filled ....
Any ideas how to write the select statement ? (The internal table it_zoll must have the nested structures for other reasons ..)
Declaration:
TYPES: BEGIN OF ty_zollp,
belnr TYPE zollp-belnr,
werks TYPE zollp-werks,
gebnr TYPE zollp-gebnr,
END OF ty_zollp.
TYPES: BEGIN OF ty_zolls,
grnum type zolls-grnum,
werks type zolls-werks,
name1 TYPE zolls-name1,
END OF ty_zolls.
DATA: BEGIN OF wa_zoll.
DATA: zollp type ty_zollp.
DATA: zolls type ty_zolls.
DATA: END OF wa_zoll.
DATA: it_zoll LIKE TABLE OF wa_zoll.
Select:
SELECT
zollp~belnr zollp~werks zollp~gebnr
zolls~grnum zolls~werks zolls~name1
FROM zollp
JOIN zolls ON zolls~werks = zollp~werks
AND zolls~grnum = zollp~grnum
INTO CORRESPONDING FIELDS OF TABLE it_zoll
WHERE zollp~werks = werks
AND zollp~gebnr IN s-gebnr
AND ...
Thank you !DATA: BEGIN OF ty_zollp,
belnr TYPE zollp-belnr,
werks TYPE zollp-werks,
gebnr TYPE zollp-gebnr,
END OF ty_zollp.
DATA: BEGIN OF ty_zolls,
grnum type zolls-grnum,
werks type zolls-werks,
name1 TYPE zolls-name1,
END OF ty_zolls.
DATA: BEGIN OF wa_zoll.
Include structure ty_zollp.
Include structure ty_zolls.
DATA: END OF wa_zoll.
The above declaration had worked. Please try.
Regards,
Satish Kanteti -
Hello,
in my program i can't fill and send contents of my internal table. my code looks like this:
TABLES:
MKPF,
MSEG.
TYPES: BEGIN OF ST_2,
F_1 LIKE MKPF-MANDT, " For MKPF~MANDT,
F_2 LIKE MKPF-MBLNR, " For MKPF~MBLNR,
etc
F_18 LIKE MSEG-ZEILE, " For MSEG~ZEILE,
F_19 LIKE MSEG-LINE_ID, " For MSEG~LINE_ID,
etc
END OF ST_2.
DATA: it_1 TYPE TABLE OF ST_2,
wa_it LIKE LINE OF it_1.
FORM get_data.
SELECT
MKPF~MANDT
MKPF~MBLNR
*etc
MSEG~ZEILE
MSEG~LINE_ID
*etc
INTO wa_it
FROM
MKPF AS MKPF
INNER JOIN
MSEG AS MSEG
ON MKPFMANDT = MSEGMANDT AND
MKPFMBLNR = MSEGMBLNR AND
MKPFMJAHR = MSEGMJAHR
WHERE
MKPF~CPUDT >= '20060301' AND
MSEG~BUKRS = 'M' AND
MSEG~BWART IN ('601', '602').
ENDSELECT.
so, where should i put:
INSERT wa_it INTO TABLE it_1.
CLEAR wa_it.
to append my internal table with data?
please help me!!!!Hi,
i`ve made the necessary changes to your code :
SELECT MKPFMANDT MKPFMBLNR MSEGZEILE MSEGLINE_ID
INTO wa_it FROM MKPF AS MKPF INNER JOIN MSEG AS MSEG
ON MKPFMANDT = MSEGMANDT AND
MKPFMBLNR = MSEGMBLNR AND
MKPFMJAHR = MSEGMJAHR
WHERE
MKPF~CPUDT >= '20060301' AND
MSEG~BUKRS = 'M' AND
MSEG~BWART IN ('601', '602').
<b>
append wa_it to it_it.
clear wa_it.
</b>
ENDSELECT.
reward points if helpful.
Regards -
How to get all values in the range of select option into internal table?
Hi,
I need to capture all entries coming in the range of select option into one internal table.
How to do get that?
For E.g
select-options: matnr for mara-matnr.(select option)
IF I enter G0100013507892 as lower value of matnr and G0100014873947 as higher value
and if there are 10,000 materials in the above range, then I want to capture all theses 10000 materails in one internal table. How to do that?
Regards,
MrunalHello Mrunal Mhaskar ,
What i understand you can do one thing go in debug mode
Try this code : -
LOOP AT s_matnr_ex.
IF s_matnr_ex-low IS NOT INITIAL.
i_matnr-matnr = s_matnr_ex-low.
i_matnr-option = s_matnr_ex-option.
APPEND i_matnr.
CLEAR : i_matnr.
ENDIF.
ENDLOOP.
LOOP AT s_matnr_ex.
IF s_matnr_ex-high IS NOT INITIAL.
i_matnr-matnr = s_matnr_ex-high.
i_matnr-option = s_matnr_ex-option.
APPEND i_matnr.
CLEAR : i_matnr.
ENDIF.
ENDLOOP.
In the i_matnr table high and low values are there.
Regards,
Vandana. -
How to fill internal table with no data in debugging mode
Hi all,
I modified one existing program.Now I want to test it.I am not given test data.So in the middle of my debugging, I found that one internal table with no data.My problem is how to fill that internal table with few records in that debugging mode just as we change contents in debugging mode.If I want to proceed further means that internal table must have some records.
Please I dont know how to create test data so I am trying to create values temporarily in debugging mode only.
Thanks,
BalajiHi,
In the debugging do the following..
Click the Table button..
Double click on the internal table name..
Then in the bottom of the screen you will get the buttons like CHANGE, INSERT, APPEND, DELETE..
Use the APPEND button to insert records to the internal table..
Thanks,
Naren -
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 -
SELECT-OPTION to internal table
Hi,
I need to convert the select-option values into an internal table.
For example, if there is a select-option S_WERKS... i need all the values entered for S_WERKS into the internal table. The internal table structure contains only WERKS.
My actual requirement is, for the given plant values as select-option, i need to fetch all details of the plants. And I should not use any SELECT statements at any stage. Only through function module/ BAPI/BADI/Class methods.
I found one function module T001W_READ, but i need to pass the plant for that.
Please suggest.
Thanks in advance.
kishoreHi Kishore
Why can't you use any SELECTs? If it is so required why not writing your own FM to select them? You can pass your select-option via a generic parameter and assign it to a range at the beginning of your FM. Or you can assign it to a select-option-like table (you can find structure names of similar type from DDIC)
<i><b>e.g.</b></i>
TABLES t001w .
RANGES s_werks for t001w-werks .
DATA: BEGIN OF lt_werks ,
werks LIKE t001w-werks ,
END OF lt_werks .
s_werks[] = it_werks_so[] .
SELECT werks FROM t001w
INTO lt_werks
WHERE werks IN s_werks .
As another thing, let me introduce you the SDN Forums pointing system: You can assign points to posts which you find helpful while solving your problem. You can reward points by pressing the yellow star icon at header of each post. You can assign;
- one 10 points (solved)
- two 6 points (very helpful answer)
- many 2 points (helpful answer)
*--Serdar
Maybe you are looking for
-
Is there a way to run javascript in the url in FF6?
With the introduction of scratchpad to FF6 the javascript in the url is filtered out and will not execute. The only way i have been able to run js scripts is to use the scratchpad even if it's a one line thing that i need. I went into about:config an
-
Templates exporting w/o markup
HI, I'm working on uploading my first template based site and when I go to modify - templates - the drop down options are greyed out...all except update pages. My searching for an answer so far has given me the basic directions I'm not able to follow
-
How to change the font and font size of content shown in facet "infoUser" ?
Hi, How can I change the font and font size of content shown in facet "infoUser" using style class? I tried placing my class in my css but no success. Any of your help would be highly appreciated.
-
I have Firefox 5, but need to downgrade to 3.5 or 3.6, how do I do this? Can you help me please? It is important to finish something I am working on.
-
Creating InDesign document outside the context of inDesign document in cs4?
when i tried to find the uses of IDML in cs4, it points out the by using tried party software tool, its possible for programmatically create, modify, and deconstruct InDesign documents outside the context of InDesign. how may it possible? thanks subh