Internal table query
i have two internal table tab1 and tab2
both have SOME fields common but not all
tab1 has some values which i want to assign to tab2 with same fields
can i do this in a single statement in tab1 loop or i have to assign each field seperately
as tab2-field1 = tab1-field1 in tab1 loop.
loop at itab2.
read table itab1 with key matnr <b>eq</b> itab1-matnr
posnr <b>ne</b> itab1-posnr.
if sy-subrc eq 0.
move-corresponding itab1 to itab2.
append itab2.
endif.
endloop.
reward if useful.
Amit Singla
Similar Messages
-
Internal Table query Please help!!!!!
Q. What is the differance between:
TABLES: KNA1.
PARAMETERS: STATE LIKE KNA1-REGIO DEFAULT MA.
TYPES: BEGIN OF OUTREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF OUTREC.
DATA: OUT_ITAB <b>TYPE</b> STANDARD TABLE OF OUTREC
INITIAL SIZE 10 WITH HEADER LINE.
and
TABLES: KNA1.
PARAMETERS: STATE LIKE KNA1-REGIO DEFAULT MA.
TYPES: BEGIN OF OUTREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF OUTREC.
DATA: OUT_ITAB <b>LIKE</b> STANDARD TABLE OF OUTREC
INITIAL SIZE 10 WITH HEADER LINE.
also cant we write it as:
DATA: OUT_ITAB LIKE KNA1OCCURS 10 WITH HEADER LINE.
Thanks,
Dhirajhi Dhiraj,
Refer to this related thread
Re: Occurs 0 Versus Type standard table of
Difference between Declaring variables -
How to fetch the data from query to internal table ?
Dear all ,
I would like to fetch the query data(sq01) into my internal table ? is it possible to do that ?
Best Regards,
CarlosHi
Try this <b>RRW3_GET_QUERY_VIEW_DATA</b>
Also, you can have a look at this...
<a href="/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-ii Query results into Internal table</a>
Regards
Raj -
Dynamic query in where clause while looping in an internal table.
Hi,
Had a small question : How can i make a dynamic query for the WHERE clause while looping at an internal table.
i want to implement a dynamic where clause query for the below example.
it_cfx_col is an internal table and wa_cfx_col is a work area for it_cfx_col
DATA :
i_cfx_col TYPE TABLE OF cfx_col,
wa_cfx_col LIKE LINE OF i_cfx_col.
DATA : count TYPE i VALUE 0.
DATA : l_where_clause TYPE string,
l_where_clause2 TYPE string,
l_name type string.
l_name = 'NANDANOM'.
l_scenario = 'collaboration'.
LOOP AT it_cfx_col INTO wa_cfx_col
WHERE CREATED_BY = l_name
AND SCENARIO = l_scenario.
count = count + 1.
some business logic implemented using the work area wa_cfx_col
endloop.
Now i want to write a dynamic query for the where clause.
DATA : count TYPE i VALUE 0.
DATA : l_where_clause TYPE string,
l_where_clause2 TYPE string,
l_name type string.
l_name = 'NANDANOM'.
l_scenario = 'collaboration'.
l_where_clause = 'CREATED_BY = l_name'.
l_where_clause2 = 'AND SCENARIO = l_scenario'.
if l_scenario is not initial.
CONCATENATE l_where_clause l_where_clause2
INTO l_where_clause SEPARATED BY space.
endif.
LOOP AT i_cfx_col INTO wa_cfx_col
WHERE (l_where_clause).
count = count + 1.
some business logic implemented using the work area wa_cfx_col
endloop.
when i compile this i get an error message as { Statement concluding with "...(l_where_clause)" ended unexpectedly}
Even i changed the initilization of the variable l_where_clause2 to [ l_where_clause2 = 'AND SCENARIO = l_scenario.'. ]
added the end of line demarkation ".", but still i got the same error message.
Is it a limtation in ABAP that i cannot write a dynamic query for the where clause while looping at an internal table?
Regards,
omHi savita,
there in no such 1 limitaion in abap for dynamic query .. i think the error meassge is only beacuse of your synatx delcartaion.
>> LOOP AT i_cfx_col INTO wa_cfx_col
WHERE (l_where_clause).
count = count + 1.
some business logic implemented using the work area wa_cfx_col
endloop.
afted delclarataion also , in the where statement you should specify both the field name and value bname
LOOP AT i_cfx_col INTO wa_cfx_col
WHERE l_where_clause = 'CREATED_BY = l_name' .
count = count + 1.
hope it helps.
regads
priya. -
SAP QUERY LOOPS AND INTERNAL TABLE
Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
POINTS WILL BE REWARDED
Thanks
Kind Regards
Adeel SarwarHi,
This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
Thanks
TABLES: EKBE.
DATA: PurO LIKE EKPO-EBELN,
POLI LIKE EKPO-EBELP.
*New Table and Vars defined
DATA: BEGIN OF IT_EKBE,
IT_EKBE LIKE EKBE,
END OF IT_EKBE.
DATA: BEGIN OF IT_SUM OCCURS 0,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
DMBTR TYPE DMBTR,
MENGE TYPE MENGE,
END OF IT_SUM.
CLEAR: QTYD.
MOVE: EKPO-EBELN TO PurO,
EKPO-EBELP TO POLI.
SELECT * FROM EKBE INTO IT_EKBE
WHERE EBELN = PurO
AND EBELP = POLI
AND BEWTP = 'E'
LOOP AT IT_EKBE.
MOVE CORRESPOING IT_EKBE TO IT_SUM.
IF IT_EKBE-BWART = '102'.
IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
IT_SUM-MENGE = IT_SUM-MENGE * -1.
ENIDF.
COLLECT IT_SUM.
CLEAR IT_SUM.
ENDLOOP.
ENDSELECT.
If sy-subrc = 0.
QTYD = IT_SUM.
ELSE.
QTYD = 0.
ENDIF. -
Hi all,
Can we use internal table in ABAP/SAP Query (Infoset - SQ02)? If yes, Pls guide me on the same.
Thanks in advance
Regards
Madhumathi Ato my knowledge u can't use internal tables in ABAP query...it is a mix of tables...
-
Import internal table from query to report
Hi,
I have to import an internal table% G00 with its contents from a query in a custom report. I use the import statement but I do not acknowledgment the table. You can help me.
thanksHi,
standard program behind the query does not have any EXPORT statement statement behind it so it does not make sense to IMPORT. It'll never IMPORT.
You can use the following way:
SUBMIT (report_name) USING SELECTION-SCREEN <sel_screen_number> EXPORTING LIST TO MEMORY AND RETURN.
and then use
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0 AND list_tab IS NOT INITIAL.
CALL FUNCTION 'LIST_FREE_MEMORY'.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES LISTOBJECT = list_tab
LISTASCI = output.
FREE MEMORY ID '%_LIST'.
ENDIF.
output is your output table. -
Saving query view in a internal table
Hello Experts,
Is there anyway that we can trasfer all the query results to a table.
What I am exactly looking is
I want to transfer a query view to an internal table so that our destop team using java will then read the results from tables and convert to desirable format ( email, pdf etc)
Please help me out to sort this issue as this became one of the major issues to be fixed.
All inputs are much appreciated.
Thanks and Regards
Harish MulakaHello Sachin and Riccardo,
Thank you very much for taking time to reply my question.
Could you please elobarte on sending query output into PDF format.
Riccardo,
when performing an extract of a query with table option in RSCRM_BAPI.. In which table it stores the information and where can I find the results
Can you please provide me if you have any document on RSCRM_BAPI
Thanks and Regards,
Harish -
Query related to Internal Table
Hi ,
I have a small query related to internal table , can we dump millions of records to an internal .
The actual requirment is like i need to develop a report in BI side where i have to dump records into an internal table from PSA tables without filtering .
Can we do so ....
or do we have any other option to dump the data to an internal tables .
need some tips on the same .
Thanks ,
VInay.Hello Vinay,
I believe the following extract will give you a brief idea on the size limitations for an internal table.......
Internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. <u><i>The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries.</i></u>
Hope it proved useful
Reward if helpful
Regards
Byju -
Internal table with same variable and one select query
Hi,
I am a new bee here with may be a silly question.
I have a internal table as below.
DATA: BEGIN OF IT_ORDERDETAILS OCCURS 0,
VBELN LIKE VBAK-VBELN, "Order number
BSTNK LIKE VBAK-BSTNK, "customer PO
ERDAT LIKE VBAK-ERDAT, " Order created date
MATNR LIKE VBAP-MATNR, "Sales order line item
KWMENG LIKE VBAP-KWMENG, "Quantity
D_VBELN like likp-vbeln, " delivery no
POSNR like lips-posnr, " delivery item
KUNNR LIKE LIKP-KUNNR, "ship quantity
END OF IT_ORDERDETAILS.
Where VBELN field is in VBAK and LIKP table.
VBELN in VBAK table = order #
VBELN in LIKP table is = Delivery #
I want to use join to fetch data in single select query.
Below is the select query
SELECT VBAK~VBELN
VBAK~BSTNK
VBAK~ERDAT
VBAP~MATNR
VBAP~KWMENG
likp~vbeln
lips~posnr
LIPS~VGBEL
INTO (IT_ORDERDETAILSvbak, IT_ORDERDETAILSbstnk, IT_ORDERDETAILSerdat, IT_ORDERDETAILSmatnr, IT_ORDERDETAILSkwmeng, IT_ORDERDETAILSd_vbeln,IT_ORDERDETAILSposnr, IT_ORDERDETAILSkunnr)
FROM VBAK left outer JOIN VBAP ON ( VBAKVBELN = VBAPVBELN )
left outer JOIN LIPS ON ( VBAKVBELN = LIPSVGBEL )
join LIKP on ( LIPSVBELN = LIKPVBELN )
WHERE VBAK~ERDAT IN CR_DATE.
I am getting error in the query.
Please suggest.
Thanks,
RajeshHi rajesh.nayakbola,
although this is not quite the right place for this, let me give you some notes:
1. Code should be
formatted as code
by markin it with mouse and use above <> button.
2. Internal tables shoult not be declared using OCCURS clause - this is last century style
3. Internal tables do not need and should not have a header line, they should use TYPES for declaration
4. Data should not be declared using LIKE: If they refer to dictionary TYPES, use TYPE. LIKE is only mandatory for data objects declared in your program, i.e. DATA IT_some_ORDERDETAILS like IT_ORDERDETAILS.
5. If you get an error here, never write "I am getting error" but copy and paste the error message fully.
- The fields in brackets in the INTO clause never have ~ character, there is no IT_ORDERDETAILS~vbak, only IT_ORDERDETAILS-vbeln
It could be something like this:
TYPES:
BEGIN OF TY_ORDERDETAILS,
VBELN TYPE VBAK-VBELN, "Order number
BSTNK TYPE VBAK-BSTNK, "customer PO
ERDAT TYPE VBAK-ERDAT, " Order created date
MATNR TYPE VBAP-MATNR, "Sales order line item
KWMENG TYPE VBAP-KWMENG, "Quantity
D_VBELN TYPE likp-vbeln, " delivery no
POSNR TYPE lips-posnr, " delivery item
KUNNR TYPE LIKP-KUNNR, "ship quantity
END OF TY_ORDERDETAILS.
DATA:
IT_ORDERDETAILS TYPE TABLE OF TY_ORDERDETAILS.
SELECT VBAK~VBELN
VBAK~BSTNK
VBAK~ERDAT
VBAP~MATNR
VBAP~KWMENG
likp~vbeln AS D_VBELN
lips~posnr
LIKP~KUNNR
INTO CORRSPONDING FIELDS OF TABLE IT_ORDERDETAILS
FROM VBAK left outer JOIN VBAP ON ( VBAK~VBELN = VBAP~VBELN )
left outer JOIN LIPS ON ( VBAK~VBELN = LIPS~VGBEL )
join LIKP on ( LIPS~VBELN = LIKP~VBELN )
WHERE VBAK~ERDAT IN CR_DATE.
Regards,
Clemens -
Hello,
I have an internal table which needs to be queried with set of attributes which change dynamically. How can I do it?
Eg: Internal Table i_tab contains attributes a,b,c,d,e etc... Now I should extract a single line from the table based based on the values I supply for the attributes.
Say if I give a=23 b='' c='abc' d='' e=''. Then the query should be able to return be the line where all the initial field attributes (here in this case b,d, and e) should not be considered for the query.
It shoud be
read table i_tab with key a= 23 c='abc'.
The next time a query can be shooted with the foll values
a='' b='SAP' c='ERP' d='' e=''.
Then the query shd be
read table i_tab with key b= 'SAP' c='ERP'.
In short can I get the functionality of the "select statement dynamic search string"?
select * from tab where ( search string ) .
and search string would be generated dynamically based on the inputs?
I would be really thankful if you can provide me an immediate answer.
Thanks and Regards,
SandhyaI think one of the simplest way is to define ranges for the variables a, b, c, d and e.
ranges : r_a for a, r_b for b...r_e for e.
refresh : r_a, r_b, r_c, r_d, r_e.
clear : r_a, r_b, r_c, r_d, r_e.
if a is not initial.
r_a-sign = 'I'.
r_a-option = 'EQ'.
r_a-low = value.
append r_a.
endif.
....similarly build for b, c, d and e.
Loop at itab.
check itab-a in r_a.
check itab-b in r_b.
check itab-e in r_e.
move-corresponding itab to <b>urval</b>.
exit.
endloop. -
SAP Query using internal table because of multiple records in KONV
Hi
Im using abap code to write to an internal table, how do you get the internal table fields to show in query report.
Reason I have added abap code is I have a query for purchase order tables EKKO and EKPO. I would like to show any conditions attached to these purchase orders using EKKO-KNUMV = to KONV-KNUMV.
Prolem is KONV can have multiple records. So added code to write records from KONV to a internal table. Problem is how do I get the internal table files to show in query report. Have added fields as additional fields and included them in the field group.
In info sturcture I have defined internal table in code 'DATA' included the select in 'Record procesing'
Any help will be appreciated. ThanksYes, and the problem is that sometimes that item has two of the same conditions. One that SAP enters automatically and one that the end user enters. I want to understand how this is happening so that I can fix it.
-
SAP Query Display data from 2 internal tables
Hi ABAP Gurus,
I am developing a SAP Query.
I have created an infoset with the custom infotype 9050 and added the table ZPA9050 into the Infoset.
How do I input values to the ZPA9050 fields? A checkbox for making a Selection field is not available in the Query (SQ01)
For every pa9050 entry there exist multiple records of ZPA9050. I need to display the pa9050 fields in the 1st row and the corresponding zpa9050 fields in the subsequent rows.
Kindly advise how to accomplish this task.
A quick reply is highly appreciated.
Useful answers will be rewarded.
Thanks
SriramHi Deepika,
Your reqirement is to print data from the two internal tables ..and if u r not using interactive alv then u need to merge data into single internal table... if anycase u dont want to merge in the table itab as u told u can use another final internal table in which u can merge data from the two previous interal tables then u pass this final internal table to ur FM.
Thanks & Regards
Ashu Singh -
How to Query Internal tables in PCR
Hi Experts,
When I tried by using operation u201CVAKEYu201D to query the Internal tables, but it was not working
I would like to write one PCR in the Indian Payroll
Please can anyone help me on the same?
The requirement as below;
u201CIf the DDNTK table filled with amount (Assume that DDNTK table may contains more than one WT)u201D
u201CAdd this total amount (with same sign) to WT /110 net deductionsu201D
Thanks in Advance!
Thanks and Regards
CheeraI have never worked with Indian Payroll and I am not aware of a function or operation that allows to check on table DDNTK,
but you could check PCR XDPR and function PRDNT. -
How many records are fetched my query into my internal tables
Hi
I am in the debugger, would like to know, how many records are fetched my query into my internal tables. How do I find out ?
thanks
sivaHi,
Do the following,
Step 1:
Fill your internal table with select query.
Step 2 : Use DESCRIBE statement with LINE addition to get the no of rows in the internal table.
for further informations, check
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
Regards,
Anirban
Maybe you are looking for
-
It's disabled and tells me to connect to iTunes. But when I do that, iTunes wont detect the iPod.I have put the iPod in USB- mode, and by that I mean I have tried connecting with holding the home button when connecting the USB. Help?
-
Unable to install Officejet Pro L7590 print driver in Windows 8.1
I have lost days of time trying to get my OfficeJet Pro L7590 to print properly and otherwise operate in a stable manner. My computer is a new Dell XPS8700 running Windows 8, upgraded to Windows 8.1 via the "Store" app after purchase. My problems s
-
WiFi: "no hardware installed" on Mac Mini, OS 10.8.5
I realize that there are many existing threads on this error message, but they all seem to be related to laptops with spesific affected hardware and not a Mac Mini. So: I have just gotten my mid 2011 Mac Mini back from service. They replaced a fauly
-
IC-AX412 MP3 recorder: can't "access" M2 card
IC-AX412 MP3 recorder: can't "access" M2 card. That about says it all. The recorder works fine until I insert the Sandisk 8GB M2 card, at which point everything stops and the message "Accessing" appears on the display, won't go away, and I have to sh
-
Clear email address from casche on mac
Yea I recon I should know but.