‎2007 Jul 10 12:11 PM
Hi all,
I have a select statement in which i am retrieving values in a internal table.
how to use the values of that table in the next if statements...
for ex:
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt.
Now i want to check if the field racct of table gt_tpca is the value in select options.
Based on that i want to write a perfrom statement.
So how to get that value.
thanks
Jareer
‎2007 Jul 10 12:13 PM
Hi
Write as
loop at gt_tpca where<b> racct in s_racct</b>.
..perform...
endloop.
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Jul 10 12:13 PM
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt.
LOOP AT GT_TPCA.
IF GT_TPCA-<field> BT <select-option>.
perform <required task>.
ENDIF.
ENDLOOP.
Regards,
Pavan P.
‎2007 Jul 10 12:14 PM
Hi,
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt and
racct in s_racct . " This will check the racct from Select OptionsRegards
Sudheer
‎2007 Jul 10 12:14 PM
Hi,
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt.
<b>
loop at gt_tpca.
if gt_tpca-racct in s_value.
perform x.
endif.
endloop.
</b>
regards
‎2007 Jul 10 12:16 PM
Hi jareer,
After ur select statemnt, Loop at the internal in which u got the data from the select statement.
Ex : Loop at gt_itab.
read table gt_itab .....( Press F1 on READ, to get the syntax )
if sy-subrc = 0.
check ur condition.
endif.
endloop.
‎2007 Jul 10 12:19 PM
Hi,
You can directly give that in where condition of select query using in operator..If you still need the remaining value or for some other purpose...
you can do like this.
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt.
LOOP AT gt_tpca into x_m WHERE racct IN s_racct.
exit.
ENDLOOP.
if sy-subrc = 0.
perform <forma name>.
endif.
‎2007 Jul 10 12:27 PM
<b>Here is the code for yours ...</b>
select-options : s_racct for glpca -racct .
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt and
racct in s_racct .
<b>
the values are filterred while selecting from the database table glpca with in the
select-ooption range as low & high </b>
reward points if it is usefull .....
Girish
‎2007 Jul 10 12:46 PM
Hey Khan,
First of all I wanna suggest u that if u want a perform in which u want any logic based on condition that 'racct of table gt_tpca is the value in select options'
use that condition in Select statement itself rather than writing a condition later after the Select statement.
Like
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE racct in S_RACCT
docnr EQ gw_idoc-belnr AND
rclnt EQ sy-mandt.
Reward points if usefull...
‎2007 Jul 10 12:48 PM
Dear Jareer,
You have 2 options
1) Filter the condition in "Select statement" before passing into the internal table gt_tpca
2) Once it is passed into the internal table you can use " loop..endloop" for your requirement of checking for a specific "racct"
Option 1 is better in terms of not using loop/endloop because it slows down your performance to the extent of data contained in the table glpca and filtering is done in an initial stage
For this use ranges like
if P_racct is your field in select options
then
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt
AND racct in P_racct.
Option2 is to be used if you need not filter at an initial stage for racct
That can be done as follows
You need to use the values for a another specific "racct" operation
loop at gt_tpca where racct = 'XXXX" "for a single racct value
Perform your operation...
endloop.
For multiple select options you can use case/if..endif inside loops '
or try " loop at gt_tpca where racct in P_racct " which i have not tried yet
Hope it clarifies your doubt
Regards
Byju
‎2007 Jul 10 12:55 PM
hi
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt.
loop at gt_tpca.
if gt_tpca-racct in s_value.
perform x.
endif.
endloop
reward if useful.
‎2007 Jul 10 1:02 PM
Hi jareer,
1.<b> Now i want to check if the field racct of table gt_tpca is the value in select options.</b>
<b>LOOP AT GT_TPCA.
IF GT_TPCA-RACCT IN MYSELECTOPTION.
*---- CODE
ENDIF.</b>
regards,
amit m.
‎2007 Jul 11 9:45 AM
Hi All,
The problem here is there are some select statements nested in that perform statement, so theres a problem of performance here arising.so how can i aviod this.
Thanks
Jareer.
‎2007 Jul 11 7:17 PM
Hi again,
Use the transactions se30 and st05 to test performance of your routines and program.
There you will see some examples and tips to rewrite your code.
Some tips:
Change SELECT... ENDSELECT to SELECT...INTO TABLE
use SELECT ... FOR ALL ENTRIES when possible
use READ TABLE... BINARY SEARCH.
use the command SORT before read or loop a table.
If useful, please reward points.
Regards
‎2007 Jul 12 4:24 AM
if u want only the value gt_tpca then include it in select statement.
or try this
*****************************************
loop at itab where <col> = 'gt_tpca'.
flg = 1.
exit.
endloop.
if flg = 1.
perform <name>
flg = 0.
endif.
‎2007 Jul 12 5:04 AM
sorry its like this
if u want only the value gt_tpca then include it in select statement.
or try this
*****************************************
loop at itab where <col> = <sel option value>
flg = 1.
exit.
endloop.
if flg = 1.
perform <name>
flg = 0.
endif.
‎2007 Jul 12 5:18 AM
SELECT rfarea docct rbukrs ryear docnr
ksl racct sgtxt cpudt usnam
FROM glpca client specified INTO TABLE gt_tpca
WHERE docnr EQ gw_idoc-belnr
AND rclnt EQ sy-mandt.
READ TABLE gt_tpca INDEX i.
PERFORM get_data USING gt_tpca-racct.