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

Reading Internal Table

Former Member
0 Likes
1,306

Hi Friends,

I have got Functional Location(TPLNR), Group Counter(PLNAL), Operation(VORNR) in an internal table GIT_DATA.

Based on the values in the internal table i am fetching below data.

    SELECT mandt tplnr plnty plnnr plnal zkriz zaehl FROM tapl
    INTO TABLE git_tapl
     FOR ALL ENTRIES IN git_data
      WHERE tplnr = git_data-tplnr
        AND plnal = git_data-plnal.

    IF sy-subrc = 0.

      SELECT mandt plnty plnnr plnal plnfl plnkn zaehl FROM plas
       INTO TABLE git_plas
        FOR ALL ENTRIES IN git_tapl
         WHERE plnty = git_tapl-plnty
           AND plnnr = git_tapl-plnnr
           AND plnal = git_tapl-plnal.

      IF sy-subrc = 0.

        SELECT mandt plnty plnnr plnkn zaehl vornr FROM plpo
         INTO TABLE git_plpo
          FOR ALL ENTRIES IN git_plas
           WHERE plnty = git_plas-plnty
             AND plnnr = git_plas-plnnr
             and plnkn = git_plas-plnkn
             and zaehl = git_plas-zaehl.

      ENDIF.
    ENDIF.

 Now i am trying to read those values. 

  LOOP AT git_data INTO wa_data.
      READ TABLE git_tapl INTO wa_tapl
       WITH KEY tplnr = wa_data-tplnr
                plnal = wa_data-plnal BINARY SEARCH.
      IF sy-subrc = 0.
        read table git_plas into wa_plas
         with key mandt = wa_tapl-mandt
                  plnty = wa_tapl-plnty
                  plnnr = wa_tapl-plnnr
                  plnal = wa_tapl-plnal
                  binary search.
         if sy-subrc = 0.

<b>* Here i need to find the exact operation record.</b> 

         READ TABLE git_plpo INTO wa_plpo  << This read is failing in the 2nd loop onwords.
          WITH KEY mandt = wa_plas-mandt
                  plnty = wa_plas-plnty
                  plnnr = wa_plas-plnnr
                  plnkn = wa_plas-plnkn
                  zaehl = wa_plas-zaehl
                  vornr = wa_data-vornr
                  BINARY SEARCH.
          endif.
     endif.
 endloop.

Am a not using correct relation? Can any body check and tell me what is wrong in this?

Thanks,

Satish

14 REPLIES 14
Read only

Former Member
0 Likes
1,180

hi,

i corrected like this,

SELECT mandt tplnr plnty plnnr plnal zkriz zaehl FROM tapl

INTO TABLE git_tapl

FOR ALL ENTRIES IN git_data

WHERE tplnr = git_data-tplnr

AND plnal = git_data-plnal.

IF sy-subrc = 0.

SELECT mandt plnty plnnr plnal plnfl plnkn zaehl FROM plas

INTO TABLE git_plas

FOR ALL ENTRIES IN git_tapl

WHERE plnty = git_tapl-plnty

AND plnnr = git_tapl-plnnr

AND plnal = git_tapl-plnal

<b>And zaehl = git_tap1-zaehl.</b>

IF sy-subrc = 0.

SELECT mandt plnty plnnr <b>plnal plnfl</b> plnkn zaehl vornr FROM plpo

INTO TABLE git_plpo

FOR ALL ENTRIES IN git_plas

WHERE plnty = git_plas-plnty

AND plnnr = git_plas-plnnr

and plnkn = git_plas-plnkn

and zaehl = git_plas-zaehl

<b>and plnal = git_plas-plnal

and plnfl = git_plas-Plnfl.</b>

ENDIF.

ENDIF.

regards,

pavan

Read only

0 Likes
1,180

Thanks Pavan,

sorry It doesn't work. PLPO Doesn't have fields PLNFL & PLNAL.

Regards,

Satish

Message was edited by:

Satish Panakala

Read only

Former Member
0 Likes
1,180

hi,

sorry overlooked

