‎2007 Dec 13 11:26 AM
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
‎2007 Dec 13 11:47 AM
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
‎2007 Dec 13 12:11 PM
Thanks Pavan,
sorry It doesn't work. PLPO Doesn't have fields PLNFL & PLNAL.
Regards,
Satish
Message was edited by:
Satish Panakala
‎2007 Dec 13 12:21 PM
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
‎2007 Dec 13 12:28 PM
Pavan,
vplfl, vintv are always empty, it doesn't have any values, so it is not fetching any values at all.
Regards,
Satish
‎2007 Dec 13 12:45 PM
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
‎2007 Dec 13 1:47 PM
Pavan,
VPLAL is also always empty, so we can not relate them.
Regards,
Satish
‎2007 Dec 13 1:53 PM
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
‎2007 Dec 13 3:56 PM
‎2007 Dec 13 4:02 PM
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
‎2007 Dec 13 5:16 PM
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
‎2007 Dec 13 8:41 PM
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
‎2007 Dec 13 9:18 PM
Hi Naimesh,
Thanks for the input, i never thought of this. May be this could be the problem, i will try this.
Thanks,
Satish
‎2007 Dec 13 12:26 PM
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
‎2007 Dec 13 12:30 PM
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