In my smartform I have a column for ship to address in my main window where I need to fill it up with the address depending upon the address number . I ahve some special cases where the customer number is same but the address numbers are different for a particular invoice number in such cases my code dosent pick up both the addresses and just picks up one as the kunnr is same but the adrnr is dirrenet . When the kunnr is different asw ell as the adrnr is different it does pick up both address. Could I get some help to bring in both the ship to address on my form .
clear: gs_vbpa. ** get location from shipto of billing document. select single * from vbpa into gs_vbpa where vbeln eq gs_gen_del-bil_number and posnr eq gs_gen_del-itm_number and parvw eq 'WE'. if sy-subrc = 0. select single * from adrc into ws_adrc where addrnumber = l_adrnr. else. * get location from shipto of sales order if no updated shipto from bill doc loop at is_bil_invoice-it_reford into gs_it_reford where bil_number = gs_gen_del-bil_number and itm_number = gs_gen_del-itm_number. select single * from vbpa into gs_vbpa where vbeln eq gs_it_reford-order_numb and parvw eq 'WE'. if sy-subrc = 0. select single * from adrc into ws_adrc where addrnumber = l_adrnr. endif. endloop. endif. * get g_shipto_print if g_old_shipto = gs_vbpa-kunnr. g_shipto_print = ' '. g_dotted_line_print = ' '. elseif g_old_shipto is initial. g_shipto_print = 'X'. g_dotted_line_print = ' '. g_old_shipto = gs_vbpa-kunnr. else. g_shipto_print = 'X'. g_dotted_line_print = 'X'. g_old_shipto = gs_vbpa-kunnr. endif.
As per the table as we see data for the invoices are as follows.
vbeln posnr parwv kunnr adrnr
0090003708 10 WE 0005000432 0000111327
0090003708 30 WE 0000176700 9000000565
In the above case it shows both the address. but in the below case it just shows one address even when the adrnr is different but kunnr is same.
0090003703 10 WE 0000176700 9000000564
0090003703 30 WE 0000176700 9000000565
I would like to bring in both the addresses based on adrnr and not kunnr in my form .