SELECT mandt plnty plnnr <b>vplfl vlntv</b> plnkn zaehl vornr FROM plpo

INTO TABLE git_plpo

FOR ALL ENTRIES IN git_plas

WHERE plnty = git_plas-plnty

AND plnnr = git_plas-plnnr

and plnkn = git_plas-plnkn

and zaehl = git_plas-zaehl

<b>and vplfl = git_plas-plnal

and vintv = git_plas-Plnfl.</b>

regards,

pavan

Read only

0 Likes
1,180

Pavan,

vplfl, vintv are always empty, it doesn't have any values, so it is not fetching any values at all.

Regards,

Satish

Read only

0 Likes
1,180

hi

SELECT mandt plnty plnnr <b>vplal</b> plnkn zaehl vornr FROM plpo

INTO TABLE git_plpo

FOR ALL ENTRIES IN git_plas

WHERE plnty = git_plas-plnty

AND plnnr = git_plas-plnnr

and plnkn = git_plas-plnkn

and zaehl = git_plas-zaehl

<b>and vplal = git_plas-plnal</b>.

regards,

pavan

Read only

0 Likes
1,180

Pavan,

VPLAL is also always empty, so we can not relate them.

Regards,

Satish

Read only

0 Likes
1,180

Hi,

Just tell me the tables relation, how i can get the record from PLPO table if i have Functional Location(TPLNR), Group Counter(PLNAL) & Operation Number(VORNR)?

Regards,

Satish

Read only

0 Likes
1,180

No Inputs from anybody?

-Satish

Read only

0 Likes
1,180

To use the BINARY SEARCH addition in the READ you must sort your table based on the key you are using to read the table.

Put Sort before going into LOOP.

SORT GIT_PLPO BY PLNTY PLNNR PLNKN ZAEHL VORNR.

LOOP AT......

         READ TABLE git_plpo INTO wa_plpo  << This read is failing in the 2nd loop onwords.
          WITH KEY mandt = wa_plas-mandt
                  plnty = wa_plas-plnty
                  plnnr = wa_plas-plnnr
                  plnkn = wa_plas-plnkn
                  zaehl = wa_plas-zaehl
                  vornr = wa_data-vornr
                  BINARY SEARCH.

Regards,

Naimesh Patel

Read only

0 Likes
1,180

I have Sorted before using read statement, it is not the problem with SORT.

I couldn't relate tables TAPL, PLAS & PLPO with values i have (TPLNR,PLNNR,VORNR). So i am not able read the proper Operation Number(VORNR).

I will explain you again

I have got TPLNR, PLNNR & VORNR.

Now i am fetching data from TAPL table for the TPLNR & PLNNR values i have.

Then for all the entries i got from TAPL i am fetching data from PLAS.

For all entries of PLAS i am getting the values of PLPO(here i will have Operation Number).

So to make Object Name in THEAD i am concatinating values from PLPO and have to update the long text.

But the relation is failing.

I think now everything is clear.

Thanks,

Satish

Read only

0 Likes
1,180

Yes... now it is clear...

It seems that your relation between tables is ok.

You have tried with the TOP - DOWN approch. Try with DOWN - TOP approch adn try without using the BINAREY SERACH in the READ.

Like:

LOOP AT PLPO.
  READ TABLE PLAS
     READ TABLE TAPL
        READ TABLE T_DATA
          IF SY-SUBRC = 0.
*             VALID RECORD
          ENDIF.
ENDLOOP.

Regards,

Naimesh Patel

Read only

0 Likes
1,180

Hi Naimesh,

Thanks for the input, i never thought of this. May be this could be the problem, i will try this.

Thanks,

Satish

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,180

hi Satish,

you have to SORT the internal table before the READ TABLE ... BINARY SEARCH. (I assume the table is TYPE STANDARD and not SORTED).

On the other hand pls. remove all declarations, selections related to field MANDT. That is handled automatically in the system, you don't need that.

ec

Read only

0 Likes
1,180

Eric,

I am sorting the internal tables before using read statements.

It doesn't matter with mandt, It is problem with fetching the proper data.

Regards,

Satish