‎2011 Dec 05 2:47 PM
Hello all,
I have a question to ask.
Have declared an internal table as follows:
types:tt_gps type table of ukv_gps with key ebeln.
data: gt_gps type tt_gps,
gs_gps like line of gt_gps.The Ebeln field is filled with values say 10 numbers.Now I want to use a select statement to put the corresponding Lieferant values into the itab gt_gps.
function zgps_read.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" TABLES
*" GPS_TAB STRUCTURE /BMW/UKV_GPS
*" EXCEPTIONS
*" SYSTEM_FAILURE
*" COMMUNICATION_FAILURE
*" NO_DATA
*"----------------------------------------------------------------------
select /bmw/ukv_gps~llief into corresponding fields of table gps_tab from /bmw/ukv_gps for all entries in
gps_tab where ebeln = gps_tab-ebeln.
if sy-subrc <> 0.
message 'Nicht gefunden' type 'I' raising no_data.
exit.
endif.
endfunction.Iam using in the FB,the same gps_tab as input and also filling the same gps_tab accordingly.
Thats not working properly.The gps_tab is getting filled with more than the needed values.
Regards
P
‎2011 Dec 05 3:07 PM
I don't think you can use the "FOR ALL ENTRIES IN" and "INTO CORRESPONDING FIELD OF TABLE" clauses on the same internal table gps_tab.
Try using different internal table for the INTO clause of the same type as gps_tab
‎2011 Dec 05 3:05 PM
you couldl try something like:
function zgps_read.
*"----
""Lokale Schnittstelle:
*" TABLES
*" GPS_TAB STRUCTURE /BMW/UKV_GPS
*" EXCEPTIONS
*" SYSTEM_FAILURE
*" COMMUNICATION_FAILURE
*" NO_DATA
*"----
field-symbols <lfs_g> type /bmw/ukv_gps.
loop at gps_tab assigning <lfs_g>.
if <lfs_g> is assigned.
select llief into <lfs_g>-llief up to 1 rows "can select single instead?
from /bmw/ukv_gps
where vbeln eq <lfs_g>-vbeln.
endselect. "if can't do a select single (what is primary key?)
endif.
endloop.
at this point, gps_tab now contains the 2nd field for all VBELN entries that were found in the db table.
endfunction.
‎2011 Dec 05 3:07 PM
I don't think you can use the "FOR ALL ENTRIES IN" and "INTO CORRESPONDING FIELD OF TABLE" clauses on the same internal table gps_tab.
Try using different internal table for the INTO clause of the same type as gps_tab
‎2011 Dec 05 4:01 PM
Hi,
try to build a range-table and than modify during loop with field-symbols:
FIELD-SYMBOLS:
<line> TYPE /bmw/ukv_gps,
<gps_line> TYPE /bmw/ukv_gps.
DATA:
lt_table TYPE tt_gps,
lrt_range TYPE RANGE OF ebeln.
lr_range LIKE LINE OF lrt_range.
lr_range-sign = 'I'.
lr_range-option = 'EQ'.
LOOP AT gps_tab ASSIGNING <gps_line>
lr_range-low = <gps_line>-ebeln.
append lr_range TO lrt_range.
ENDLOOP.
SELECT llief ebeln INTO CORRESPONDING FIELDS OF lt_table
FROM /bmw/ukv_gps
WHERE ebeln IN lrt_range.
IF sy-subrc <> 0.
LOOP AT lt_table ASSIGNING <line>.
READ TABLE gps_tab ASSIGNING <gps_line>
WITH KEY ebeln = <line>-ebeln.
if SY-subrc = 0.
* Modify directly the value in tab gps_tab
<gps_line>-llief = <line>-llief.
ENDIF:
ENDLOOP.
ENDIF.
Kind regards,
Hendrik