Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

read table...

Former Member
0 Kudos

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

16 REPLIES 16

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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 Options

Regards

Sudheer

rodrigo_paisante3
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

former_member491305
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

<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

Former Member
0 Kudos

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...

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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

kesavadas_thekkillath
Active Contributor
0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

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.