Sql statement, internal table
<i>This is a simplified example of the problem:</i>
types: begin of t_MaterialStruct,
X_MARC_MATNR type MARC-MATNR,
X_MARC_WERKS type MARC-WERKS,
X_MBEW_VERPR type MBEW-VERPR,
end of t_MaterialStruct.
data: i_MaterialTab type table of t_MaterialStruct with header line.
The above table is partly filled with data.
It's missing the X_MBEW_VERPR.
Is it possible to update my internal table in a new select statement or ?
Something like this:
select VERPR from MBEW into i_MaterialTab where BWKEY = 3100
//Martin
Message was edited by: Martin Andersson
Hello Martin,
When you say that the above table is <i>partially</i> filled with data, are you referring to the partiality of the rows or of the columns?
Case 1 : If the internal table already has, let us say, some 10 records, you can certainly add new records to the internal table using the syntax :
SELECT VERPR
FROM MBEW
APPENDING CORRESPONDING FIELDS OF i_MaterialTab
WHERE BWKEY = 3100.
Case 2 : If the internal table has, for example 10 rows, but none of these rows has the X_MBEW_VERPR fields populated, then neither is it possible , nor does it technically make sense to populate this field in the 10 rows using another SELECT statement. That is beacuse, the SELECT statement might return more than 10 rows as the result. Also, the data fetched by the SELECT statement might not be consistent with the rest of the fields' data in those 10 rows.
Hope the explanation has been clear enough. If not please get back. If yes, then please mark the question as answered.
Regards,
Anand Mandalika.
Similar Messages
-
Dynamic SQL Statement with table name
Dear all
i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
should be something like "select * from <mytablename>"
Thank you
HerbertYes this is possible. use the below reference code for this.
data: g_tablename type w_tabname,
gv_dref TYPE REF TO data.
FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
ASSIGN gv_dref->* TO <g_itab>.
now use the below select query to fetch the data
SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
Hope this will help -
Update sql statement in sender/receiver jdbc adapter
Hi
What is the update sql statement we give in the sender/ receiver adapter when
1) SELECT statement was written in query sql statement
2) EXECUTE statement was written for a stored procedure in query sql statement
thanks
Anitha> 1) SELECT statement was written in query sql statement
your table should have some value "already_processed" which prevents a second processing of that table.
the update statement sets that value.
> 2) EXECUTE statement was written for a stored procedure in query sql statement
the same as above.
when your stored procedure already does the update, then write a second stored procedure which does nothing. -
SQL Statement / index on function ??
Hello
My environment is : Oracle 9.2.0.7
In "top sql sessions" I obtained that sql statement as below consumes many ressources.
When I use "SQL Analyzer" ... no recommandation was specified but I wonder if an index on function may be use to optimize this request.
I'd like to have your opinion on how to optimize this kind of request :
SELECT trim(CARD_NUMBER) as CARD_NUMBER,
trim(CUSTOMER.CLIENTS.CUSTOMER_ID) as CUSTOMER_ID,
trim(LASTNAME) as LASTNAME,
trim(FIRSTNAME) as FIRSTNAME,
trim(EMAIL) as EMAIL,
FROM CUSTOMER.CARTES, CUSTOMER.CLIENTS
WHERE CUSTOMER.CARTES.CUSTOMER_ID = CUSTOMER.CLIENTS.CUSTOMER_ID
AND trim(CUSTOMER.CARTES.CARD_NUMBER) = '1234567890'
AND (trim(CUSTOMER.CLIENTS.POST_CODE)='12345')
Plan execution is :
SQL STATEMENT :
JOIN
TABLE ACCESS (FULL) CUSTOMER.CARTES
TABLE ACCESS (FULL) CUSTOMER.CLIENTS
Many thanks for any help.
Regards,
GuillaumeAND trim(CUSTOMER.CARTES.CARD_NUMBER) =
'1234567890'
AND (trim(CUSTOMER.CLIENTS.POST_CODE)='12345')Yea function based index on trim(CUSTOMER.CARTES.CARD_NUMBER) and trim(CUSTOMER.CLIENTS.POST_CODE) might help.
BUT I suggest to correct data insertion app and insert already trimmed data in your table to avoid such ugly queries.
Gints Plivna
http://www.gplivna.eu -
Hi,
Need help to write sql statement.
create table t_dt ( dt_start date, dt_end date, amount number);
insert into t_dt values('1-Jan-10','10-Feb-10',12);
insert into t_dt values('11-Feb-10','10-Mar-10',10);
insert into t_dt values('11-Mar-10','20-Apr-10',8);
insert into t_dt values('21-Apr-10','28-Jun-10',10);
insert into t_dt values('29-Jun-10','20-Sep-10',10);
insert into t_dt values('21-Sep-10','10-Oct-10',10);
insert into t_dt values('11-Oct-10','31-Dec-10',8);
insert into t_dt values('1-Jan-11','10-Feb-11',8);
insert into t_dt values('11-Feb-11','10-Mar-11',7);
insert into t_dt values('11-Mar-11','20-Apr-11',6);
insert into t_dt values('21-Apr-11','28-Jun-11',6);
insert into t_dt values('29-Jun-11','20-Sep-11',6);
insert into t_dt values('21-Sep-11','10-Oct-11',4);
insert into t_dt values('11-Oct-11','31-Dec-11',8);
Result should be like below..
dt_start dt_end Amount
1-Jan-10 10-Feb-10 12
11-Feb-10 10-Mar-10 10
11-Mar-10 20-Apr-10 8
21-Apr-10 10-Oct-10 10
11-Oct-10 10-Feb-11 8
11-Feb-11 10-Mar-11 7
11-Mar-11 20-Sep-11 6
21-Sep-11 10-Oct-11 4
11-Oct-11 31-Dec-11 8
Just to explain the example, take a row with start date as 21-Apr-10 in the above insert statements, since it has the same amount for next two rows (i.e. with start date '29-Jun-10' and '21-Sep-10') these 3 rows should be converted to represent only 1 row in the result and the start date and end date should be changed per the result shown above.
Thanks.Hello
I think this gives yuo what you need....
SELECT
MIN(dt_start),
MAX(dt_end),
amount
FROM
( SELECT
dt_start,
dt_end,
MAX(marker) OVER(ORDER BY dt_start) marker,
amount
FROM
Select
dt_start,
dt_end,
amount,
CASE
WHEN LAG(amount) OVER(ORDER BY dt_start) <> amount THEN
ROW_NUMBER() OVER(ORDER BY dt_start)
END marker
from t_dt
GROUP BY
amount,
marker
order by
MIN(dt_start)
MIN(DT_START) MAX(DT_END) AMOUNT
01-JAN-2010 00:00:00 10-FEB-2010 00:00:00 12
11-FEB-2010 00:00:00 10-MAR-2010 00:00:00 10
11-MAR-2010 00:00:00 20-APR-2010 00:00:00 8
21-APR-2010 00:00:00 10-OCT-2010 00:00:00 10
11-OCT-2010 00:00:00 10-FEB-2011 00:00:00 8
11-FEB-2011 00:00:00 10-MAR-2011 00:00:00 7
11-MAR-2011 00:00:00 20-SEP-2011 00:00:00 6
21-SEP-2011 00:00:00 10-OCT-2011 00:00:00 4
11-OCT-2011 00:00:00 31-DEC-2011 00:00:00 8
9 rows selected.HTH
David
Edited by: Bravid on Feb 23, 2012 12:08 PM
Beaten to it by Frank! :-) -
If someone would be so kind, I need help in formulating a SQL statement.
Table A - employees(empoyee_id, employee_name, status)
This table contains all employees
employee status can be one of three values (A=active, T=temporary, I=inactive)
Table B - savings_program(employee_id, plan_type)
This table only has employee_id's of those that participate in a savings program (subset of all employees).
plan_type can be one of three numeric values (30,35,40)
I need SQL to report a.employee_id,a.employee_name,b.plan_type (return plan_type 30,35, or none)of all active employees in Table A that don't participate in Table B plan_type 40.
Working with version 9iR2. Thanks!
Edited by: fosterk on Nov 21, 2008 12:59 PMThe tables and columns above were for demo purposes but actual code I'm trying is below. Please excuse me I'm more of an SA type so SQL is not my thing.
As you can see from the first SQL statement below I know that I have exactly
3,000 employees that meet this criteria. The second SQL statement is my attempt to return the rows I want (I'm just nesting it in a count(*) until the numbers look right)
The last statement is what was given to me by someone else (seeking my help haha) trying to resolve it and it only returns 3 rows. This SQL shows the actual columns that we're trying to return from both tables.
HR> select count(*) from ps_All_employees where empl_status != 'T'
2 and emplid not in
3 (select emplid from ps_savings_pt_vw where plan_type = 40)
4 /
COUNT(*)
3000
HR> select count(*) from (
2 (select * from ps_all_employees where empl_status != 'T') a left outer join
3 (select emplid from ps_savings_pt_vw where plan_type != 40) s
4 on a.emplid = s.emplid
5 )
6 /
COUNT(*)
4587
select count(*) from (
select a.location, a.ssn, a.first_name, a.last_name, a.birthdate, a.orig_hire_dt, a.hire_dt, a.location, a.street1,
a.street2, a.city, a.state, a.zip, s.plan_type
from ps_all_employees a, ps_savings_pt_vw s
where a.empl_status != 'T' and
a.emplid = s.emplid and
a.emplid not in (select s.emplid from ps_savings_pt_vw s where s.plan_type = 40)
COUNT(*)
3 -
Explain ref cursor sql statement
I would like to explain the following sql statement. Table e should have minimal rows, guesstimate less than 100. However, table a and c has 250 million rows each. Table b has 10 000 rows. How could i get an explain plan for this select statement ?
SQL> explain plan for
2 select count(a.acct_no) acct_eligible,
3 count(c.acct_no) acct_rv,
4 e.offer_id,
5 e.offer_name,
6 e.method_id,
7 e.org_cd
8 from table(cast(nt_stretch as ntt_stretch)) e,
9 crfmgr.stmt_insert_qualify@gem a,
10 datamgr.rqst_tst_acct_cre@gem b,
11 crfmgr.stmt_insert_actual@gem c
12 where e.method_id = a.mthd_cd
13 and e.method_id = c.mthd_cd
14 and a.cyc_dt between to_date('01/01/2003','MM/DD/YYYY') and to_date('02/01/2003','MM/DD/YYYY')
15 and c.cyc_dt between to_date('01/01/2003','MM/DD/YYYY') and to_date('02/01/2003','MM/DD/YYYY')
16 and a.account_no <> b.fusa_acct_nb
17 group by e.offer_id,
e.offer_name,
e.method_id, e.org_cd;
from table(cast(nt_stretch as ntt_stretch)) e,
ERROR at line 8:
ORA-00904: invalid column nameWhere is the collection nt_stretch coming from? I'm assuming it's a local variable in the code for this query. Obviously, you can't just have local variables in there for the explain plan. I'd materialize a temporary table with the structure of nt_stretch to do the explain plan.
Richard -
How to get a SQL statement that trigerred a trigger ?
I'd like to trace all insert and update operations done on a table.
So, how can I get the SQL statement that triggered a trigger ?
ThanksUse AUDIT to trace all sql statement about table, views etc. (except column) :
http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_4007.htm#SQLRF01107
Or, if you are in 9i or later, you can use DBMS_FGA (you can audit just a column) :
http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10802/d_fga.htm#ARPLS015
Nicolas. -
SQL Statement taking too long to get the data
Hi,
There are over 2500 records in a table and when retrieve all using ' SELECT * From Table' it is taking too long to get the data. ie .. 4.3 secs.
Is there any possible way to shorten the process time.
ThanksHi Patrick,
Here is the sql statement and table desc.
ID Number
SN Varchar2(12)
FN Varchar2(30)
LN Varchar2(30)
By Varchar(255)
Dt Date(7)
Add Varchar2(50)
Add1 Varchar2(30)
Cty Varchar2(30)
Stt Varchar2(2)
Zip Varchar2(12)
Ph Varchar2(15)
Email Varchar2(30)
ORgId Number
Act Varchar2(3)
select A."FN" || '' '' || A."LN" || '' ('' || A."SN" || '')'' "Name",
A."By", A."Dt",
A."Add" || ''
'' || A."Cty" || '', '' || A."Stt" || '' '' || A."Zip" "Location",
A."Ph", A."Email", A."ORgId", A."ID",
A."SN" "OSN", A."Act"
from "TBL_OPTRS" A where A."ID" <> 0 ';
I'm displaying all rows in a report.
if I use 'select * from TBL_OPTRS' , this also takes 4.3 to 4.6 secs.
Thanks. -
Update databse from internal table statement not using index
Hi Guys,
We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
Should not the update statement here be using the table index (for primary key)?
Regards,
Munish... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
Coming to the original question, what is you actually coding for the update?
What is the table, which fields are in the internal table and what are the indexes?
Siegfried -
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 -
Dynamic Tables & SQL Statements
Example:
A user types in a SQL statement, " Country = 'US' ", into a input field. i read it and copy into table A. how am i supposed to use the statement found in the table to do a comparison of data from table B? i've found a example in the abap documentation but i'm not sure how to retrieve the statement from table A. please provide sample codes so i know how it works. i'll reward handsomely if the answer's close (((((((:
Thanks (:
REPORT demo_special_tech_subroutine_1.
DATA: code TYPE TABLE OF rssource-line,
prog(8) TYPE c, msg(120) TYPE c, lin(3) TYPE c,
wrd(10) TYPE c, off(3) TYPE c.
APPEND 'PROGRAM SUBPOOL.'
TO code.
APPEND 'FORM DYN1.'
TO code.
APPEND
'WRITE / ''Hello, I am the temporary subroutine DYN1!''.' "#EC NOTEXT
TO code.
APPEND 'ENDFORM.'
TO code.
APPEND 'FORM DYN2.'
TO code.
APPEND
'WRIT / ''Hello, I am the temporary subroutine DYN2!''.' "#EC NOTEXT
TO code.
APPEND 'ENDFORM.'
TO code.
GENERATE SUBROUTINE POOL code NAME prog
MESSAGE msg
LINE lin
WORD wrd
OFFSET off.
IF sy-subrc <> 0.
WRITE: / 'Error during generation in line', lin, "#EC NOTEXT
/ msg,
/ 'Word:', wrd, 'at offset', off. "#EC NOTEXT
ELSE.
WRITE: / 'The name of the subroutine pool is', prog. "#EC NOTEXT
SKIP 2.
PERFORM dyn1 IN PROGRAM (prog).
SKIP 2.
PERFORM dyn2 IN PROGRAM (prog).
ENDIF.
Edited by: Leslie Koh on Jan 16, 2008 6:31 AMLeslie
Check below comments:
types: begin of ty_code, " Type declaration
text type char255,
end of ty_code.
data: it_code type table of ty_code, " Internal table to hold the dynamic WHERE condition
wa_code type ty_code. " Work Area
select * from <tabA> into <itabA>. " tabA is the first table which holds the SQL conditions
loop at <itabA> into <waA>.
move <waA>-cfield to wa_code-text. " In this example as presuming CFIELD has the SQL condition
append wa_code to it_code. " Am preparing an internal table with all the conditions
endloop.
* Note that if you have more than one condition you may need to add AND to starting 2nd line
* Now the conditions exists in table it_code, Use the same for next select
select * from <tabB> into <itabB>
where (it_code). " Retreiving data from table tabB with the SQL conditions from tabA
Hope this helps you understand.
Try using the above code in a temporary program, replace <tabA> with your first table that holds SQL conditions, <tabB> with the second table.
Kind Regards
Eswar -
SP2-0642: SQL*Plus internal error state 2133, context
Hi Everybody
I am getting the below wired error msg in SQL Plus when trying to execute a select statment on a external table
SP2-0642: SQL*Plus internal error state 2133, context 0:0:0
Unsafe to proceed
SP2-0642: SQL*Plus internal error state 2221, context 4294967295:4:0
Unsafe to proceed
Kindly help me out to solve this issue.
Thanks & Regards
Chandra Sekar A.
[email protected]Hi Guys
Thanks for both of you for your replies.
The problem is still pertaining.
Below is the structure I have used to create the external table
CREATE TABLE "Z_TBN_JXPKIREC"
"ORG" NUMBER ,
"ACCT" VARCHAR2(19) ,
"XD_REC_NBR" NUMBER ,
"XD_REC_TYPE_KEY" NUMBER ,
"LOGO" Number ,
"XD_DATE_LAST_MAINT" NUMBER ,
"XD_PLAN_NBR" NUMBER ,
"XD_FILLER_1" VARCHAR2(21) ,
"XD_DATE_ADDED" NUMBER ,
"XD_PRIN_BNP" NUMBER ,
"XD_INT_BNP" NUMBER ,
"XD_INS_BNP" NUMBER ,
"XD_NSF_BNP" NUMBER ,
"XD_SVC_CHG_BNP" NUMBER ,
"XD_LATE_CHG_BNP" NUMBER ,
"XD_MEMBER_BNP" NUMBER ,
"XD_OVLM_BNP" NUMBER ,
"XD_RECV_BNP" NUMBER ,
"XD_COLL_BNP" NUMBER ,
"XD_USER_FEE_1_BNP" NUMBER ,
"XD_USER_FEE_2_BNP" NUMBER ,
"XD_USER_FEE_3_BNP" NUMBER ,
"XD_USER_FEE_4_BNP" NUMBER ,
"XD_USER_FEE_5_BNP" NUMBER ,
"XD_USER_FEE_6_BNP" NUMBER ,
"XD_FILLER_2" NUMBER ,
"XD_FILLER_3" VARCHAR2(85)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY LOC_TARGET
ACCESS PARAMETERS (
RECORDS FIXED 2500
CHARACTERSET JA16EBCDIC930
STRING SIZES ARE IN BYTES
NOBADFILE
NODISCARDFILE
LOGFILE 'XXXX_9.LOG'
FIELDS
NOTRIM
"ORG" POSITION (1:3) INTEGER EXTERNAL ,
"ACCT" POSITION (4:22) CHAR(19) ,
"XD_REC_NBR" POSITION (23:25) INTEGER EXTERNAL ,
"XD_REC_TYPE_KEY" POSITION (26:27) INTEGER EXTERNAL ,
"LOGO" POSITION (28:30) INTEGER EXTERNAL ,
"XD_DATE_LAST_MAINT" POSITION (31:34) DECIMAL(7,0) ,
"XD_PLAN_NBR" POSITION (35:37) INTEGER EXTERNAL ,
"XD_FILLER_1" POSITION (42:62) CHAR(21) ,
"XD_DATE_ADDED" POSITION (38:41) DECIMAL(7,0) ,
"XD_PRIN_BNP" POSITION (63:71) DECIMAL(17,0) ,
"XD_INT_BNP" POSITION (72:80) DECIMAL(17,0) ,
"XD_INS_BNP" POSITION (81:89) DECIMAL(17,0) ,
"XD_NSF_BNP" POSITION (90:98) DECIMAL(17,0) ,
"XD_SVC_CHG_BNP" POSITION (99:107) DECIMAL(17,0) ,
"XD_LATE_CHG_BNP" POSITION (108:116) DECIMAL(17,0) ,
"XD_MEMBER_BNP" POSITION (117:125) DECIMAL(17,0) ,
"XD_OVLM_BNP" POSITION (126:134) DECIMAL(17,0) ,
"XD_RECV_BNP" POSITION (135:143) DECIMAL(17,0) ,
"XD_COLL_BNP" POSITION (144:152) DECIMAL(17,0) ,
"XD_USER_FEE_1_BNP" POSITION (153:161) DECIMAL(17,0) ,
"XD_USER_FEE_2_BNP" POSITION (162:170) DECIMAL(17,0) ,
"XD_USER_FEE_3_BNP" POSITION (171:179) DECIMAL(17,0) ,
"XD_USER_FEE_4_BNP" POSITION (180:188) DECIMAL(17,0) ,
"XD_USER_FEE_5_BNP" POSITION (189:197) DECIMAL(17,0) ,
"XD_USER_FEE_6_BNP" POSITION (198:206) DECIMAL(17,0) ,
"XD_FILLER_2" POSITION (207:215) DECIMAL(17,0) ,
"XD_FILLER_3" POSITION (216:300) CHAR(85)
LOCATION (LOC_TARGET: 'XXXX.DAT')
REJECT LIMIT UNLIMITED
NOPARALLEL
and w.r.t. SQL Plus version itz 9.2 and the database server is also 9.2
Your replies are highly appreciated and thanks for your valuable time.
Thanks & Regards
Chandra Sekar A.
[email protected] -
IMPORT Statement Issue (Internal Table)
Hi All,
I am using an IMPORT statement to get all the data from other report's internal table. Now whenever this (the other report's internal table) is changed (for field addition, etc), my report throws a dump. Hence, everytime I have to add these fields in my program as well.
Is there any way by which I can include the whole internal table of that report in my program just like
'INCLUDE STRUCTURE VBRK'.
Thanks in advanceHi, CHeck this code related to your problem..This will helpful to you...
I have done this program earlier..I hope it will helpful to u..
This programa calling the other program to import the data..
Check it out...
*" Tables declarations.................................................
TABLES:
spfli.
*" Type declarations...................................................
Type declaration of the structure to hold data from table SPFLI *
TYPES:
BEGIN OF type_s_spfli,
carrid LIKE spfli-carrid, " Carrier Id
connid LIKE spfli-connid, " Connection Number
cityfrom LIKE spfli-cityfrom, " City from
cityto LIKE spfli-cityto, " City to
airpfrom LIKE spfli-airpfrom, " Airport from
airpto LIKE spfli-airpto, " Airport to
countryfr LIKE spfli-countryfr, " Country from
countryto LIKE spfli-countryto, " Country to
END OF type_s_spfli.
Data Declaration...................................................*
Field String To Hold Flight Details Record from SPFLI *
DATA
fs_spfli TYPE type_s_spfli.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SPFLI *
DATA
t_spfli LIKE STANDARD TABLE OF fs_spfli.
TYPES:
BEGIN OF types_s_itab,
carrid LIKE sflight-carrid, " Carrier id
connid LIKE sflight-connid, " Connection number
fldate LIKE sflight-fldate, " Flight date
END OF types_s_itab.
Data Declaration...................................................*
Field String To Hold Flight Details Record from SFLIGHT *
DATA
fs_itab TYPE types_s_itab.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SFLIGHT *
DATA
t_itab LIKE STANDARD TABLE OF fs_itab.
*" Type declarations...................................................
Type declaration of the structure to hold data from table SBOOK *
TYPES:
BEGIN OF type_s_sbook,
carrid LIKE sbook-carrid, " Carrier Id
connid LIKE sbook-connid, " Connection Number
fldate LIKE sbook-fldate, " Flight date
bookid LIKE sbook-bookid, " Booking number
loccuram LIKE sbook-loccuram, " Local currency
loccurkey LIKE sbook-loccurkey,
order_date LIKE sbook-order_date, " Booking date
END OF type_s_sbook.
Data Declaration...................................................*
Field String To Hold Flight Details Record from BOOK *
DATA
fs_sbook TYPE type_s_sbook.
Data Declaration...................................................*
Internal Table To Hold Flight Details Records from SBOOK *
DATA
t_sbook LIKE STANDARD TABLE OF fs_sbook.
DATA
w_checkbox. " Checkbox
SELECT-OPTIONS:
s_carr FOR spfli-carrid. " Carrier id range
START-OF-SELECTION EVENT *
START-OF-SELECTION.
PERFORM selectq.
END-OF-SELECTION EVENT *
END-OF-SELECTION.
SET PF-STATUS 'YH1314_030502'.
PERFORM display_basic.
AT USER-COMMAND.
PERFORM ucomm.
*& Form selectq
This subroutine retreive data from SPFLI table
There are no interface parameters to be passed to this subroutine.
FORM selectq .
SELECT carrid " Carrier id
connid " Connection number
cityfrom " City from
cityto " City to
airpfrom " Airport from
airpto " Airport to
countryfr " Country from
countryto " Country to
INTO CORRESPONDING FIELDS OF TABLE t_spfli
FROM spfli
WHERE carrid IN s_carr.
ENDFORM. " Selectq
*& Form display_basic
This subroutine displays data from internal table
There are no interface parameters to be passed to this subroutine.
FORM display_basic .
LOOP AT t_spfli INTO fs_spfli.
WRITE:
/ w_checkbox AS CHECKBOX,
fs_spfli-carrid,
fs_spfli-connid,
fs_spfli-cityfrom,
fs_spfli-cityto,
fs_spfli-airpfrom,
fs_spfli-airpto,
fs_spfli-countryfr,
fs_spfli-countryto.
ENDLOOP. " LOOP AT T-SPFLI INTO...
ENDFORM. " Display_basic
*& Form UCOMM
This subroutine for at user-command event
There are no interface parameters to be passed to this subroutine.
FORM ucomm .
RANGES :
r_carr FOR spfli-carrid,
r_conn FOR spfli-connid,
r_carrid FOR sflight-carrid,
r_connid FOR sflight-connid,
r_fldate FOR sflight-fldate.
CASE sy-ucomm.
WHEN 'DISPLAY'.
DATA:
lw_lines TYPE i,
lw_lineno TYPE i VALUE 3.
DESCRIBE TABLE t_spfli LINES lw_lines.
DO lw_lines TIMES.
READ LINE lw_lineno FIELD
VALUE w_checkbox INTO w_checkbox
fs_spfli-carrid INTO fs_spfli-carrid
fs_spfli-connid INTO fs_spfli-connid.
IF sy-subrc = 0.
IF w_checkbox = 'X'.
r_carr-sign = 'I'.
r_carr-option = 'EQ'.
r_carr-low = fs_spfli-carrid.
APPEND r_carr.
r_conn-sign = 'I'.
r_conn-option = 'EQ'.
r_conn-low = fs_spfli-connid.
APPEND r_conn.
ENDIF. " IF W_CHECKBOX = 'X'
ENDIF. " IF SY-SUBRC = 0
ADD 1 TO lw_lineno.
ENDDO. " DO LW_LINES TIMES
SUBMIT yh1314_030502_call
WITH s_carr IN r_carr
WITH s_conn IN r_conn
AND RETURN.
IMPORT t_itab FROM MEMORY ID 'YH1314'.
LOOP AT t_itab INTO fs_itab.
r_carrid-sign = 'I'.
r_carrid-option = 'EQ'.
r_carrid-low = fs_itab-carrid.
APPEND r_carrid.
r_connid-sign = 'I'.
r_connid-option = 'EQ'.
r_connid-low = fs_itab-connid.
APPEND r_connid.
r_fldate-sign = 'I'.
r_fldate-option = 'EQ'.
r_fldate-low = fs_itab-fldate.
APPEND r_fldate.
ENDLOOP. " LOOP AT T_ITAB INTO.....
SELECT carrid " Carriee Id
connid " Connection number
fldate " Flight date
bookid " Booking number
loccuram " Local Currency
order_date " Booking date
INTO CORRESPONDING FIELDS OF TABLE t_sbook
FROM sbook
WHERE carrid IN r_carrid AND
connid IN r_connid AND
fldate IN r_fldate.
IF SY-SUBRC NE 0.
MESSAGE 'NO RECORDS FOUND'(006) TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
LOOP AT t_sbook INTO fs_sbook.
AT FIRST.
WRITE: /5 'Carrier Id'(001),
20 'Conn Id'(002),
35 'Flight date'(003),
50 'Book Id'(004),
65 'Local Currency'(005).
ENDAT. " AT FIRST
WRITE: /5 fs_sbook-carrid,
20 fs_sbook-connid,
35 fs_sbook-fldate,
50 fs_sbook-bookid,
65 fs_sbook-loccuram CURRENCY fs_sbook-loccurkey.
ENDLOOP. " LOOP AT T_SBOOK INTO.....
ENDCASE. " CASE SY-UCOMM
ENDFORM. " UCOMM
Regards
Kiran -
Doubts with control break statements on internal table loops (AT/ENDAT)
Hi, i've had a couple of doubts for a long while which I hope someone can clarify today:
1) I know how to use the AT statements, however, i'm not sure I get correctly what this part of help regarding this commands means:
<i>"The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant."</i>
I've always sorted the internal table before the control break and it works that way. For example:
SORT ITAB BY EBELN EBELP.
LOOP AT ITAB.
AT NEW EBELN.
* Code for the order header
ENDAT.
ENDLOOP.
If I <b>don't</b> sort the internal table, it doesn't work! (i get dupplicated processing). In the example, if i have more than one register with the same EBELN and they're not consecutive, the header gets processed twice. I really don't get that part of the help text.
2) I know this: <i>"At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:
All character type fields (on the right) are filled with "*" after the current control level key.
All other fields (on the right) are set to their initial values after the current control level key."</i>
My doubt is: WHY is that this way? Because sometimes (most times) I need those fields INSIDE the statement! So when that happened i've solved it in one of three ways:
LOOP AT ITAB INTO WA_ITAB.
WA_ITAB_AUX = WA_ITAB.
AT NEW FIELD.
WA_ITAB = WA_ITAB_AUX.
* ...Rest of the code for the first register
ENDAT.
ENDLOOP.
LOOP AT ITAB INTO WA_ITAB.
AT NEW FIELD.
READ TABLE ITAB INDEX SY-TABIX INTO WA_ITAB.
* ...Rest of the code for the first register
ENDAT.
ENDLOOP.
* (Without AT)
LOOP AT ITAB INTO WA_ITAB.
IF WA_ITAB-FIELD <> FIELD_AUX.
FIELD_AUX = WA_ITAB_FIELD.
* ...Rest of the code for the first register
ENDIF.
ENDLOOP.
Is there any problem with this way of coding? Can be done better?
Thank you very much in advance.Hi..,
1)
See if u sort the table on a field on which u r using AT ENDAT .. then all the records which are having the same value for that field will form a group or those reocrds will be at one place.. so when u sort the table for all the records AT ENDAT will get executed onli once..
If u dont sort this table on this field then all these records will be at different places and in between there may be records with different value for this field.. so this AT ENDAT will get executed for each record !!
2)
No u cannot use the Right hand fields of the field in the table .. Because these AT events work as Group based operations... So till that field on which AT ENDAT is working it breaks that record into two groups.. One is the left hand fields including that field.. and right hand fields as another group.. and makes the right hand group as stars ****. Thats y u can observe that even any one field in the left hand group changes the AT ENDAT will get executed !!!!
Hope u understood !!!
regards,
sai ramesh
Maybe you are looking for
-
Urgent help needed on oracle queueing
Hi we have created AQ tables and queues but are facing with the following errors Thu Aug 30 17:25:31 2007 Errors in file e:\orant\ora9i\pds\udump\pds_ora_4092.trc: ORA-00600: internal error code, arguments: [opidor: call 1], [], [], [], [], [], [], [
-
Renamed Root Server/Bad Scan Directory path
Hi, I had to rename one of my NetWare 6.0sp5 servers. This server also holds the ZFD3.2 database - it is a Root server with workstations attached. The problem I have now is that the <ServerName>_ZenInvService object contains a pointer to the wrong lo
-
Why Update query is executing twice in this case even if called one time?
Example 1=> I have unix ksh file and I am calling sql file from it. (table 1 contains 2 rows - ID Name 1 test't 2 Pet's below sql statement is part of sql file: update table1 set name = replace(name,'''','''''') where instr(name,'''') > 0 ; 2 ro
-
My trial subscription to outlook has ended, but my iphone only seems able to sync with Outlook. Surely Apple have an alternative or can anyone suggest one? I can't bear to pay a fortune to Microsoft just for their Outlook calendar app. Or can my Mobi
-
Code Help in my Template - Please?
My template looks as intended, but when I create a page from the template, it is wrong. My code for the dwt file is below. Below that is my css code. Please pardon the mess. I'm still learning. Please let me know if you can tell what I've done wrong.