2007 Aug 22 6:48 PM
Can I select from an internal table? here is my code but it says WA_SCHED_DATA is not defined.
WA_SCHED_DATA[] = T_SCHED_DATA[].
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
SELECT VBELN POSNR sched_line DSDEL_DATE req_date ORDER_QTY
INTO TABLE TF_SCHED_DATA
FROM WA_SCHED_DATA
WHERE
VBELN = WA_SCHED_DATA-VBELN
POSNR = WA_SCHED_DATA-POSNR
DSDEL_DATE = WA_SCHED_DATA-REQ_DATE
SCHED_LINE NE WA_SCHED_DATA-SCHED_LINE.
ENDIF.
2007 Aug 22 7:02 PM
Hi,
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
read table wa_sched_data with key
VBELN = LS_DATA-VBELN
POSNR = LS_DATA-POSNR
DSDEL_DATE = LS_DATA-REQ_DATE
SCHED_LINE NE LS_DATA-SCHED_LINE.
ENDIF.
endloop.
your wa_sched_data is not a database table from SAP that why it was throughing error that table not found.
select can be used to select from data base only.
if you want to read data from internal table you have to use read statements.
Thanks,
Deepak.
Message was edited by:
KDeepak
Hi,
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
read table wa_sched_data with key
VBELN = LS_DATA-VBELN
POSNR = LS_DATA-POSNR
DSDEL_DATE = LS_DATA-REQ_DATE
SCHED_LINE NE LS_DATA-SCHED_LINE.
ENDIF.
endloop.
your wa_sched_data is not a database table from SAP that why it was throughing error that table not found.
select can be used to select from data base only.
if you want to read data from internal table you have to use read statements.
Thanks,
Deepak.
Message was edited by:
KDeepak
2007 Aug 22 6:51 PM
Hi,
Check wa_sched_data declerations.
But SELECT statements inside loop is not advisable as it will be performance issue.
You can use for all entries on internal table t_sched_data.
Thanks,
Deepak.
2007 Aug 22 6:57 PM
how would I do that if I need to check if the qunatity is zero?
2007 Aug 22 7:01 PM
What you can do is instead of selecting inside loop first select all entries and then do a read inside the loop.This is much better in terms of performance since you reduce the database hits.
If you need some more help on how to use select for all entries, let me know.
Thanks
Amruta
2007 Aug 22 7:01 PM
What you can do is instead of selecting inside loop first select all entries and then do a read inside the loop.This is much better in terms of performance since you reduce the database hits.
If you need some more help on how to use select for all entries, let me know.
Thanks
Amruta
2007 Aug 22 7:02 PM
Hi,
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
read table wa_sched_data with key
VBELN = LS_DATA-VBELN
POSNR = LS_DATA-POSNR
DSDEL_DATE = LS_DATA-REQ_DATE
SCHED_LINE NE LS_DATA-SCHED_LINE.
ENDIF.
endloop.
your wa_sched_data is not a database table from SAP that why it was throughing error that table not found.
select can be used to select from data base only.
if you want to read data from internal table you have to use read statements.
Thanks,
Deepak.
Message was edited by:
KDeepak
2007 Aug 22 7:04 PM
I tried this and it doens't seem to like the very last line using NE
2007 Aug 22 7:12 PM
HI,
You cannot use a select statement on internal table.. use loop or read statement.
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
loop at wa_sched_data where
VBELN = LS_DATA-VBELN
POSNR = LS_DATA-POSNR
DSDEL_DATE = LS_DATA-REQ_DATE
SCHED_LINE NE LS_DATA-SCHED_LINE.
TF_SCHED_DATA-order = wa_sched_data-order.
append tf_sched_data.
ENDIF.
endloop.
Thaks
Mahesh
2007 Aug 22 7:14 PM
2007 Aug 22 7:20 PM
use this
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
loop at wa_sched_data where
VBELN = LS_DATA-VBELN
<b>AND</b> POSNR = LS_DATA-POSNR
<b>AND</b> DSDEL_DATE = LS_DATA-REQ_DATE
<b>AND</b> SCHED_LINE NE LS_DATA-SCHED_LINE.
TF_SCHED_DATA-order = wa_sched_data-order.
append tf_sched_data.
ENDIF.
endloop.
2007 Aug 22 7:24 PM
OKAY i THINK I GET THIS BUT WHAT IS THE FINAL STATEMTN DOING.
TF_SCHED_DATA-order = wa_sched_data-order.
append tf_sched_data.
2007 Aug 22 7:47 PM
I am trying to put the data into the internal table TF_SCHED_DATA which ever mathces the criteria.
you want to fill this table fields with the required data na..
so
TF_SCHED_DATA-vbeln = wa_sched_data-vbeln.
tf_sched_data-posnr = wa_sched_Data-posnr.
append TF_SCHED_DATA.
Thanks
Mahesh
2007 Aug 22 8:01 PM
does this make sense what i ma doing?
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
LOOP at wa_sched_data INTO WS_DATA
where
VBELN = LS_DATA-VBELN
AND POSNR = LS_DATA-POSNR
AND DSDEL_DATE = LS_DATA-REQ_DATE
AND SCHED_LINE NE LS_DATA-SCHED_LINE.
APPEND WS_DATA TO tf_sched_data.
TF_SCHED_DATA-order = wa_sched_data-order.
append WS_DATA TO tf_sched_data.
ENDLOOP.
ENDIF.
*
ENDLOOP.
2007 Aug 22 8:03 PM
Yes it does. provided ws_data and tf_sched_data are of same structure...
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
LOOP at wa_sched_data INTO WS_DATA
where
VBELN = LS_DATA-VBELN
AND POSNR = LS_DATA-POSNR
AND DSDEL_DATE = LS_DATA-REQ_DATE
AND SCHED_LINE NE LS_DATA-SCHED_LINE.
APPEND WS_DATA TO tf_sched_data.
ENDLOOP.
ENDIF.
*
ENDLOOP.
Thanks
Mahesh
2007 Aug 22 8:21 PM
nothing is in ws_data when i debug so what could be worng? wa_sched_data is loaded
2007 Aug 22 8:24 PM
there may not be the data in table wa_sched_data with this where condition..
check the two internal tables T_SCHED_DATA INTO and wa_sched_data . and also may be the case that the LS_DATA-ORDER_QTY is greater than zero all the time...
loop at <b>T_SCHED_DATA</b> INTO LS_DATA.
IF <b>LS_DATA-ORDER_QTY = 0.</b>
LOOP at wa_sched_data INTO WS_DATA
where
<b>VBELN = LS_DATA-VBELN
AND POSNR = LS_DATA-POSNR
AND DSDEL_DATE = LS_DATA-REQ_DATE
AND SCHED_LINE NE LS_DATA-SCHED_LINE.</b>
APPEND WS_DATA TO tf_sched_data.
ENDLOOP.
ENDIF.
*
ENDLOOP.
2007 Aug 22 8:28 PM
you keep using LS_data below. is that correct
VBELN = LS_DATA-VBELN
AND POSNR = LS_DATA-POSNR
AND DSDEL_DATE = LS_DATA-REQ_DATE
AND SCHED_LINE NE LS_DATA-SCHED
2007 Aug 22 8:46 PM
Yes it is... is this not ur requirement that for each record in t_sched_data table if the quantity is eq 0 then select the records from the table wa_sched_data where the order item date and schedule line matches.
check the order_qty field value in the internal table t_sched_data this could be the case that if order_qty is not equal to 0 then the second loop will not exeucte...
do one think put a break point at the second loop and see if it triggers .. if you reach that point it indicates u have atlease one record whose quanity is equla to 0 then see the values in the wa_sched_data table and the ls_data ..
loop at T_SCHED_DATA INTO LS_DATA.
IF LS_DATA-ORDER_QTY = 0.
LOOP at wa_sched_data INTO WS_DATA
where
VBELN = LS_DATA-VBELN
AND POSNR = LS_DATA-POSNR
AND DSDEL_DATE = LS_DATA-REQ_DATE
AND SCHED_LINE NE LS_DATA-SCHED_LINE.
APPEND WS_DATA TO tf_sched_data.
ENDLOOP.
ENDIF.
ENDLOOP.
2007 Aug 22 9:07 PM
yes records were found = 0 but the line belwo doesn nothing. Nothing is in ws_data
LOOP at wa_sched_data INTO WS_DATA
2007 Aug 22 9:36 PM
it clearly indicates that wa_sched_data does not have any matching data from ls_data...
Thanks
mahesh
2007 Aug 23 9:55 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |