Application Development and Automation 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 only

Problem in writing a Read Statement

Former Member
0 Likes
709

Hi,

In my Table control I have a POSITION button which is used to find the record in the table.

I have written the following code.



  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
*   NO_VALUE_CHECK        = ' '
      popup_title           = 'Find the record'
*   START_COLUMN          = '5'
*   START_ROW             = '5'
* IMPORTING
*   RETURNCODE            =
    TABLES
      fields                = lt_tab
 EXCEPTIONS
   error_in_fields       = 1
   OTHERS                = 2

I have five primary keys in my table, so that in the pop up I am getting all the five fields.

The user will enter any of the five fields , I want to write a read statement based on the fields entered by the user.

Could anybody help in writing the Read statement.

Or could any one help me in writing out the FIND functionality for a table control

Regards

Edited by: SAP LEARNER on Jun 15, 2010 1:40 PM

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
687

Hi,

Just append each value to individual ranges.

while apending to ranges , just use CP, EQ based on the string given for search.

loop at itab into wa.

if wa-field1 in s_field1 "values entered in popup

or wa-field2 in s_field2. "

move sy-tabix to wa_tabix-index.

append wa_tabix to i_find_index.

endloop.

Now i_find_index will hold the index no of the entries that satisfied the serach.

Now on each find button and find next button.

Move the index in the itab i_find_index to the top_line of table control.

7 REPLIES 7
Read only

Former Member
0 Likes
687

What is the problem you are getting with that write statement... provide your code here

Read only

0 Likes
687

Hi Its not the write statement.

For example if the user fills up the values in the First field and third field

I must write the query as

READ TABLE ITAB WITH KEY F1 = <value1> and F3 = <value2>

if he fills up 3 and fifth

READ TABLE ITAB WITH KEY F3 = <value1> and F5 = <value2>

it must be dynamic with those fields which user has filled up

How to write the READ statement

Read only

0 Likes
687

I think it's pretty well covered in F1 for READ TABLE.

Rob

Read only

0 Likes
687

read the table with fieldname

Read only

0 Likes
687

Hi,

I do not know what fields will be filled up.

as there are 5 PK fields so 5! chances will be there for the where condition in the READ statement.

How can I do it.

I tried in the following way.

I created a structure with the primary key fields and I filled the structure with the user filled values.

Then I used it in the read statement as below, but it did not work.



    LOOP AT lt_tab .
      IF lt_tab-fieldname = 'SOCIEDAD'.
        lw_pk-sociedad = lt_tab-value.
      ENDIF.
      IF lt_tab-fieldname = 'NATURAL_YEAR'.
        lw_pk-natural_year = lt_tab-value.
      ENDIF.
      IF lt_tab-fieldname = 'CICLO_DE_VENTAS'.
        lw_pk-ciclo_de_ventas = lt_tab-value.
      ENDIF.
      IF lt_tab-fieldname = 'MODEL_VERSION'.
        lw_pk-model_version = lt_tab-value.
      ENDIF.
    ENDLOOP.

    DATA:lw_yrwbw010 TYPE ty_yrwbw010.

    READ TABLE t_yrwbw010 INTO lw_yrwbw010 WITH KEY lw_pk.
     IF sy-subrc = 0.
      table-top_line = sy-tabix.
     ENDIF.

  ENDIF.

@Rob Burbank

Could you please help me !! I could not find that in F1 help.

@ Keshav.T

Could you please elaborate it please

Read only

0 Likes
687

Thanks Keshav,

I used Loop with where condition using the ranges,

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
688

Hi,

Just append each value to individual ranges.

while apending to ranges , just use CP, EQ based on the string given for search.

loop at itab into wa.

if wa-field1 in s_field1 "values entered in popup

or wa-field2 in s_field2. "

move sy-tabix to wa_tabix-index.

append wa_tabix to i_find_index.

endloop.

Now i_find_index will hold the index no of the entries that satisfied the serach.

Now on each find button and find next button.

Move the index in the itab i_find_index to the top_line of table control.