Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Regading New record

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

karol_seman
Active Participant
0 Kudos

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

3 REPLIES 3

karol_seman
Active Participant
0 Kudos

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

0 Kudos

Hi Karol,

Thanks a lot. I will try it.

Krishan

former_member188685
Active Contributor
0 Kudos
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.