Application Development and Automation 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: 
Read only

VT04 custom sort - almost completed, small problem

mihailo_sundic
Active Contributor
0 Likes
717

Hello dear experts,

I'm having a problem with sorting in VT04 transaction.

I had a requirement to sort the deliveries in shipping document by itinerary from VL52.

I have successfully updated structure I_VTRLK field Data1 => I_VTRLK-USR01_VBLB
from itinerary table.
I used this code:

tables: vark, valw, vawk.

data: zitin like vark-ausl_reih,
        zwa_i_vtrlk like line of i_vtrlk.
loop at i_vtrlk into zwa_i_vtrlk.
select single ausl_reih from vark into zitin where vark~kunwe EQ zwa_i_vtrlk-kunnr and vark~vstel EQ zwa_i_vtrlk-vstel and vark~aulwe EQ zwa_i_vtrlk-aulwe.
zwa_i_vtrlk-usr01_vblb = zitin.
modify i_vtrlk from zwa_i_vtrlk transporting usr01_vblb.
endloop.
sort i_vtrlk by usr01_vblb ascending.

Code works great, i_vtrlk is updated successfully and sorted by i_vtrlk-usr01_vblb.
Later, i_vtrlk should be inserted in vtrlk, and then vtrlk-user01_vblb is used as actual criteria in VT04.

I guess that vtrlk isn't getting updated from vtrlk, could anyone help me to determine 100% if
this is true, and possibly help me complete the requirement...

Regards,
Mihailo

1 ACCEPTED SOLUTION
Read only

mihailo_sundic
Active Contributor
0 Likes
545

OK, I'll post the solution in case someone else needs this.

It can't be done using the I_VTRLK structure with user exits, but you need to
fill C_VTRLK earlier in the program by enhancing the code.

if sy-tcode EQ 'VT04'.
   tables: vark, valw, vawk.
   data: zitin like vark-ausl_reih.
   data: zwa_c_vtrlk like line of c_vtrlk.
   loop at c_vtrlk into zwa_c_vtrlk.
     select single ausl_reih from vark into zitin where vark~kunwe EQ zwa_c_vtrlk-kunnr and vark~vstel EQ zwa_c_vtrlk-vstel and vark~aulwe EQ zwa_c_vtrlk-aulwe.
     zwa_c_vtrlk-usr01_vblb = zitin.
     modify c_vtrlk from zwa_c_vtrlk transporting usr01_vblb.
   endloop.
endif.


Regards,
Mihailo

1 REPLY 1
Read only

mihailo_sundic
Active Contributor
0 Likes
546

OK, I'll post the solution in case someone else needs this.

It can't be done using the I_VTRLK structure with user exits, but you need to
fill C_VTRLK earlier in the program by enhancing the code.

if sy-tcode EQ 'VT04'.
   tables: vark, valw, vawk.
   data: zitin like vark-ausl_reih.
   data: zwa_c_vtrlk like line of c_vtrlk.
   loop at c_vtrlk into zwa_c_vtrlk.
     select single ausl_reih from vark into zitin where vark~kunwe EQ zwa_c_vtrlk-kunnr and vark~vstel EQ zwa_c_vtrlk-vstel and vark~aulwe EQ zwa_c_vtrlk-aulwe.
     zwa_c_vtrlk-usr01_vblb = zitin.
     modify c_vtrlk from zwa_c_vtrlk transporting usr01_vblb.
   endloop.
endif.


Regards,
Mihailo