‎2006 Nov 26 9:08 AM
Types : begin of ts_ordsent,
Ordnr type ztsd2marc,
Kunnr type vbpa-kunnr,
Matnr type vbap-matnr,
Kwmeng type vbap-kwmeng,
Edatu type vbep-edatu,
Vbeln type vbak-vbeln,
End of ts_ordsent,
Tt_ordsent type table of ts_ordsent.
Types :begin of ts_ship,
Vbenl type vbak-vbeln,
Kunnr type vbpa-kunnr,
End of ts_ship,
Tt_ship type standard table of ts_ship.
Types :begin of ts_material,
Vbenl type vbak-vbeln,
matnr type vbap-matnr,
kwmeng type vbap-kwmeng,
End of ts_material,
Tt_material type standard table of ts_material.
Types :begin of ts_ddate,
Vbenl type vbak-vbeln,
edatu type vbep-edatu,
End of ts_ddate,
Tt_ddate type standard table of ts_ddate.
Types :begin of ts_order,
Vbenl type vbak-vbeln,
vkorg type vbak-vkorg,
End of ts_order,
Tt_order type standard table of ts_order.
Data : ls_ordsent type ts_ordsent,
Ls_ship type ts_ship,
Ls_material type ts_material,
Ls_ddate type ts_ddate,
Ls_order type ls_order,
lt_ordsent type tt_ordsent,
Lt_ship type tt_ship,
Lt_material type tt_material,
Lt_ddate type tt_ddate,
Lt_order type lt_order.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: pa_sotg type vbak-vkorg,
Pa_dpln type vbap-werks.
Select-options : so_shpt for vbpa-kunnr,
So_ddat for vbep-edatu.
SELECTION-SCREEN END OF BLOCK b2.
Select ordnr from ztsd2marc
Into corresponding fields of table lt_ordsent.
Select vbeln kunnr from vbpa
Into corresponding fields of table lt_ship
For all entries in lt_ordsent
Where kunnr in so_shpt.
Select vbeln matnr kwmeng from vbap
Into corresponding fields of table lt_material
For all entries in lt_ordsent
Where werks = pa_dpln.
Select vbeln edatu from vbep
Into corresponding fields of table lt_ddate
For all entries in lt_ordsent
Where edatu in so_ddat.
Select vbeln vkorg from vbak
Into corresponding fields of table lt_order
For all entries in lt_ordsent
Where .vkorg = pa_sorg.
Loop at lt_ordsent into ls_ordsent.
Read table lt_ship into ls_ship with key vbeln = ls_ordsent-ordnr.
Check sy-subrc eq 0.
Move ls_ship-kunnr to ls_ordsent-kunnr.
Modify lt_ordsent from ls_ordsent.
Endloop.
Loop at lt_ordsent into ls_ordsent.
Read table lt_material into ls_material with key vbeln = ls_ordsent-ordnr.
Check sy-subrc eq 0.
Move ls_material-matnr to ls_ordsent-matnr.
Move ls_material-kwmeng to ls_ordsent-kwmeng.
Modify lt_ordsent from ls_ordsent.
Endloop.
Loop at lt_ordsent into ls_ordsent.
Read table lt_ddate into ls_ddate with key vbeln = ls_ordsent-ordnr.
Check sy-subrc eq 0.
Move ls_ddate-edatu to ls_ordsent-edatu.
Modify lt_ordsent from ls_ordsent.
Endloop.
Loop at lt_ordsent into ls_ordsent.
Read table lt_order into ls_order with key vbeln = ls_ordsent-ordnr.
Check sy-subrc eq 0.
Move ls_order-vbeln to ls_ordsent-vbeln.
Modify lt_ordsent from ls_ordsent.
Endloop.
then display it in avl format.
‎2006 Nov 26 9:12 AM
hi,
try to avoid that INTO CORRESPONDING.
create internal table with only fields you want.
then use INTO TABLE.
otherwise its seems ok.
rgds
Anver
‎2006 Nov 26 9:20 AM
One more sugestion.
now u r writing for seperate LOOPS.
You can put all those Four READ statemnts in one siingle LOOP.
After all READ and MOVE statement give the MODIFY statement.
So that u can avoid that four times looping
Loop at lt_ordsent into ls_ordsent.
Read table lt_ship into ls_ship with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_ship-kunnr to ls_ordsent-kunnr.
endif.
Read table lt_material into ls_material with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0..
Move ls_material-matnr to ls_ordsent-matnr.
Move ls_material-kwmeng to ls_ordsent-kwmeng.
endif.
Read table lt_ddate into ls_ddate with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_ddate-edatu to ls_ordsent-edatu.
if sy-subrc eq 0.
Read table lt_order into ls_order with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_order-vbeln to ls_ordsent-vbeln.
endif.
Modify lt_ordsent from ls_ordsent.
Endloop.
rgds
Anver
‎2006 Nov 26 9:20 AM
HI neha,
I donno wat is given in ztsd2marc but few changes in this code are u have given select options but tables are not defined like vbpa and vbep and structures have some naming errors and read data is done witout transporting any field u can over come this by typing 'transporting any '.finally u want thjis in alv , in that case define alv types like field naes,position ets, hope u know that
‎2006 Nov 26 9:26 AM
If there is <b>1:1 relation between all table</b> entries you have here,
then you <b>need not use 4 LOOPS for that</b>. Just you one as below,
Loop at lt_ordsent into ls_ordsent.
Read table lt_ship into ls_ship with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_ship-kunnr to ls_ordsent-kunnr.
endif.
Read table lt_material into ls_material with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_material-matnr to ls_ordsent-matnr.
Move ls_material-kwmeng to ls_ordsent-kwmeng.
endif.
Read table lt_ddate into ls_ddate with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_ddate-edatu to ls_ordsent-edatu.
endif.
Read table lt_order into ls_order with key vbeln = ls_ordsent-ordnr.
if sy-subrc eq 0.
Move ls_order-vbeln to ls_ordsent-vbeln.
endif.
Modify lt_ordsent from ls_ordsent.
Endloop.
The <b>execution time will be very less</b>.
Regards
Kathirvel
‎2006 Nov 26 9:26 AM
Hi
You should correct the lines of your codes where u use FOR ALL ENTRIES option.
It doesn't make sense to use FOR ALL ENTRIES and not to use the table in WHERE condition. For example:
*>>>>>>>>>>>>>>> ERROR <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
SELECT VBELN KUNNR FROM VBPA
INTO CORRESPONDING FIELDS OF TABLE LT_SHIP
FOR ALL ENTRIES IN LT_ORDSENT
* U have to indicate a condtion for the table used in
* FOR ALL ENTRIES:
WHERE VBELN IN LT_ORDSENT-ORDNR "???????????
AND KUNNR IN SO_SHPT.The following considerations are to improve the performance:
- If the internal table you're using in the select has the same fields you're finding out it's better to use only INTO TABLE statamente instead of INTO CORRISPONDING FIELDS OF TABLE:
SELECT VBELN KUNNR FROM VBPA
INTO TABLE LT_SHIP
FOR ALL ENTRIES IN LT_ORDSENT
WHERE VBELN IN LT_ORDSENT-ORDNR "???????????
AND KUNNR IN SO_SHPT.- U can do only one big loop instead of several loop of the same table:
Loop at lt_ordsent into ls_ordsent.
Read table lt_ship into ls_ship
with key vbeln = ls_ordsent-ordnr.
*Check sy-subrc eq 0.
IF SY-SUBRC = 0.
Move ls_ship-kunnr to ls_ordsent-kunnr.
*Modify lt_ordsent from ls_ordsent.
*Endloop.
ENDIF.
*Loop at lt_ordsent into ls_ordsent.
Read table lt_material into ls_material
with key vbeln = ls_ordsent-ordnr.
*Check sy-subrc eq 0.
IF SY-SUBRC = 0.
Move ls_material-matnr to ls_ordsent-matnr.
Move ls_material-kwmeng to ls_ordsent-kwmeng.
*Modify lt_ordsent from ls_ordsent.
*Endloop.
ENDIF.
*Loop at lt_ordsent into ls_ordsent.
Read table lt_ddate into ls_ddate
with key vbeln = ls_ordsent-ordnr.
*Check sy-subrc eq 0.
IF SY-SUBRC = 0.
Move ls_ddate-edatu to ls_ordsent-edatu.
*Modify lt_ordsent from ls_ordsent.
*Endloop.
ENDIF.
*Loop at lt_ordsent into ls_ordsent.
Read table lt_order into ls_order
with key vbeln = ls_ordsent-ordnr.
*Check sy-subrc eq 0.
IF SY-SUBRC = 0.
Move ls_order-vbeln to ls_ordsent-vbeln.
ENDIF.
Modify lt_ordsent from ls_ordsent.
Endloop.The last thing u should consider is you get some data from header, but also item table, so you coudln't use the READ TABLE statament because it's like to do a select single, but you should use the loop statamtent.
For example u can have several material for the same order so if you want to get all data you should use a loop and append statament.
U should use PSONR field to:
..................
Types: begin of ts_ship,
Vbenl type vbak-vbeln,
POSNR TYPE VBAP-POSNR,
Kunnr type vbpa-kunnr,
End of ts_ship,
Tt_ship type standard table of ts_ship.
Types: begin of ts_material,
Vbenl type vbak-vbeln,
POSNR TYPE VBAP-POSNR,
matnr type vbap-matnr,
kwmeng type vbap-kwmeng,
End of ts_material,
Tt_material type standard table of ts_material.
Types: begin of ts_ddate,
Vbenl type vbak-vbeln,
POSNR TYPE VBAP-POSNR,
edatu type vbep-edatu,
End of ts_ddate,
Tt_ddate type standard table of ts_ddate.
DATA: GT_ORDSENT TYPE TT_ORDSENT.
SELECT ORDNR FROM ZTSD2MARC
INTO CORRESPONDING FIELDS OF TABLE LT_ORDSENT.
SELECT VBELN POSNR KUNNR FROM VBPA
INTO CORRESPONDING FIELDS OF TABLE LT_SHIP
FOR ALL ENTRIES IN LT_ORDSENT
WHERE VBELN = LT_ORDSENT-ORDNR
AND KUNNR IN SO_SHPT.
SELECT VBELN POSNR MATNR KWMENG FROM VBAP
INTO TABLE LT_MATERIAL
FOR ALL ENTRIES IN LT_ORDSENT
WHERE VBELN = LT_ORDSENT-ORDNR
AND WERKS = PA_DPLN.
SELECT VBELN POSNR EDATU FROM VBEP
INTO TABLE LT_DDATE
FOR ALL ENTRIES IN LT_ORDSENT
WHERE VBELN = LT_ORDSENT-ORDNR
AND EDATU IN SO_DDAT.
SELECT VBELN VKORG FROM VBAK
INTO TABLE LT_ORDER
FOR ALL ENTRIES IN LT_ORDSENT
WHERE VBELN = LT_ORDSENT-ORDNR
AND VKORG = PA_SORG.
LOOP AT LT_ORDSENT INTO LS_ORDSENT.
* Get Header data:
READ TABLE LT_ORDER INTO LS_ORDER WITH KEY VBELN = LS_ORDSENT-ORDNR.
IF SY-SUBRC = 0.
LS_ORDSENT-VKORG = LT_ORDER-VKORG.
ENDIF.
READ TABLE LT_SHIP INTO LS_SHIP WITH KEY VBELN = LS_ORDSENT-ORDNR
POSNR = '000000'.
IF SY-SUBRC EQ 0.
MOVE LS_SHIP-KUNNR TO LS_ORDSENT-KUNNR.
ENDIF.
* Get Item data:
LOOP LT_MATERIAL INTO LS_MATERIAL WHERE VBELN = = LS_ORDSENT-ORDNR.
READ TABLE LT_DDATE INTO LS_DDATE
WITH KEY VBELN = LS_ORDSENT-ORDNR
POSNR = LS_MATERIAL-POSNR.
IF SY-SUBRC <> 0.
CLEAR LS_DDATE.
ENDIF.
MOVE LS_MATERIAL-MATNR TO LS_ORDSENT-MATNR.
MOVE LS_MATERIAL-KWMENG TO LS_ORDSENT-KWMENG.
MOVE LS_DDATE-EDATU TO LS_ORDSENT-EDATU.
APPEND LS_ORDSENT TO GT_ORDSENT.
ENDLOOP.
ENDLOOP.Max