‎2007 Nov 17 6:39 AM
1.select matnr from mara into corresponding fields of table itab .
loop at itab.
write : / itab-matnr.
endlop.
above the query its working or not?
2.Which event the validate the input fields in Module pool pgm ?
A.PAI B.PBO
3.What is the inner join?Anybody can explain briefly with examples?
4.A,B are integers A = 4,B=5 How to interchange Values like B= 4 and A= 5 what is the code?
5Read table how many types?what purpose to use that please give me the examples?
‎2007 Nov 17 6:44 AM
1. Yes
2. PAI
3. inner join means like one entry in header with several item entries pertaining to same objects like: VBAK for order header and VBAP for order items
4. like:
C = A.
Clear A.
A = B.
B = C.
5.You can use this syntax to read the internal table where you need only record and you are sure that you will only one record with that combination.
Regards,
Naimesh Patel
‎2007 Nov 17 6:48 AM
HI
<b>1.select matnr from mara into corresponding fields of table itab .
loop at itab.
write : / itab-matnr.
endlop.
above the query its working or not?</b>
yes it will execte but performance point of view we can't use like that
<b>2.Which event the validate the input fields in Module pool pgm ?
<b>A.PAI</b> B.PBO</b>
PAI:
When ever some user actions takes place like SAVE, DELETE, SUBMIT etc.,, you capture the function code and write your code here.
PBO:
Just remember that PBO will be processed before the screen is displayed to the end user.
Dont have myth that select statements are always written in PBO. Nothing like that. Everything depends up on your requirements.
<b>3.What is the inner join?Anybody can explain briefly with examples?</b>
The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
At least one comparison must be specified after ON.
Individual comparisons may be joined using AND only.
All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
The following language elements may not be used: BETWEEN, LIKE, IN.
No sub-queries may be used.
For outer joins, only equality comparisons (=, EQ) are possible.
If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
Resulting set for inner join
The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
Resulting set for outer join
The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
Example
Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT ccarrname pconnid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON pcarrid = ccarrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON fcarrid = pcarrid
AND fconnid = pconnid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Example
Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
PARAMETERS p_cityfr TYPE spfli-cityfrom.
DATA: BEGIN OF wa,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH NON-UNIQUE KEY carrid.
SELECT scarrid scarrname p~connid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM scarr AS s
LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
AND p~cityfrom = p_cityfr.
LOOP AT itab INTO wa.
IF wa-connid = '0000'.
WRITE: / wa-carrid, wa-carrname.
ENDIF.
ENDLOOP.
<b>4.A,B are integers A = 4,B=5 How to interchange Values like B= 4 and A= 5 what is the code?</b>
<b>5Read table how many types?what purpose to use that please give me the examples?</b>
READ TABLE itab
Effect
This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
System Fields
The statement READ TABLE sets system fields sy-subrc and sy-tabix.
sy-subrc Relevance
0 Row found. sy-tabix is set to the table index of the entry for index tables, and to the value 0 for hashed-tables.
2 Like sy-subrc equals 0. Differentiates cases that use the addition COMPARING in result.
4 Row not found. For sorted tables and when the BINARY SEARCH in free_key addition is used, sy-tabix is set to the table index of the entry before it was inserted with INSERT. Otherwise, sy-tabix is not defined.
8 Like sy-subrc equals 4. For sorted tables, however, and when the addition BINARY SEARCH is used, the end of the table was reached, and sy-tabix is set to the number of rows + 1.
The system fields sy-tfill and sy-tleng are also supplied with data.
Note
Besides the alternatives shown above for specifying the row to be read, there is another obsolete key specification obsolete_key possible.
READ TABLE - table_key
Syntax
... { FROM wa }
| { WITH TABLE KEY {comp_name1|(name1)} = dobj1
{comp_name2|(name2)} = dobj2
... } ... .
Alternatives:
1. ... FROM wa
2. ... WITH TABLE KEY ...
Effect:
The values of the search key can be specified either implicitly in a work area wa after FROM, or by explicitly listing the components of the table key after TABLE KEY.
Alternative 1
... FROM wa
Effect:
The work area wa must be a data object that is compatible with the line type of the internal table. The first found line of the internal table is read for which the values in the columns of the table key match the values in the corresponding components of wa.
Note:
Apart from in classes, the specification FROM wa can be omitted if the internal table has a header line itab with the same name. In this case, the statement then does not evaluate the content of the table key, but instead evaluates the standard key. Initial fields receive special treatment (see obsolete variants of READ TABLE).
Alternative 2
... WITH TABLE KEY ...
Effect:
Each component of the table key must listed either directly as comp_name1 comp_name2 ... , or as a bracketed character-type data object name1 name2 ..., which contains the name of the component when the statement is executed (before release 6.10 in upper case). A data object must be assigned to each component, which is compatible with or can be converted to the data type of the component. The first found line of the table is read, for which the values in the columns of the table key match the values in the assigned data objects dobj1 dobj2 .... If necessary, the content of dobj1 dobj2 ... is converted to the data type of the component before the comparison.
The different table types are accessed as follows:
standard tables are searched using a linear search.
sorted tables are searched using a binary search.
For hashed tables, the hash algorithm is used.
Notes:
In tables with a non-structured line type, for which the whole table line is defined as a table key, the pseudo component table_line can be specified as a component.
To avoid unexpected results after a conversion, dobj1 dobj2 ... should be compatible with the data type of the component.
Example:
Reading from lines of the internal table spfli_tab using the table key. The first READ statement evaluates the work area spfli_key, in the second READ statement, the components of the table key are specified explicitly.
DATA: spfli_tab TYPE SORTED TABLE OF spfli
WITH UNIQUE KEY carrid connid,
spfli_key LIKE LINE OF spfli_tab.
FIELD-SYMBOLS <spfli> TYPE spfli.
...
SELECT *
FROM spfli
INTO TABLE spfli_tab
WHERE carrid = 'LH'.
...
spfli_key-carrid = 'LH'.
spfli_key-connid = '0400'.
READ TABLE spfli_tab FROM spfli_key ASSIGNING <spfli>.
IF sy-subrc = 0.
...
ENDIF.
...
READ TABLE spfli_tab
WITH TABLE KEY carrid = 'LH' connid = '2402'
ASSIGNING <spfli>.
IF sy-subrc = 0.
...
ENDIF.
READ TABLE - free_key
Syntax
... WITH KEY comp1 = dobj1 comp2 = dobj2 ... [BINARY SEARCH] ... .
Effect:
After the addition before WITH KEY, components comp1 comp2 ... can be specified as a search key according to the rules in the section specifying components. One data object dobj1 dobj2 ... is assigned to each of the components. The data object must be compatible with or convertible to the data type of the component. The first found line of the internal table is read for which the values in the specified components (or their subareas or attributes) match the values in the assigned data objects dobj1 dobj2 .... If necessary, the content of dobj1 dobj2 ... is converted to the data type of the component before the comparison. No duplicate or overlapping key specifications are permitted.
The search takes place as follows for the individual table types :
standard tables are subject to a linear search. If the addition BINARY SEARCH is specified, the search is binary instead of linear. This considerably reduces the runtime of the search for larger tables (from approximately 100 entries upwards). For the binary search, the table must be sorted by the specified search key in ascending order. Otherwise the search will not find the correct row.
sorted tables are subject to a binary search if the specified search key is or includes a starting field of the table key. Otherwise it is linear. The addition BINARY SEARCH can be specified for sorted tables, but has no effect.
For hashed tables, the hash algorithm is used if the specified search key includes the table key. Otherwise the search is linear. The addition BINARY SEARCH is not permitted for hashed tables.
Notes:
If a name field for naming a component comp is initial, the first line that fits the rest of the search key is read. If all name fields are initial, the first row of the internal table is read.
If the addition BINARY SEARCH is used, the READ statement executes an index access. This can therefore only be used for appropriately typed tables (generic INDEX TABLE).
Example:
The internal table html_viewer_tab contains references to HTML- Controls. In the READ statement, the reference that points to an HTML control in a particular container is read.
DATA: container TYPE REF TO cl_gui_container,
html_viewer TYPE REF TO cl_gui_html_viewer.
DATA html_viewer_tab LIKE TABLE OF html_viewer.
...
CREATE OBJECT html_viewer EXPORTING parent = container.
APPEND html_viewer TO html_viewer_tab.
...
READ TABLE html_viewer_tab
WITH KEY table_line->parent = container
INTO html_viewer.
‎2007 Nov 17 6:59 AM
1) it will work fine
2) PAI
3)Inner join is used to link tables with matching key fields and obtain data...when a is joined with B...it will fethc only those records from b which matches the entries of key field in table A.
Ex: select marcmatnr maktmaktx into table it_data from marc inner join
makt on ( marcmandt = mkatmandt and marcmatnr = maktmatnr)
it gets the description from makt for only the materials fetched from marc.
4) data:val type i,a type i,b type i.
val = A + B.
B = val - A.
A = val - B.
5) Read table is used to read data fro internal tables.
We must specify either index of key fields while using read.
ex: read itab index 5. = reads the data in index 5.
read table itab with key <field> = 'A' = reads the data matching the condition.
type read in abap editor and select and press for more details
reward if usefull.....