08-02-2008 6:48 PM
Hi Experts,
Please consider the scenario:
I have a table itab1 i which I have data for shipmet no, shipment type and corresponding delivery like this:
Shipment no | Shipment type | Delivery Number
123 X 1
123 X 2
123 X 3
456 Y 4
456 Y 5
Table 2 itab2
Delivery No | Delivery Date|
1 01.08.2008
2 03.08.2008
3 04.08.2008
4 04.08.2008
5 04.08.2008
Now I want to dispay like this
Shipment No : 123 Shipment type : X
....................................................................
1 01.08.2008
2 03.08.2008
3 04.08.2008
...................................................................
Shipment No : 456 Shipment type : Y
.......................................................................
4 04.08.2008
5 04.08.2008
I am not able to group similar deliveries under a shipment . Please help me.
Regards,
Krishan
08-02-2008 7:07 PM
Hi Krishan,
for DDIC table it is easier - it is enough to use join and group by. For internal table I suggest following (I don't have access to the SAP right now so if there are some small errors please correct them).
data: lv_counter type i.
SORT itab1 by Shipment no, Shipment type.
loop at itab1 into wa_itab1.
add 1 to lv_counter.
loop at itab2 into wa_itab2 where Delivery no = wa_itab1-Delivery no.
write: / lv_counter, wa_itab2-delivery date.
endloop.
at new Shipment type or new Shipment no.
write: / 'Shipment No :', wa_itab1-Shipment no, 'Shipment type :', wa_itab1-Shipment type.
write: / '....................................................................'.
endloop.
Regards,
Karol
08-02-2008 7:07 PM
Hi Krishan,
for DDIC table it is easier - it is enough to use join and group by. For internal table I suggest following (I don't have access to the SAP right now so if there are some small errors please correct them).
data: lv_counter type i.
SORT itab1 by Shipment no, Shipment type.
loop at itab1 into wa_itab1.
add 1 to lv_counter.
loop at itab2 into wa_itab2 where Delivery no = wa_itab1-Delivery no.
write: / lv_counter, wa_itab2-delivery date.
endloop.
at new Shipment type or new Shipment no.
write: / 'Shipment No :', wa_itab1-Shipment no, 'Shipment type :', wa_itab1-Shipment type.
write: / '....................................................................'.
endloop.
Regards,
Karol
08-02-2008 7:12 PM
08-02-2008 8:37 PM
data: wa1 like line of itab1.
sort itab1 by shipment shipmenttype.
sort itab2 by Deliveryno.
loop at itab1.
wa1 = itab1.
at new shipemtype.
write:/ '....................................................................'.
write 😕 'Shipment no:', itab1-shipmentno ,
'Shipment type:', itab1-shipmentype.
write:/ '....................................................................'.
loop at itab2 where delivernumber = wa1-deliverynumber.
write:/ itab2-deliverynumber, itab2-deliverydate.
endloop.
endat.
endloop.
Check the above code.