Skip to Content
author's profile photo Former Member
Former Member

read table...

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

14 Answers

  • Posted on Jul 12, 2007 at 03: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.

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • author's profile photo Former Member
                                                                                  Former Member
                                                                                  Posted on Jul 10, 2007 at 11:13 AM

                                                                                  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

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • author's profile photo Former Member
                                                                                  Former Member
                                                                                  Posted on Jul 10, 2007 at 11:13 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.

                                                                                  LOOP AT GT_TPCA.

                                                                                  IF GT_TPCA-<field> BT <select-option>.

                                                                                  perform <required task>.

                                                                                  ENDIF.

                                                                                  ENDLOOP.

                                                                                  Regards,

                                                                                  Pavan P.

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • author's profile photo Former Member
                                                                                  Former Member
                                                                                  Posted on Jul 10, 2007 at 11:14 AM

                                                                                  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

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • Posted on Jul 10, 2007 at 11:14 AM

                                                                                  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

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • Posted on Jul 10, 2007 at 11:16 AM

                                                                                  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.

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • Posted on Jul 10, 2007 at 11:19 AM

                                                                                  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.

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • author's profile photo Former Member
                                                                                  Former Member
                                                                                  Posted on Jul 10, 2007 at 11:27 AM

                                                                                  <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

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • author's profile photo Former Member
                                                                                  Former Member
                                                                                  Posted on Jul 10, 2007 at 11:46 AM

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

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                • author's profile photo Former Member
                                                                                  Former Member
                                                                                  Posted on Jul 10, 2007 at 11:48 AM

                                                                                  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

                                                                                  Add a comment
                                                                                  10|10000 characters needed characters exceeded

                                                                                Before answering

                                                                                You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
                                                                                You must be Logged in to submit an answer.

                                                                                Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.